Skip to content

Commit

Permalink
Fix notifications
Browse files Browse the repository at this point in the history
  • Loading branch information
tagliala committed Aug 4, 2021
1 parent f075556 commit af58c91
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 12 deletions.
13 changes: 6 additions & 7 deletions app/javascript/src/navbar.js
Expand Up @@ -16,15 +16,12 @@ $(document).on('shown.bs.popover', '.notifications', function (e) {
if ($target.data('remote')) {
return $.ajax({
url: $target.data('remote'),
beforeSend () {
return $('.popover-body').html($('.popover-body-loading').html())
},
success (messages) {
$target.data('unread', messages.length).find('span.unread-count').text(messages.length > 0 ? messages.length : '')
if (messages.length > 0) {
return $('.popover-body').html(HandlebarsTemplates['notifications/messages']({ messages }))
$popover.find('.popover-body').html(HandlebarsTemplates['notifications/messages']({ messages }))
} else {
return $popover.find('.popover-body').text(I18n.t(`javascript.notifications.${$target.data('notificationsType')}.no_new`))
$popover.find('.popover-body').text(I18n.t(`javascript.notifications.${$target.data('notificationsType')}.no_new`))
}
}
})
Expand All @@ -42,15 +39,17 @@ $(document).on(window.initializeOnEvent, () => $('.notifications').each(function
no_notifications_text: I18n.t(`javascript.notifications.${notificationsType}.no_new`),
footer_link_text: I18n.t(`javascript.notifications.${notificationsType}.see_all`)
}
const popoverTemplate = HandlebarsTemplates['notifications/base'](popoverData)

return $target.on('click', function (e) {
$target.on('click', function (e) {
e.preventDefault()
return false
}).popover({
placement: 'bottom',
html: true,
container: $(this),
template: HandlebarsTemplates['notifications/base'](popoverData),
content: $(popoverTemplate).find('.popover-body-loading').html(),
template: popoverTemplate,
title: I18n.t(`javascript.notifications.${notificationsType}.title`)
})
}))
2 changes: 1 addition & 1 deletion app/javascript/src/templates/notifications/base.handlebars
@@ -1,7 +1,7 @@
<div class="popover popover--notifications" role="tooltip">
<div class="popover-arrow"></div>
<h3 class="popover-header"></h3>
<div class="popover-body-loading">
<div class="popover-body-loading d-none">
<div class="d-flex justify-content-center m-2">
<div class="spinner-border text-primary" role="status">
<span class="sr-only">{{ translate "templates.loading" }}</span>
Expand Down
4 changes: 0 additions & 4 deletions app/javascript/stylesheets/notifications.scss
Expand Up @@ -60,10 +60,6 @@ $background: lighten($success, 5%) !default;
}
}

.popover-body-loading {
display: none;
}

.popover-footer {
padding: 8px 14px;
line-height: 18px;
Expand Down

0 comments on commit af58c91

Please sign in to comment.