Removed MessageSeverity enum and MessageController
This commit is contained in:
@@ -1,8 +1,5 @@
|
||||
<span ng-show="notifications.length > 0" class="status block"
|
||||
ng-class="{
|
||||
'info': highest.severity===MessageSeverity.INFO,
|
||||
'error': highest.severity===MessageSeverity.ERROR,
|
||||
'alert': highest.severity===MessageSeverity.ALERT }"
|
||||
ng-class="highest.severity"
|
||||
ng-controller="NotificationIndicatorController">
|
||||
<span class="ui-symbol status-indicator"></span>
|
||||
<span class="label">
|
||||
|
||||
@@ -1,11 +0,0 @@
|
||||
/**
|
||||
* Created by akhenry on 10/7/15.
|
||||
*/
|
||||
/*global define*/
|
||||
define(function(){
|
||||
return {
|
||||
INFO: 0,
|
||||
ALERT: 1,
|
||||
ERROR: 2
|
||||
};
|
||||
});
|
||||
@@ -22,8 +22,8 @@
|
||||
/*global define*/
|
||||
|
||||
define(
|
||||
['./MessageSeverity'],
|
||||
function (MessageSeverity) {
|
||||
[],
|
||||
function () {
|
||||
"use strict";
|
||||
|
||||
/**
|
||||
@@ -40,7 +40,6 @@ define(
|
||||
function NotificationIndicatorController($scope, notificationService, dialogService) {
|
||||
$scope.notifications = notificationService.notifications;
|
||||
$scope.highest = notificationService.highest;
|
||||
$scope.MessageSeverity = MessageSeverity;
|
||||
|
||||
/**
|
||||
* Launch a dialog showing a list of current notifications.
|
||||
@@ -48,8 +47,7 @@ define(
|
||||
$scope.showNotificationsList = function(){
|
||||
|
||||
var model = {
|
||||
title: "Messages",
|
||||
severity: MessageSeverity.INFO
|
||||
title: "Messages"
|
||||
};
|
||||
|
||||
model.messages = notificationService.notifications;
|
||||
|
||||
@@ -32,8 +32,8 @@
|
||||
* @namespace platform/commonUI/dialog
|
||||
*/
|
||||
define(
|
||||
["./MessageSeverity"],
|
||||
function (MessageSeverity) {
|
||||
[],
|
||||
function () {
|
||||
"use strict";
|
||||
|
||||
/**
|
||||
@@ -56,8 +56,9 @@ define(
|
||||
*
|
||||
* @typedef {object} Notification
|
||||
* @property {string} title The title of the message
|
||||
* @property {MessageSeverity} severity The importance of the
|
||||
* message (eg. error, info)
|
||||
* @property {string} severity The importance of the
|
||||
* message (one of 'info', 'alert', or 'error' where info < alert <
|
||||
* error)
|
||||
* @property {number} progress The completion status of a task
|
||||
* represented numerically
|
||||
* @property {boolean} unknownProgress a boolean indicating that the
|
||||
@@ -91,7 +92,7 @@ define(
|
||||
function NotificationService($timeout, DEFAULT_AUTO_DISMISS, MINIMIZE_TIMEOUT) {
|
||||
this.notifications = [];
|
||||
this.$timeout = $timeout;
|
||||
this.highest ={ severity: MessageSeverity.INFO };
|
||||
this.highest ={ severity: "info" };
|
||||
this.DEFAULT_AUTO_DISMISS = DEFAULT_AUTO_DISMISS;
|
||||
this.MINIMIZE_TIMEOUT = MINIMIZE_TIMEOUT;
|
||||
|
||||
@@ -118,7 +119,7 @@ define(
|
||||
*/
|
||||
NotificationService.prototype.info = function (notification) {
|
||||
notification.autoDismiss = notification.autoDismiss || true;
|
||||
notification.severity = MessageSeverity.INFO;
|
||||
notification.severity = "info";
|
||||
this.notify(notification);
|
||||
};
|
||||
|
||||
@@ -130,13 +131,18 @@ define(
|
||||
* @param {Notification} notification The notification to display
|
||||
*/
|
||||
NotificationService.prototype.notify = function (notification) {
|
||||
var self = this;
|
||||
|
||||
var self = this,
|
||||
ordinality = {
|
||||
"info": 1,
|
||||
"alert": 2,
|
||||
"error": 3
|
||||
};
|
||||
notification.severity = notification.severity || "info"
|
||||
if (notification.autoDismiss === true){
|
||||
notification.autoDismiss = this.DEFAULT_AUTO_DISMISS;
|
||||
}
|
||||
|
||||
if (notification.severity > this.highest.severity){
|
||||
if (ordinality[notification.severity.toLowerCase()] > ordinality[this.highest.severity.toLowerCase()]){
|
||||
this.highest.severity = notification.severity;
|
||||
}
|
||||
|
||||
@@ -271,11 +277,6 @@ define(
|
||||
//For now minimize everything, and have discussion around which
|
||||
//kind of messages should or should not be in the minimized
|
||||
//notifications list
|
||||
/*if (notification.severity > MessageSeverity.INFO){
|
||||
this.minimize(notification);
|
||||
} else {
|
||||
this.dismiss(notification);
|
||||
}*/
|
||||
this.minimize(notification);
|
||||
};
|
||||
|
||||
|
||||
@@ -22,8 +22,8 @@
|
||||
/*global define,describe,it,expect,beforeEach,waitsFor,jasmine */
|
||||
|
||||
define(
|
||||
['../src/NotificationService','../src/MessageSeverity'],
|
||||
function (NotificationService, MessageSeverity) {
|
||||
['../src/NotificationService'],
|
||||
function (NotificationService) {
|
||||
"use strict";
|
||||
|
||||
describe("The notification service ", function () {
|
||||
@@ -34,46 +34,6 @@ define(
|
||||
successModel,
|
||||
errorModel;
|
||||
|
||||
/**
|
||||
* 1) Calling .notify results in a new notification being created
|
||||
* with the provided model and set to the active notification. DONE
|
||||
*
|
||||
* 2) Calling .notify with autoDismiss results in a SUCCESS notification
|
||||
* becoming dismissed after timeout has elapsed DONE
|
||||
*
|
||||
* 3) Calling .notify with autoDismiss results in an ERROR notification
|
||||
* being MINIMIZED after a timeout has elapsed DONE
|
||||
*
|
||||
* 4) Calling .notify with an active info notification results in that
|
||||
* notification being auto-dismissed, and the new notification becoming
|
||||
* active. DONE
|
||||
*
|
||||
* 5) Calling .notify with an active error notification results in that
|
||||
* notification being auto-minimized and the new notification becoming
|
||||
* active. DONE
|
||||
*
|
||||
* 6) Calling .notify with an active error notification, AND a
|
||||
* queued error notification results in the active notification
|
||||
* being auto-dismissed, the next message in the queue becoming
|
||||
* active, then auto-dismissed, and then the provided notification
|
||||
* becoming active.
|
||||
*/
|
||||
|
||||
/**
|
||||
var model = {
|
||||
title: string,
|
||||
progress: number,
|
||||
severity: MessageSeverity,
|
||||
unknownProgress: boolean,
|
||||
minimized: boolean,
|
||||
autoDismiss: boolean | number,
|
||||
actions: {
|
||||
label: string,
|
||||
action: function
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
||||
beforeEach(function(){
|
||||
mockTimeout = jasmine.createSpy("$timeout");
|
||||
mockAutoDismiss = mockMinimizeTimeout = 1000;
|
||||
@@ -81,11 +41,11 @@ define(
|
||||
mockTimeout, mockAutoDismiss, mockMinimizeTimeout);
|
||||
successModel = {
|
||||
title: "Mock Success Notification",
|
||||
severity: MessageSeverity.INFO
|
||||
severity: "info"
|
||||
};
|
||||
errorModel = {
|
||||
title: "Mock Error Notification",
|
||||
severity: MessageSeverity.ERROR
|
||||
severity: "error"
|
||||
};
|
||||
});
|
||||
|
||||
@@ -147,23 +107,6 @@ define(
|
||||
activeNotification = notificationService.getActiveNotification();
|
||||
expect(activeNotification).toBe(errorModel);
|
||||
});
|
||||
/* Test is temporarily invalid as info messages are being
|
||||
minimized
|
||||
it("auto-dismisses an active success notification, removing" +
|
||||
" it completely", function() {
|
||||
//First pre-load with a info message
|
||||
notificationService.notify(successModel);
|
||||
//Then notify of an error
|
||||
notificationService.notify(errorModel);
|
||||
expect(notificationService.notifications.length).toEqual(2);
|
||||
mockTimeout.mostRecentCall.args[0]();
|
||||
//Two timeouts, one is to force minimization after
|
||||
// displaying the message for a minimum period, the
|
||||
// second is to allow minimization animation to take place.
|
||||
mockTimeout.mostRecentCall.args[0]();
|
||||
//Previous info message should be completely dismissed
|
||||
expect(notificationService.notifications.length).toEqual(1);
|
||||
});*/
|
||||
it("auto-minimizes an active error notification", function() {
|
||||
var activeNotification;
|
||||
//First pre-load with an error message
|
||||
@@ -190,11 +133,11 @@ define(
|
||||
var activeNotification,
|
||||
error2 = {
|
||||
title: "Second Mock Error Notification",
|
||||
severity: MessageSeverity.ERROR
|
||||
severity: "error"
|
||||
},
|
||||
error3 = {
|
||||
title: "Third Mock Error Notification",
|
||||
severity: MessageSeverity.ERROR
|
||||
severity: "error"
|
||||
};
|
||||
|
||||
//First pre-load with a info message
|
||||
|
||||
Reference in New Issue
Block a user