Only enable notification ack button if there are any unread ones

This commit is contained in:
Johannes Zellner
2021-06-21 14:04:25 +02:00
parent 90112de6e4
commit b27b4a38eb
2 changed files with 4 additions and 1 deletions
+1 -1
View File
@@ -3,7 +3,7 @@
<div class="text-left">
<h1>{{ 'notifications.title' | tr }}
<button class="btn btn-primary btn-outline pull-right" ng-click="clearAll()" ng-disabled="clearAllBusy"><i class="fa fa-circle-notch fa-spin" ng-show="clearAllBusy"></i><i class="fa fa-check" ng-hide="clearAllBusy"></i> {{ 'notifications.markAllAsRead' | tr }}</button>
<button class="btn btn-primary btn-outline pull-right" ng-click="clearAll()" ng-disabled="!hasUnread || clearAllBusy"><i class="fa fa-circle-notch fa-spin" ng-show="clearAllBusy"></i><i class="fa fa-check" ng-hide="clearAllBusy"></i> {{ 'notifications.markAllAsRead' | tr }}</button>
<button class="btn btn-default btn-outline pull-right" ng-click="showNextPage()" ng-disabled="busy || perPage > notifications.length">{{ 'main.pagination.next' | tr }} <i class="fa fa-angle-double-right"></i></button>
<button class="btn btn-default btn-outline pull-right" ng-click="showPrevPage()" ng-disabled="busy || currentPage <= 1"><i class="fa fa-angle-double-left"></i> {{ 'main.pagination.prev' | tr }}</button>
</h1>
+3
View File
@@ -9,6 +9,7 @@ angular.module('Application').controller('NotificationsController', ['$scope', '
$scope.notifications = [];
$scope.activeNotification = null;
$scope.busy = true;
$scope.hasUnread = false;
$scope.currentPage = 1;
$scope.perPage = 20;
@@ -27,6 +28,7 @@ angular.module('Application').controller('NotificationsController', ['$scope', '
});
$scope.notifications = result;
$scope.hasUnread = !!result.find(function (n) { return !n.acknowledged; });
$scope.busy = false;
});
@@ -76,6 +78,7 @@ angular.module('Application').controller('NotificationsController', ['$scope', '
}, function (error) {
if (error) console.error(error);
$scope.hasUnread = false;
$scope.clearAllBusy = false;
});
};