Commit 4bcf671a by Sam Padgett Committed by GitHub

Merge pull request #180 from benjaminapetersen/bpeterse/notification.unique.id

Update notification id to unique id specifically for  in templates
parents 7eda56a4 ce88403e
...@@ -408,7 +408,7 @@ hawtioPluginLoader.addModule('openshiftCommonUI'); ...@@ -408,7 +408,7 @@ hawtioPluginLoader.addModule('openshiftCommonUI');
$templateCache.put('src/components/toast-notifications/toast-notifications.html', $templateCache.put('src/components/toast-notifications/toast-notifications.html',
"<div class=\"toast-notifications-list-pf\">\n" + "<div class=\"toast-notifications-list-pf\">\n" +
" <div ng-repeat=\"(notificationID, notification) in notifications track by (notificationID + (notification.message || notification.details))\" ng-if=\"!notification.hidden || notification.isHover\"\n" + " <div ng-repeat=\"(notificationID, notification) in notifications track by notification.trackByID\" ng-if=\"!notification.hidden || notification.isHover\"\n" +
" ng-mouseenter=\"setHover(notification, true)\" ng-mouseleave=\"setHover(notification, false)\">\n" + " ng-mouseenter=\"setHover(notification, true)\" ng-mouseleave=\"setHover(notification, false)\">\n" +
" <div class=\"toast-pf alert {{notification.type | alertStatus}}\" ng-class=\"{'alert-dismissable': !hideCloseButton}\">\n" + " <div class=\"toast-pf alert {{notification.type | alertStatus}}\" ng-class=\"{'alert-dismissable': !hideCloseButton}\">\n" +
" <button ng-if=\"!hideCloseButton\" type=\"button\" class=\"close\" ng-click=\"close(notification)\">\n" + " <button ng-if=\"!hideCloseButton\" type=\"button\" class=\"close\" ng-click=\"close(notification)\">\n" +
...@@ -2149,7 +2149,9 @@ angular.module('openshiftCommonUI').provider('NotificationsService', function() ...@@ -2149,7 +2149,9 @@ angular.module('openshiftCommonUI').provider('NotificationsService', function()
}; };
var addNotification = function (notification) { var addNotification = function (notification) {
notification.id = notification.id || _.uniqueId('notification-') + Date.now(); // notifications may already have an id that is not necessarily unique,
// this is an explicitly unique id just for `track by` in templates
notification.trackByID = _.uniqueId('notification-') + Date.now();
notification.timestamp = new Date().toISOString(); notification.timestamp = new Date().toISOString();
if (isNotificationPermanentlyHidden(notification) || isNotificationVisible(notification)) { if (isNotificationPermanentlyHidden(notification) || isNotificationVisible(notification)) {
return; return;
......
...@@ -579,7 +579,7 @@ hawtioPluginLoader.addModule('openshiftCommonUI'); ...@@ -579,7 +579,7 @@ hawtioPluginLoader.addModule('openshiftCommonUI');
$templateCache.put('src/components/toast-notifications/toast-notifications.html', $templateCache.put('src/components/toast-notifications/toast-notifications.html',
"<div class=\"toast-notifications-list-pf\">\n" + "<div class=\"toast-notifications-list-pf\">\n" +
" <div ng-repeat=\"(notificationID, notification) in notifications track by (notificationID + (notification.message || notification.details))\" ng-if=\"!notification.hidden || notification.isHover\"\n" + " <div ng-repeat=\"(notificationID, notification) in notifications track by notification.trackByID\" ng-if=\"!notification.hidden || notification.isHover\"\n" +
" ng-mouseenter=\"setHover(notification, true)\" ng-mouseleave=\"setHover(notification, false)\">\n" + " ng-mouseenter=\"setHover(notification, true)\" ng-mouseleave=\"setHover(notification, false)\">\n" +
" <div class=\"toast-pf alert {{notification.type | alertStatus}}\" ng-class=\"{'alert-dismissable': !hideCloseButton}\">\n" + " <div class=\"toast-pf alert {{notification.type | alertStatus}}\" ng-class=\"{'alert-dismissable': !hideCloseButton}\">\n" +
" <button ng-if=\"!hideCloseButton\" type=\"button\" class=\"close\" ng-click=\"close(notification)\">\n" + " <button ng-if=\"!hideCloseButton\" type=\"button\" class=\"close\" ng-click=\"close(notification)\">\n" +
...@@ -5759,7 +5759,9 @@ angular.module('openshiftCommonUI').provider('NotificationsService', function() ...@@ -5759,7 +5759,9 @@ angular.module('openshiftCommonUI').provider('NotificationsService', function()
}; };
var addNotification = function (notification) { var addNotification = function (notification) {
notification.id = notification.id || _.uniqueId('notification-') + Date.now(); // notifications may already have an id that is not necessarily unique,
// this is an explicitly unique id just for `track by` in templates
notification.trackByID = _.uniqueId('notification-') + Date.now();
notification.timestamp = new Date().toISOString(); notification.timestamp = new Date().toISOString();
if (isNotificationPermanentlyHidden(notification) || isNotificationVisible(notification)) { if (isNotificationPermanentlyHidden(notification) || isNotificationVisible(notification)) {
return; return;
......
...@@ -379,7 +379,7 @@ angular.module('openshiftCommonUI').run(['$templateCache', function($templateCac ...@@ -379,7 +379,7 @@ angular.module('openshiftCommonUI').run(['$templateCache', function($templateCac
$templateCache.put('src/components/toast-notifications/toast-notifications.html', $templateCache.put('src/components/toast-notifications/toast-notifications.html',
"<div class=\"toast-notifications-list-pf\">\n" + "<div class=\"toast-notifications-list-pf\">\n" +
" <div ng-repeat=\"(notificationID, notification) in notifications track by (notificationID + (notification.message || notification.details))\" ng-if=\"!notification.hidden || notification.isHover\"\n" + " <div ng-repeat=\"(notificationID, notification) in notifications track by notification.trackByID\" ng-if=\"!notification.hidden || notification.isHover\"\n" +
" ng-mouseenter=\"setHover(notification, true)\" ng-mouseleave=\"setHover(notification, false)\">\n" + " ng-mouseenter=\"setHover(notification, true)\" ng-mouseleave=\"setHover(notification, false)\">\n" +
" <div class=\"toast-pf alert {{notification.type | alertStatus}}\" ng-class=\"{'alert-dismissable': !hideCloseButton}\">\n" + " <div class=\"toast-pf alert {{notification.type | alertStatus}}\" ng-class=\"{'alert-dismissable': !hideCloseButton}\">\n" +
" <button ng-if=\"!hideCloseButton\" type=\"button\" class=\"close\" ng-click=\"close(notification)\">\n" + " <button ng-if=\"!hideCloseButton\" type=\"button\" class=\"close\" ng-click=\"close(notification)\">\n" +
......
<div class="toast-notifications-list-pf"> <div class="toast-notifications-list-pf">
<div ng-repeat="(notificationID, notification) in notifications track by (notificationID + (notification.message || notification.details))" ng-if="!notification.hidden || notification.isHover" <div ng-repeat="(notificationID, notification) in notifications track by notification.trackByID" ng-if="!notification.hidden || notification.isHover"
ng-mouseenter="setHover(notification, true)" ng-mouseleave="setHover(notification, false)"> ng-mouseenter="setHover(notification, true)" ng-mouseleave="setHover(notification, false)">
<div class="toast-pf alert {{notification.type | alertStatus}}" ng-class="{'alert-dismissable': !hideCloseButton}"> <div class="toast-pf alert {{notification.type | alertStatus}}" ng-class="{'alert-dismissable': !hideCloseButton}">
<button ng-if="!hideCloseButton" type="button" class="close" ng-click="close(notification)"> <button ng-if="!hideCloseButton" type="button" class="close" ng-click="close(notification)">
......
...@@ -18,7 +18,9 @@ angular.module('openshiftCommonUI').provider('NotificationsService', function() ...@@ -18,7 +18,9 @@ angular.module('openshiftCommonUI').provider('NotificationsService', function()
}; };
var addNotification = function (notification) { var addNotification = function (notification) {
notification.id = notification.id || _.uniqueId('notification-') + Date.now(); // notifications may already have an id that is not necessarily unique,
// this is an explicitly unique id just for `track by` in templates
notification.trackByID = _.uniqueId('notification-') + Date.now();
notification.timestamp = new Date().toISOString(); notification.timestamp = new Date().toISOString();
if (isNotificationPermanentlyHidden(notification) || isNotificationVisible(notification)) { if (isNotificationPermanentlyHidden(notification) || isNotificationVisible(notification)) {
return; return;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment