2015-05-21 20:03:24 +03:00
|
|
|
import Ember from 'ember';
|
|
|
|
|
2015-05-26 05:10:50 +03:00
|
|
|
export default Ember.Component.extend({
|
2015-05-21 20:03:24 +03:00
|
|
|
tagName: 'article',
|
2015-06-19 00:56:18 +03:00
|
|
|
classNames: ['gh-alert'],
|
2015-05-21 20:03:24 +03:00
|
|
|
classNameBindings: ['typeClass'],
|
|
|
|
|
2015-05-26 05:10:50 +03:00
|
|
|
notifications: Ember.inject.service(),
|
|
|
|
|
2015-05-21 20:03:24 +03:00
|
|
|
typeClass: Ember.computed(function () {
|
|
|
|
var classes = '',
|
|
|
|
message = this.get('message'),
|
2015-06-19 00:56:18 +03:00
|
|
|
type = Ember.get(message, 'type'),
|
|
|
|
typeMapping;
|
|
|
|
|
|
|
|
typeMapping = {
|
|
|
|
success: 'green',
|
|
|
|
error: 'red',
|
|
|
|
warn: 'yellow',
|
|
|
|
info: 'blue'
|
|
|
|
};
|
|
|
|
|
|
|
|
if (typeMapping[type] !== undefined) {
|
|
|
|
classes += 'gh-alert-' + typeMapping[type];
|
2015-05-21 20:03:24 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
return classes;
|
|
|
|
}),
|
|
|
|
|
|
|
|
actions: {
|
|
|
|
closeNotification: function () {
|
2015-05-26 05:10:50 +03:00
|
|
|
this.get('notifications').closeNotification(this.get('message'));
|
2015-05-21 20:03:24 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|