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 a09376e645 various
2017-10-30 14:24:51 +08:00

37 Zeilen
994 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((result) => {
console.log(result)
this.set('saving', false);
this.set('error', I18n.t(`admin.wizard.error.${result.error}`));
Ember.run.later(() => this.set('error', null), 10000);
});
},
remove() {
this.get('model').remove().then(() => {
this.send("refreshAllWizards");
});
}
}
});