2015-06-09 12:08:14 +02:00
|
|
|
'use strict';
|
|
|
|
|
|
|
|
export default class GlobalNotificationModel {
|
2015-06-10 15:49:46 +02:00
|
|
|
constructor(message, type = 'info', dismissAfter = 5000) {
|
2015-06-09 13:36:09 +02:00
|
|
|
if(message) {
|
|
|
|
this.message = message;
|
|
|
|
} else {
|
2015-06-09 12:08:14 +02:00
|
|
|
throw new Error('A notifications message must be defined.');
|
2015-06-09 13:36:09 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
if(type === 'info' || type === 'success' || type === 'warning' || type === 'danger') {
|
|
|
|
this.type = type;
|
2015-06-09 12:08:14 +02:00
|
|
|
} else {
|
2015-06-09 13:36:09 +02:00
|
|
|
throw new Error('A notification\'s type either has to be info, success, warning, danger. Not: ' + type);
|
2015-06-09 12:08:14 +02:00
|
|
|
}
|
|
|
|
|
2015-06-09 13:36:09 +02:00
|
|
|
this.dismissAfter = dismissAfter;
|
2015-06-09 12:08:14 +02:00
|
|
|
}
|
|
|
|
}
|