@@ -61,7 +61,7 @@ define(
61
61
* @property {boolean } [unknownProgress] a boolean indicating that the
62
62
* progress of the underlying task is unknown. This will result in a
63
63
* visually distinct progress bar.
64
- * @property {boolean | number } [autoDismiss] If truthy, dialog will
64
+ * @property {boolean } [autoDismiss] If truthy, dialog will
65
65
* be automatically minimized or dismissed (depending on severity).
66
66
* Additionally, if the provided value is a number, it will be used
67
67
* as the delay period before being dismissed.
@@ -109,18 +109,18 @@ define(
109
109
* @memberof platform/commonUI/notification
110
110
* @constructor
111
111
* @param $timeout the Angular $timeout service
112
- * @param DEFAULT_AUTO_DISMISS The period of time that an
112
+ * @param defaultAutoDismissTimeout The period of time that an
113
113
* auto-dismissed message will be displayed for.
114
- * @param MINIMIZE_TIMEOUT When notifications are minimized, a brief
114
+ * @param minimizeAnimationTimeout When notifications are minimized, a brief
115
115
* animation is shown. This animation requires some time to execute,
116
116
* so a timeout is required before the notification is hidden
117
117
*/
118
- function NotificationService ( $timeout , topic , DEFAULT_AUTO_DISMISS , MINIMIZE_TIMEOUT ) {
118
+ function NotificationService ( $timeout , topic , defaultAutoDismissTimeout , minimizeAnimationTimeout ) {
119
119
this . notifications = [ ] ;
120
120
this . $timeout = $timeout ;
121
121
this . highest = { severity : "info" } ;
122
- this . DEFAULT_AUTO_DISMISS = DEFAULT_AUTO_DISMISS ;
123
- this . MINIMIZE_TIMEOUT = MINIMIZE_TIMEOUT ;
122
+ this . AUTO_DISMISS_TIMEOUT = defaultAutoDismissTimeout ;
123
+ this . MINIMIZE_ANIMATION_TIMEOUT = minimizeAnimationTimeout ;
124
124
this . topic = topic ;
125
125
126
126
/*
@@ -162,7 +162,7 @@ define(
162
162
// in order to allow the minimize animation to run through.
163
163
service . $timeout ( function ( ) {
164
164
service . setActiveNotification ( service . selectNextNotification ( ) ) ;
165
- } , service . MINIMIZE_TIMEOUT ) ;
165
+ } , service . MINIMIZE_ANIMATION_TIMEOUT ) ;
166
166
}
167
167
} ;
168
168
@@ -208,11 +208,16 @@ define(
208
208
* @private
209
209
*/
210
210
NotificationService . prototype . dismissOrMinimize = function ( notification ) {
211
-
212
- //For now minimize everything, and have discussion around which
213
- //kind of messages should or should not be in the minimized
214
- //notifications list
215
- notification . minimize ( ) ;
211
+ var model = notification . model ;
212
+ if ( model . severity === "info" ) {
213
+ if ( model . autoDismiss === false ) {
214
+ notification . minimize ( ) ;
215
+ } else {
216
+ notification . dismiss ( ) ;
217
+ }
218
+ } else {
219
+ notification . minimize ( ) ;
220
+ }
216
221
} ;
217
222
218
223
/**
@@ -226,7 +231,9 @@ define(
226
231
/**
227
232
* A convenience method for info notifications. Notifications
228
233
* created via this method will be auto-dismissed after a default
229
- * wait period
234
+ * wait period unless explicitly forbidden by the caller through
235
+ * the {autoDismiss} property on the {NotificationModel}, in which
236
+ * case the notification will be minimized after the wait.
230
237
* @param {NotificationModel | string } message either a string for
231
238
* the title of the notification message, or a {@link NotificationModel}
232
239
* defining the options notification to display
@@ -235,7 +242,6 @@ define(
235
242
*/
236
243
NotificationService . prototype . info = function ( message ) {
237
244
var notificationModel = typeof message === "string" ? { title : message } : message ;
238
- notificationModel . autoDismiss = notificationModel . autoDismiss || true ;
239
245
notificationModel . severity = "info" ;
240
246
return this . notify ( notificationModel ) ;
241
247
} ;
@@ -306,28 +312,29 @@ define(
306
312
activeNotification = self . active . notification ,
307
313
topic = this . topic ( ) ;
308
314
315
+ notificationModel . severity = notificationModel . severity || "info" ;
316
+
309
317
notification = {
310
318
model : notificationModel ,
319
+
311
320
minimize : function ( ) {
312
321
self . minimize ( self , notification ) ;
313
322
} ,
323
+
314
324
dismiss : function ( ) {
315
325
self . dismiss ( self , notification ) ;
316
326
topic . notify ( ) ;
317
327
} ,
328
+
318
329
dismissOrMinimize : function ( ) {
319
330
self . dismissOrMinimize ( notification ) ;
320
331
} ,
332
+
321
333
onDismiss : function ( callback ) {
322
334
topic . listen ( callback ) ;
323
335
}
324
336
} ;
325
337
326
- notificationModel . severity = notificationModel . severity || "info" ;
327
- if ( notificationModel . autoDismiss === true ) {
328
- notificationModel . autoDismiss = this . DEFAULT_AUTO_DISMISS ;
329
- }
330
-
331
338
//Notifications support a 'dismissable' attribute. This is a
332
339
// convenience to support adding a 'dismiss' option to the
333
340
// notification for the common case of dismissing a
@@ -366,38 +373,39 @@ define(
366
373
*/
367
374
this . active . timeout = this . $timeout ( function ( ) {
368
375
activeNotification . dismissOrMinimize ( ) ;
369
- } , this . DEFAULT_AUTO_DISMISS ) ;
376
+ } , this . AUTO_DISMISS_TIMEOUT ) ;
370
377
}
371
378
372
379
return notification ;
373
-
374
380
} ;
375
381
376
382
/**
377
383
* Used internally by the NotificationService
378
384
* @private
379
385
*/
380
- NotificationService . prototype . setActiveNotification =
381
- function ( notification ) {
382
- var timeout ;
386
+ NotificationService . prototype . setActiveNotification = function ( notification ) {
387
+ var shouldAutoDismiss ;
388
+ this . active . notification = notification ;
383
389
384
- this . active . notification = notification ;
385
- /*
386
- If autoDismiss has been specified, OR there are other
387
- notifications queued for display, setup a timeout to
388
- dismiss the dialog.
389
- */
390
- if ( notification && ( notification . model . autoDismiss ||
391
- this . selectNextNotification ( ) ) ) {
390
+ if ( ! notification ) {
391
+ delete this . active . timeout ;
392
+ return ;
393
+ }
392
394
393
- timeout = notification . model . autoDismiss || this . DEFAULT_AUTO_DISMISS ;
394
- this . active . timeout = this . $timeout ( function ( ) {
395
- notification . dismissOrMinimize ( ) ;
396
- } , timeout ) ;
397
- } else {
398
- delete this . active . timeout ;
399
- }
400
- } ;
395
+ if ( notification . model . severity === "info" ) {
396
+ shouldAutoDismiss = true ;
397
+ } else {
398
+ shouldAutoDismiss = notification . model . autoDismiss ;
399
+ }
400
+
401
+ if ( shouldAutoDismiss || this . selectNextNotification ( ) ) {
402
+ this . active . timeout = this . $timeout ( function ( ) {
403
+ notification . dismissOrMinimize ( ) ;
404
+ } , this . AUTO_DISMISS_TIMEOUT ) ;
405
+ } else {
406
+ delete this . active . timeout ;
407
+ }
408
+ } ;
401
409
402
410
/**
403
411
* Used internally by the NotificationService
0 commit comments