From 9cb1366d36c2f991dd4e38dcc78a084cc5d9e625 Mon Sep 17 00:00:00 2001 From: Joseph Schorr Date: Tue, 22 Dec 2015 07:38:57 -0500 Subject: [PATCH] Fix UI for dismissing notifications Fixes #959 --- static/directives/notification-view.html | 3 ++- static/js/directives/ui/notification-view.js | 3 +++ static/js/services/notification-service.js | 12 ++++++------ 3 files changed, 11 insertions(+), 7 deletions(-) diff --git a/static/directives/notification-view.html b/static/directives/notification-view.html index fd346609d..fe1716c3f 100644 --- a/static/directives/notification-view.html +++ b/static/directives/notification-view.html @@ -8,9 +8,10 @@
- + Dismiss Notification + diff --git a/static/js/directives/ui/notification-view.js b/static/js/directives/ui/notification-view.js index cc3a89d06..7e5e0e569 100644 --- a/static/js/directives/ui/notification-view.js +++ b/static/js/directives/ui/notification-view.js @@ -13,6 +13,8 @@ angular.module('quay').directive('notificationView', function () { 'parent': '=parent' }, controller: function($scope, $element, $window, $location, UserService, NotificationService, ApiService) { + $scope.dismissing = false; + var stringStartsWith = function (str, prefix) { return str.slice(0, prefix.length) == prefix; }; @@ -51,6 +53,7 @@ angular.module('quay').directive('notificationView', function () { }; $scope.dismissNotification = function(notification) { + $scope.dismissing = true; NotificationService.dismissNotification(notification); }; diff --git a/static/js/services/notification-service.js b/static/js/services/notification-service.js index 31ff5af2c..17f0262d5 100644 --- a/static/js/services/notification-service.js +++ b/static/js/services/notification-service.js @@ -140,14 +140,14 @@ function($rootScope, $interval, UserService, ApiService, StringBuilderService, P 'uuid': notification.id }; - ApiService.updateUserNotification(notification, params, function() { + ApiService.updateUserNotification(notification, params).then(function(resp) { + var index = $.inArray(notification, notificationService.notifications); + if (index >= 0) { + notificationService.notifications.splice(index, 1); + } + notificationService.update(); }, ApiService.errorDisplay('Could not update notification')); - - var index = $.inArray(notification, notificationService.notifications); - if (index >= 0) { - notificationService.notifications.splice(index, 1); - } }; notificationService.getActions = function(notification) {