diff --git a/platform/commonUI/dialog/res/templates/overlay-message-list.html b/platform/commonUI/dialog/res/templates/overlay-message-list.html
index 026ef1cbb1..5a7a48192f 100644
--- a/platform/commonUI/dialog/res/templates/overlay-message-list.html
+++ b/platform/commonUI/dialog/res/templates/overlay-message-list.html
@@ -6,7 +6,9 @@
-
+
severity[previous]){
+ return notification.model.severity;
+ } else {
+ return previous;
+ }
+ }, "info");
+ };
+
/**
* Notifies the user of an event. If there is a banner notification
* already active, then it will be dismissed or minimized automatically,
@@ -274,23 +305,23 @@ define(
NotificationService.prototype.notify = function (notificationModel) {
var self = this,
notification,
- ordinality = {
- "info": 1,
- "alert": 2,
- "error": 3
- },
- activeNotification = self.active.notification;
+ activeNotification = self.active.notification,
+ topic = this.topic();
notification = {
model: notificationModel,
minimize: function() {
- minimize(self, notification);
+ self.minimize(self, notification);
},
dismiss: function(){
- dismiss(self, notification);
+ self.dismiss(self, notification);
+ topic.notify();
},
dismissOrMinimize: function(){
- dismissOrMinimize(notification);
+ self.dismissOrMinimize(notification);
+ },
+ onDismiss: function(callback) {
+ topic.listen(callback);
}
};
@@ -299,12 +330,25 @@ define(
notificationModel.autoDismiss = this.DEFAULT_AUTO_DISMISS;
}
- if (ordinality[notificationModel.severity.toLowerCase()] > ordinality[this.highest.severity.toLowerCase()]){
- this.highest.severity = notificationModel.severity;
+ //Notifications support a 'dismissable' attribute. This is a
+ // convenience to support adding a 'dismiss' option to the
+ // notification for the common case of dismissing a
+ // notification. Could also be done manually by specifying an
+ // option on the model
+ if (notificationModel.dismissable !== false) {
+ notificationModel.options = notificationModel.options || [];
+ notificationModel.options.unshift({
+ label: "Dismiss",
+ callback: function() {
+ notification.dismiss();
+ }
+ });
}
this.notifications.push(notification);
+ this.setHighestSeverity();
+
/*
Check if there is already an active (ie. visible) notification
*/
diff --git a/platform/commonUI/notification/test/NotificationServiceSpec.js b/platform/commonUI/notification/test/NotificationServiceSpec.js
index ded62a7f48..25d9077f45 100644
--- a/platform/commonUI/notification/test/NotificationServiceSpec.js
+++ b/platform/commonUI/notification/test/NotificationServiceSpec.js
@@ -32,13 +32,19 @@ define(
mockAutoDismiss,
mockMinimizeTimeout,
successModel,
+ mockTopicFunction,
+ mockTopicObject,
errorModel;
beforeEach(function(){
mockTimeout = jasmine.createSpy("$timeout");
+ mockTopicFunction = jasmine.createSpy("topic");
+ mockTopicObject = jasmine.createSpyObj("topicObject", ["listen", "notify"]);
+ mockTopicFunction.andReturn(mockTopicObject);
+
mockAutoDismiss = mockMinimizeTimeout = 1000;
notificationService = new NotificationService(
- mockTimeout, mockAutoDismiss, mockMinimizeTimeout);
+ mockTimeout, mockTopicFunction, mockAutoDismiss, mockMinimizeTimeout);
successModel = {
title: "Mock Success Notification",
severity: "info"
@@ -57,6 +63,19 @@ define(
expect(activeNotification.model).toBe(successModel);
});
+ it("notifies listeners on dismissal of notification", function() {
+ var notification,
+ dismissListener = jasmine.createSpy("ondismiss");
+ notification = notificationService.notify(successModel);
+ notification.onDismiss(dismissListener);
+ expect(mockTopicObject.listen).toHaveBeenCalled();
+ notification.dismiss();
+ expect(mockTopicObject.notify).toHaveBeenCalled();
+ mockTopicObject.listen.mostRecentCall.args[0]();
+ expect(dismissListener).toHaveBeenCalled();
+
+ });
+
it("allows specification of an info notification given just a" +
" title, making the notification active", function() {
var activeNotification,
diff --git a/platform/core/src/capabilities/PersistenceCapability.js b/platform/core/src/capabilities/PersistenceCapability.js
index 637be193c2..dd2378feb9 100644
--- a/platform/core/src/capabilities/PersistenceCapability.js
+++ b/platform/core/src/capabilities/PersistenceCapability.js
@@ -104,14 +104,16 @@ define(
* persistence.
*/
function notifyOnError(error, domainObject, notificationService, $q){
- var errorMessage = "Unable to persist " + domainObject.getModel().name;
+ var errorMessage = "Unable to persist " + domainObject.getModel().name,
+ notification;
if (error) {
errorMessage += ": " + formatError(error);
}
- notificationService.error({
+ notification = notificationService.error({
title: "Error persisting " + domainObject.getModel().name,
- hint: errorMessage || "Unknown error"
+ hint: errorMessage || "Unknown error",
+ dismissable: true
});
return $q.reject(error);