mirror of
https://github.com/flarum/core.git
synced 2025-07-24 18:21:33 +02:00
Add alert messages
This commit is contained in:
@@ -1,9 +1,44 @@
|
||||
import Ember from 'ember';
|
||||
|
||||
export default Ember.Component.extend({
|
||||
|
||||
close: function() {
|
||||
this.sendAction('closeAction');
|
||||
}
|
||||
import TaggedArray from '../utils/tagged-array';
|
||||
import ActionButton from 'flarum/components/ui/controls/action-button';
|
||||
|
||||
export default Ember.Component.extend(Ember.Evented, {
|
||||
message: '',
|
||||
type: '',
|
||||
dismissable: true,
|
||||
|
||||
layoutName: 'components/alert-message',
|
||||
classNames: ['alert'],
|
||||
classNameBindings: ['classForType'],
|
||||
|
||||
classForType: function() {
|
||||
return 'alert-'+this.get('type');
|
||||
}.property('type'),
|
||||
|
||||
didInsertElement: function() {
|
||||
var controls = TaggedArray.create();
|
||||
this.trigger('populateControls', controls);
|
||||
this.set('controls', controls);
|
||||
},
|
||||
|
||||
populateControls: function(controls) {
|
||||
if (this.get('dismissable')) {
|
||||
var component = this;
|
||||
var dismiss = ActionButton.create({
|
||||
icon: 'times',
|
||||
className: 'btn btn-icon btn-link',
|
||||
action: function() {
|
||||
component.send('dismiss');
|
||||
}
|
||||
});
|
||||
controls.pushObjectWithTag(dismiss, 'dismiss');
|
||||
}
|
||||
},
|
||||
|
||||
actions: {
|
||||
dismiss: function() {
|
||||
this.sendAction('dismiss', this);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
Reference in New Issue
Block a user