diff --git a/app/assets/stylesheets/navigation/notifications.scss b/app/assets/stylesheets/navigation/notifications.scss index 66df0372f..2a410bc8d 100644 --- a/app/assets/stylesheets/navigation/notifications.scss +++ b/app/assets/stylesheets/navigation/notifications.scss @@ -12,6 +12,24 @@ top: var(--top-navigation); } + .has-unseen { + &::after { + align-items: center; + background-color: $brand-focus; + border-radius: .5rem; + color: $color-white; + content: attr(data-unseen); + display: flex; + font-size: 10px; + height: 1rem; + justify-content: center; + position: absolute; + right: 0; + top: 0; + width: 1rem; + } + } + .sci--navigation--notificaitons-flyout { background-color: $color-white; border-radius: 0 0 $border-radius-default $border-radius-default; @@ -48,6 +66,8 @@ .sci--navigation--notificaitons-flyout-tab { cursor: pointer; + padding: .5rem .625rem; + position: relative; &.active { color: $brand-focus; diff --git a/app/controllers/user_notifications_controller.rb b/app/controllers/user_notifications_controller.rb index 37e459268..ff045ca95 100644 --- a/app/controllers/user_notifications_controller.rb +++ b/app/controllers/user_notifications_controller.rb @@ -13,7 +13,20 @@ class UserNotificationsController < ApplicationController } end end - UserNotification.seen_by_user(current_user) + + UserNotification.where( + notification_id: notifications.where.not(type_of: 2).select(:id) + ).seen_by_user(current_user) + + current_user.user_system_notifications.where( + system_notification_id: notifications.where(type_of: 2).select(:id) + ).mark_as_seen + end + + def unseen_counter + render json: { + unseen: load_notifications.where(checked: false).size + } end private diff --git a/app/javascript/vue/navigation/notifications/notification_item.vue b/app/javascript/vue/navigation/notifications/notification_item.vue index 4f6ebe879..0baa93c5a 100644 --- a/app/javascript/vue/navigation/notifications/notification_item.vue +++ b/app/javascript/vue/navigation/notifications/notification_item.vue @@ -25,7 +25,7 @@ export default { switch(this.notification.type_of) { case 'deliver': return 'fa-truck'; - case 'system': + case 'system_message': return 'fa-gift'; case 'assignment': return 'fa-list-alt'; diff --git a/app/javascript/vue/navigation/notifications/notifications_flyout.vue b/app/javascript/vue/navigation/notifications/notifications_flyout.vue index 7d9834735..0b8c22c83 100644 --- a/app/javascript/vue/navigation/notifications/notifications_flyout.vue +++ b/app/javascript/vue/navigation/notifications/notifications_flyout.vue @@ -6,8 +6,9 @@
+ :class="{'active': activeTab == 'all', 'has-unseen': unseenNotificationsCount > 0}"> {{ i18n.t('nav.notifications.all') }}
-
- +