Class: AmaLayout::NavigationDecorator
- Inherits:
-
Object
- Object
- AmaLayout::NavigationDecorator
- Includes:
- DraperReplacement
- Defined in:
- lib/ama_layout/decorators/navigation_decorator.rb
Instance Method Summary collapse
- #account_toggle(view_data = {}) ⇒ Object
- #display_name_text ⇒ Object
- #items ⇒ Object
- #member_links ⇒ Object
- #mobile_links ⇒ Object
- #mobile_notification_icon ⇒ Object
- #name_or_email ⇒ Object
- #notification_badge ⇒ Object
- #notification_icon ⇒ Object
- #notification_sidebar ⇒ Object
- #notifications_heading ⇒ Object
- #sidebar ⇒ Object
- #sign_out_link ⇒ Object
- #top_nav ⇒ Object
Instance Method Details
#account_toggle(view_data = {}) ⇒ Object
43 44 45 |
# File 'lib/ama_layout/decorators/navigation_decorator.rb', line 43 def account_toggle(view_data = {}) h(view_data).render partial: 'account_toggle' end |
#display_name_text ⇒ Object
11 12 13 |
# File 'lib/ama_layout/decorators/navigation_decorator.rb', line 11 def display_name_text name_or_email.try(:truncate, 30) end |
#items ⇒ Object
7 8 9 |
# File 'lib/ama_layout/decorators/navigation_decorator.rb', line 7 def items object.items.map(&:decorate) end |
#member_links ⇒ Object
21 22 23 24 25 |
# File 'lib/ama_layout/decorators/navigation_decorator.rb', line 21 def member_links return '' unless user && %w[member member_renewal member_outstanding_balance].include?(user.try(:menu_key)) h.render partial: ama_layout_partial('member_links') end |
#mobile_links ⇒ Object
59 60 61 62 63 |
# File 'lib/ama_layout/decorators/navigation_decorator.rb', line 59 def mobile_links return '' if user h.render ama_layout_partial('mobile_links') end |
#mobile_notification_icon ⇒ Object
53 54 55 56 57 |
# File 'lib/ama_layout/decorators/navigation_decorator.rb', line 53 def mobile_notification_icon return '' unless user h.render ama_layout_partial('mobile_notification_icon'), navigation: self end |
#name_or_email ⇒ Object
39 40 41 |
# File 'lib/ama_layout/decorators/navigation_decorator.rb', line 39 def name_or_email display_name.present? ? "Welcome, #{display_name.titleize}" : email end |
#notification_badge ⇒ Object
65 66 67 68 69 70 71 72 73 74 75 76 |
# File 'lib/ama_layout/decorators/navigation_decorator.rb', line 65 def notification_badge return '' unless new_notifications? h.content_tag( :div, active_notification_count, class: 'notification__badge', data: { notification_count: true } ) end |
#notification_icon ⇒ Object
47 48 49 50 51 |
# File 'lib/ama_layout/decorators/navigation_decorator.rb', line 47 def notification_icon return '' unless user h.render ama_layout_partial('notification_icon'), navigation: self end |
#notification_sidebar ⇒ Object
78 79 80 81 82 |
# File 'lib/ama_layout/decorators/navigation_decorator.rb', line 78 def return '' unless user h.render ama_layout_partial('notification_sidebar'), navigation: self, notifications: decorated_notifications end |
#notifications_heading ⇒ Object
84 85 86 87 88 89 90 |
# File 'lib/ama_layout/decorators/navigation_decorator.rb', line 84 def notifications_heading if user.notifications.any? h.content_tag :p, 'Most Recent Notifications', class: 'mt1' else h.content_tag :p, 'No Recent Notifications', class: 'mt1 italic' end end |
#sidebar ⇒ Object
33 34 35 36 37 |
# File 'lib/ama_layout/decorators/navigation_decorator.rb', line 33 def return '' if items.none? h.render partial: ama_layout_partial('sidebar'), locals: { navigation: self } end |
#sign_out_link ⇒ Object
15 16 17 18 19 |
# File 'lib/ama_layout/decorators/navigation_decorator.rb', line 15 def sign_out_link return '' unless user h.render partial: ama_layout_partial('sign_out_link') end |
#top_nav ⇒ Object
27 28 29 30 31 |
# File 'lib/ama_layout/decorators/navigation_decorator.rb', line 27 def top_nav return '' unless user h.render partial: ama_layout_partial('top_nav'), locals: { navigation: self } end |