retrospring/app/views/navigation/main/_notifications.haml
Andreas Nedbal b550e78272 Refactor notifications into partials
All notification type layouts have been:

1) present in both the navigation layout and the notification page
2) in a single file

This commit addresses both issues and creates partials for all notfication types.
2020-04-26 15:26:55 +02:00

26 lines
1.1 KiB
Text

= nav_entry t('views.navigation.notifications'), notifications_path, badge: notification_count, class: 'd-block d-sm-none'
- notifications = Notification.for(current_user).where(new: true).limit(4)
%li.nav-item.dropdown.d-none.d-sm-block
%a.nav-link.dropdown-toggle{href: "#", "data-toggle" => "dropdown"}
- if notification_count.nil?
%i.fa.fa-bell-o
- else
%i.fa.fa-bell
%span.sr-only Notifications
%span.badge= notification_count
.dropdown-menu.notification-center
- if notifications.count == 0
.dropdown-item.text-center.notifications--none
%i.fa.fa-bell-o.no-notifications
%p No new notifications.
%a.dropdown-item.text-center{href: notifications_path('all')}
%i.fa.fa-fw.fa-chevron-right
Show all notifications
- else
- notifications.each do |notification|
.dropdown-item.media.notification--dropdown-media
= render "notifications/type/#{notification.target_type.downcase}", notification: notification
%a.dropdown-item.text-center{href: notifications_path}
%i.fa.fa-fw.fa-chevron-right
Show all new notifications