Module: NotificationEngine::ApplicationHelper
- Defined in:
- app/helpers/notification_engine/application_helper.rb
Instance Method Summary collapse
-
#active_filter_class(filter) ⇒ Object
Returns a CSS class name for the active filter tab.
-
#notification_bell(**options) ⇒ Object
Renders a notification bell link with an unread count badge.
-
#unread_notification_count ⇒ Object
Returns the unread notification count for the current user.
Instance Method Details
#active_filter_class(filter) ⇒ Object
Returns a CSS class name for the active filter tab.
36 37 38 39 |
# File 'app/helpers/notification_engine/application_helper.rb', line 36 def active_filter_class(filter) current = params[:filter].presence current == filter ? "active" : "" end |
#notification_bell(**options) ⇒ Object
Renders a notification bell link with an unread count badge.
<%= notification_bell %>
<%= notification_bell(class: "my-bell") %>
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
# File 'app/helpers/notification_engine/application_helper.rb', line 10 def notification_bell(**) user = notification_engine_current_user return unless user count = user.notifications.unread.count path = notification_engine.notifications_path css = ["notification-bell", .delete(:class)].compact.join(" ") tag.a(href: path, class: css, **) do safe_join([ tag.span("Notifications", class: "notification-bell-label"), (tag.span(count, class: "ui mini circular blue label notification-badge") if count > 0) ].compact) end end |
#unread_notification_count ⇒ Object
Returns the unread notification count for the current user.
28 29 30 31 32 33 |
# File 'app/helpers/notification_engine/application_helper.rb', line 28 def unread_notification_count user = notification_engine_current_user return 0 unless user user.notifications.unread.count end |