Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Display # of notif, grants and chats #7315

Merged
merged 6 commits into from
Sep 30, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 12 additions & 6 deletions app/assets/v2/css/notifications.css
Original file line number Diff line number Diff line change
Expand Up @@ -26,15 +26,21 @@ html.dark-mode {
}

.notification__dot {
background: rgba(var(--color-notification), 1);
background: red;
display: none;
width: 9px;
height: 9px;
border-radius: 50%;
min-width: 17px;
height: 17px;
border-radius: 8.5px;
box-shadow: 0 0 0 rgba(var(--color-notification), .4);
position: absolute;
top: 0.5em;
right: 0.9em;
top: 0;
left: 2.5em;
font-size: 10px;
text-align: center;
font-weight: bold;
padding: 2px;
font-family: 'Font Awesome\ 5 Pro', sans-serif;
line-height: initial;
}

.notification__dot_active {
Expand Down
1 change: 1 addition & 0 deletions app/assets/v2/js/base.js
Original file line number Diff line number Diff line change
Expand Up @@ -462,6 +462,7 @@ function applyCartMenuStyles() {

if (CartData.hasItems()) {
dot.addClass('notification__dot_active');
dot.text(CartData.length());
} else {
dot.removeClass('notification__dot_active');
if (document.location.href.indexOf('/grants') == -1) {
Expand Down
4 changes: 4 additions & 0 deletions app/assets/v2/js/cart-data.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@ class CartData {
return this.loadCart().length > 0;
}

static length() {
return this.loadCart().length;
}

static cartContainsGrantWithId(grantId) {
const cart = this.loadCart();
const idList = cart.map(grant => {
Expand Down
6 changes: 6 additions & 0 deletions app/assets/v2/js/notifications.js
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,11 @@ Vue.mixin({
$.when(putRead).then(function(response) {
sessionStorage.removeItem('notificationRead');
vm.checkUnread();
// eslint-disable-next-line block-scoped-var
if (app) {
// eslint-disable-next-line block-scoped-var
app.fetchNotifications();
}
});
}
vm.checkUnread();
Expand Down Expand Up @@ -134,6 +139,7 @@ if (document.getElementById('gc-notifications')) {
},
mounted() {
this.fetchNotifications();
setTimeout(this.fetchNotifications.bind(this), 30000);
},
created() {
this.sendState();
Expand Down
2 changes: 1 addition & 1 deletion app/dashboard/templates/shared/chat_nav.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<div id="sidebar-chat-app" class="nav-item dropdown notifications">
<a href="" class="notification__icon nav-link" v-b-toggle.sidebar-chat role="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
<i class="fas fa-comments fa-fw">
<span id="chat-notification-dot" class="notification__dot" :class="{'notification__dot_active': unreadCount > 0}"></span>
<span id="chat-notification-dot" class="notification__dot" :class="{'notification__dot_active': unreadCount > 0}">[[unreadCount ? unreadCount : '']]</span>
</i>
</a>
<b-sidebar id="sidebar-chat" @shown="showHandler($event)" @change="changeHandler($event)" @hidden="hideHandler($event)" class="chat-sidebar justify-content-center" backdrop lazy v-cloak title="close to go back" :no-header-close="!isMobile" :no-header="!isMobile" :width="`${isMobile ? '100vw' : '50vw'}`">
Expand Down
2 changes: 1 addition & 1 deletion app/dashboard/templates/shared/notifications.html
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
<a href="" class="notification__icon nav-link dropdown-toggle" id="notificationsDropdown" role="button"
data-toggle="dropdown" aria-haspopup="true" aria-expanded="false" @click="fetchNotifications(1)">
<i class="fas fa-bell fa-fw"></i>
<span id="notification-dot" class="notification__dot" :class="{'notification__dot_active': unreadNotifications.length > 0}"></span>
<span id="notification-dot" class="notification__dot" :class="{'notification__dot_active': unreadNotifications.length > 0}">[[unreadNotifications.length ? unreadNotifications.length : '']]</span>
</a>
<div class="dropdown-menu dropdown-menu-right animation slideDownIn notifications__box" aria-labelledby="notificationsDropdown">
<div class="notifications__header">
Expand Down