Class: AmaLayout::NavigationDecorator
- Inherits:
-
Draper::Decorator
- Object
- Draper::Decorator
- AmaLayout::NavigationDecorator
- Defined in:
- lib/ama_layout/decorators/navigation_decorator.rb
Instance Method Summary collapse
- #account_toggle ⇒ Object
- #display_name_text ⇒ Object
- #items ⇒ Object
- #name_or_email ⇒ Object
- #notification_badge ⇒ Object
- #notification_sidebar ⇒ Object
- #notifications ⇒ Object
- #notifications_heading ⇒ Object
- #sidebar ⇒ Object
- #sign_out_link ⇒ Object
- #top_nav ⇒ Object
Instance Method Details
#account_toggle ⇒ Object
32 33 34 |
# File 'lib/ama_layout/decorators/navigation_decorator.rb', line 32 def account_toggle h.render partial: "account_toggle" end |
#display_name_text ⇒ Object
9 10 11 |
# File 'lib/ama_layout/decorators/navigation_decorator.rb', line 9 def display_name_text name_or_email.truncate(30) end |
#items ⇒ Object
5 6 7 |
# File 'lib/ama_layout/decorators/navigation_decorator.rb', line 5 def items object.items.map { |i| i.decorate } end |
#name_or_email ⇒ Object
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_badge ⇒ Object
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.content_tag( :div, active_notification_count, class: 'notification__badge', data: { notification_count: true } ) end end |
#notification_sidebar ⇒ Object
55 56 57 58 59 |
# File 'lib/ama_layout/decorators/navigation_decorator.rb', line 55 def if user h.render 'ama_layout/notification_sidebar', navigation: self, notifications: decorated_notifications end end |
#notifications ⇒ Object
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_heading ⇒ Object
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.content_tag :p, 'Most Recent Notifications', class: 'mt1' else h.content_tag :p, 'No Recent Notifications', class: 'mt1 italic' end end |
#sidebar ⇒ Object
24 25 26 |
# File 'lib/ama_layout/decorators/navigation_decorator.rb', line 24 def h.render partial: "ama_layout/sidebar", locals: { navigation: self } if items.any? end |
#sign_out_link ⇒ Object
13 14 15 16 17 18 |
# File 'lib/ama_layout/decorators/navigation_decorator.rb', line 13 def sign_out_link return "" unless user h.content_tag :li, class: "side-nav__item" do h.concat h.link_to "Sign Out", "/logout", class: "side-nav__link" end end |
#top_nav ⇒ Object
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 |