FIX: Flash messages were broken
This commit is contained in:
parent
06254d3163
commit
7bd88b706a
|
@ -6,6 +6,12 @@ export default Ember.Component.extend({
|
|||
$('#modal-alert').hide();
|
||||
$('#discourse-modal').modal('show');
|
||||
Ember.run.scheduleOnce('afterRender', this, this._afterFirstRender);
|
||||
this.appEvents.on('modal-body:flash', msg => this._flash(msg));
|
||||
},
|
||||
|
||||
willDestroyElement() {
|
||||
this._super();
|
||||
this.appEvents.off('modal-body:flash');
|
||||
},
|
||||
|
||||
_afterFirstRender() {
|
||||
|
@ -23,5 +29,12 @@ export default Ember.Component.extend({
|
|||
}
|
||||
|
||||
this.appEvents.trigger('modal:body-shown', this.getProperties('title'));
|
||||
}
|
||||
},
|
||||
|
||||
_flash(msg) {
|
||||
$('#modal-alert').hide()
|
||||
.removeClass('alert-error', 'alert-success')
|
||||
.addClass(`alert alert-${msg.messageClass || 'success'}`).html(msg.text || '')
|
||||
.fadeIn();
|
||||
},
|
||||
});
|
||||
|
|
|
@ -1,7 +1,5 @@
|
|||
export default Ember.Mixin.create({
|
||||
flashMessage: null,
|
||||
|
||||
flash(message, messageClass) {
|
||||
this.set('flashMessage', Em.Object.create({ message, messageClass }));
|
||||
flash(text, messageClass) {
|
||||
this.appEvents.trigger('modal-body:flash', { text, messageClass });
|
||||
}
|
||||
});
|
||||
|
|
|
@ -1,4 +1,3 @@
|
|||
import { observes } from "ember-addons/ember-computed-decorators";
|
||||
import deprecated from 'discourse-common/lib/deprecated';
|
||||
|
||||
export default Ember.View.extend({
|
||||
|
@ -12,6 +11,13 @@ export default Ember.View.extend({
|
|||
$('#modal-alert').hide();
|
||||
$('#discourse-modal').modal('show');
|
||||
Ember.run.scheduleOnce('afterRender', this, this._afterFirstRender);
|
||||
|
||||
this.appEvents.on('modal-body:flash', msg => this._flash(msg));
|
||||
},
|
||||
|
||||
willDestroyElement() {
|
||||
this._super();
|
||||
this.appEvents.off('modal-body:flash');
|
||||
},
|
||||
|
||||
_afterFirstRender() {
|
||||
|
@ -25,16 +31,10 @@ export default Ember.View.extend({
|
|||
}
|
||||
},
|
||||
|
||||
@observes("controller.flashMessage")
|
||||
flashMessageChanged() {
|
||||
const flashMessage = this.get('controller.flashMessage');
|
||||
if (flashMessage) {
|
||||
const messageClass = flashMessage.get('messageClass') || 'success';
|
||||
$('#modal-alert').hide()
|
||||
.removeClass('alert-error', 'alert-success')
|
||||
.addClass("alert alert-" + messageClass).html(flashMessage.get('message'))
|
||||
.fadeIn();
|
||||
}
|
||||
_flash(msg) {
|
||||
$('#modal-alert').hide()
|
||||
.removeClass('alert-error', 'alert-success')
|
||||
.addClass(`alert alert-${msg.messageClass || 'success'}`).html(msg.text || '')
|
||||
.fadeIn();
|
||||
}
|
||||
|
||||
});
|
||||
|
|
Loading…
Reference in New Issue