0
0
Fork 1
Spiegel von https://github.com/paviliondev/discourse-custom-wizard.git synchronisiert 2024-09-20 07:41:11 +02:00
discourse-custom-wizard/assets/javascripts/discourse/controllers/admin-wizard.js.es6
Angus McLeod 5220b069f6 various
2017-10-17 15:18:53 +08:00

36 Zeilen
958 B
JavaScript

import { default as computed } from 'ember-addons/ember-computed-decorators';
export default Ember.Controller.extend({
@computed('model.id', 'model.name')
wizardUrl(wizardId) {
return window.location.origin + '/w/' + Ember.String.dasherize(wizardId);
},
actions: {
save() {
this.setProperties({
saving: true,
error: null
});
const wizard = this.get('model');
wizard.save().then(() => {
this.set('saving', false);
if (this.get('newWizard')) {
this.send("refreshAllWizards");
} else {
this.send("refreshWizard");
}
}).catch((error) => {
this.set('saving', false);
this.set('error', I18n.t(`admin.wizard.error.${error}`));
Ember.run.later(() => this.set('error', null), 10000);
});
},
remove() {
this.get('model').remove().then(() => {
this.send("refreshAllWizards");
});
}
}
});