add notification counter to indicator

This commit is contained in:
Matthias 2021-11-30 16:56:55 +01:00
parent 5614fde368
commit 791da9b322
No known key found for this signature in database
GPG Key ID: F50EF5741D33E076
2 changed files with 12 additions and 6 deletions

View File

@ -134,17 +134,22 @@ function showMessage(message, options={}) {
}, },
{ {
success: function(response) { success: function(response) {
if (response.length == 0) { updateNotificationIndicator(response.length);
$("#notification-alert").addClass("d-none");
} else {
$("#notification-alert").removeClass("d-none");
}
} }
} }
); );
} }
} }
function updateNotificationIndicator(counter) {
if (counter == 0) {
$("#notification-alert").addClass("d-none");
} else {
$("#notification-alert").removeClass("d-none");
}
$("#notification-counter").html(counter);
}
/** /**
* Returns the html for a read / unread button * Returns the html for a read / unread button

View File

@ -75,8 +75,9 @@
<li class='nav-item me-2'> <li class='nav-item me-2'>
<button data-bs-toggle="offcanvas" data-bs-target="#offcanvasRight" class='btn position-relative' title='{% trans "Show Notifications" %}'> <button data-bs-toggle="offcanvas" data-bs-target="#offcanvasRight" class='btn position-relative' title='{% trans "Show Notifications" %}'>
<span class='fas fa-bell'></span> <span class='fas fa-bell'></span>
<span class="position-absolute top-100 start-100 translate-middle p-2 bg-danger border border-light rounded-circle d-none" id="notification-alert"> <span class="position-absolute top-100 start-100 translate-middle badge rounded-pill bg-danger d-none" id="notification-alert">
<span class="visually-hidden">{% trans "New Notifications" %}</span> <span class="visually-hidden">{% trans "New Notifications" %}</span>
<span id="notification-counter">0</span>
</span> </span>
</button> </button>
</li> </li>