Class: AmaLayout::NavigationDecorator

Inherits:
Draper::Decorator
  • Object
show all
Defined in:
lib/ama_layout/decorators/navigation_decorator.rb

Instance Method Summary collapse

Instance Method Details

#account_toggleObject



32
33
34
# File 'lib/ama_layout/decorators/navigation_decorator.rb', line 32

def 
  h.render partial: "account_toggle"
end

#display_name_textObject



9
10
11
# File 'lib/ama_layout/decorators/navigation_decorator.rb', line 9

def display_name_text
  name_or_email.truncate(30)
end

#itemsObject



5
6
7
# File 'lib/ama_layout/decorators/navigation_decorator.rb', line 5

def items
  object.items.map { |i| i.decorate }
end

#name_or_emailObject



28
29
30
# File 'lib/ama_layout/decorators/navigation_decorator.rb', line 28

def name_or_email
  display_name.present? ? "Welcome, #{display_name.titleize}" : email
end

#notification_badgeObject



42
43
44
45
46
47
48
49
50
51
52
53
# File 'lib/ama_layout/decorators/navigation_decorator.rb', line 42

def notification_badge
  if new_notifications?
    h.(
      :div,
      active_notification_count,
      class: 'notification__badge',
      data: {
        notification_count: true
      }
    )
  end
end

#notification_sidebarObject



55
56
57
58
59
# File 'lib/ama_layout/decorators/navigation_decorator.rb', line 55

def notification_sidebar
  if user
    h.render 'ama_layout/notification_sidebar', navigation: self, notifications: decorated_notifications
  end
end

#notificationsObject



36
37
38
39
40
# File 'lib/ama_layout/decorators/navigation_decorator.rb', line 36

def notifications
  if user
    h.render 'ama_layout/notifications', notifications: user.notifications, navigation: self
  end
end

#notifications_headingObject



61
62
63
64
65
66
67
# File 'lib/ama_layout/decorators/navigation_decorator.rb', line 61

def notifications_heading
  if user.notifications.any?
    h. :p, 'Most Recent Notifications', class: 'mt1'
  else
    h. :p, 'No Recent Notifications', class: 'mt1 italic'
  end
end


24
25
26
# File 'lib/ama_layout/decorators/navigation_decorator.rb', line 24

def sidebar
  h.render partial: "ama_layout/sidebar", locals: { navigation: self } if items.any?
end


13
14
15
16
17
18
# File 'lib/ama_layout/decorators/navigation_decorator.rb', line 13

def sign_out_link
  return "" unless user
  h. :li, class: "side-nav__item" do
    h.concat h.link_to "Sign Out", "/logout", class: "side-nav__link"
  end
end

#top_navObject



20
21
22
# File 'lib/ama_layout/decorators/navigation_decorator.rb', line 20

def top_nav
  h.render partial: "ama_layout/top_nav", locals: { navigation: self } if items.any?
end