Merge pull request #5314 from aignatov-bio/ai-sci-8331-small-fixes-for-notifications

Small fixes for notifications [SCI-8331]
This commit is contained in:
aignatov-bio 2023-04-17 15:35:29 +02:00 committed by GitHub
commit 20f9b41b78
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
7 changed files with 33 additions and 13 deletions

View file

@ -24,11 +24,6 @@ function bindSystemNotificationAjax() {
$('.dropdown.system-notifications').removeClass('open'); $('.dropdown.system-notifications').removeClass('open');
// Open modal // Open modal
SystemNotificationModal.modal('show'); SystemNotificationModal.modal('show');
if (SystemNotification[0].dataset.unread === '1') {
$.each(SystemNotification, (index, e) => { e.dataset.unread = '0'; });
SystemNotification.find('.status-icon').addClass('seen');
$.post('/system_notifications/' + data.id + '/mark_as_read');
}
}); });
} }

View file

@ -9,7 +9,7 @@
left: 0; left: 0;
position: fixed; position: fixed;
right: 0; right: 0;
top: var(--top-navigation); top: 0;
} }
.has-unseen { .has-unseen {
@ -131,8 +131,17 @@
} }
.sci-navigation--notificaitons-flyout-notification-title { .sci-navigation--notificaitons-flyout-notification-title {
font-weight: bold;
margin: .25rem 0; margin: .25rem 0;
&:not([data-seen="true"]) {
font-weight: bold;
}
}
.sci-navigation--notificaitons-flyout-notification-message {
&[data-notification="system"] {
cursor: pointer;
}
} }
} }
} }

View file

@ -2,6 +2,7 @@
class SystemNotificationsController < ApplicationController class SystemNotificationsController < ApplicationController
def show def show
current_user.user_system_notifications.mark_as_read(params[:id])
render json: current_user.system_notifications.modals render json: current_user.system_notifications.modals
.find_by_id(params[:id]) || {} .find_by_id(params[:id]) || {}
end end

View file

@ -66,7 +66,8 @@ class UserNotificationsController < ApplicationController
message: notification.message, message: notification.message,
created_at: I18n.l(notification.created_at, format: :full), created_at: I18n.l(notification.created_at, format: :full),
today: notification.created_at.today?, today: notification.created_at.today?,
checked: notification.checked checked: notification.checked,
action_url: (system_notification_path(notification.id) if notification.type_of == 'system_message')
} }
end end
end end

View file

@ -6,11 +6,11 @@
<div class="sci-navigation--notificaitons-flyout-notification-date"> <div class="sci-navigation--notificaitons-flyout-notification-date">
{{ notification.created_at }} {{ notification.created_at }}
</div> </div>
<div class="sci-navigation--notificaitons-flyout-notification-title"> <div class="sci-navigation--notificaitons-flyout-notification-title"
{{ notification.title }} v-html="notification.title"
</div> :data-seen="notification.checked"></div>
<div v-if="notification.type_of !== 'system'" v-html="notification.message" class="sci-navigation--notificaitons-flyout-notification-message"></div> <div v-if="notification.type_of !== 'system_message'" v-html="notification.message" class="sci-navigation--notificaitons-flyout-notification-message"></div>
<a v-else :href="notification.url" class="sci-navigation--notificaitons-flyout-notification-message">{{ i18n.t('nav.notifications.read_more') }}</a> <a v-else @click="showSystemNotification()" class="sci-navigation--notificaitons-flyout-notification-message" data-notification="system">{{ i18n.t('nav.notifications.read_more') }}</a>
</div> </div>
</template> </template>
@ -33,6 +33,18 @@ export default {
return 'fa-list-alt'; return 'fa-list-alt';
} }
} }
},
methods: {
showSystemNotification() {
$.get(this.notification.action_url, (data) => {
let systemNotificationModal = $('#manage-module-system-notification-modal');
let systemNotificationModalBody = systemNotificationModal.find('.modal-body');
let systemNotificationModalTitle = systemNotificationModal.find('#manage-module-system-notification-modal-label');
systemNotificationModalBody.html(data.modal_body);
systemNotificationModalTitle.text(data.modal_title);
systemNotificationModal.modal('show');
});
}
} }
} }
</script> </script>

View file

@ -96,6 +96,7 @@ export default {
this.notifications = this.notifications.concat(result.notifications); this.notifications = this.notifications.concat(result.notifications);
this.nextPage = result.next_page; this.nextPage = result.next_page;
this.loadingPage = false; this.loadingPage = false;
this.$emit('update:unseenNotificationsCount');
}); });
} }
} }

View file

@ -61,6 +61,7 @@
v-if="notificationsOpened" v-if="notificationsOpened"
:notificationsUrl="notificationsUrl" :notificationsUrl="notificationsUrl"
:unseenNotificationsCount="unseenNotificationsCount" :unseenNotificationsCount="unseenNotificationsCount"
@update:unseenNotificationsCount="checkUnseenNotifications()"
@close="notificationsOpened = false" /> @close="notificationsOpened = false" />
</div> </div>
<div v-if="user" class="dropdown"> <div v-if="user" class="dropdown">