1
0
Fork 0
discourse-custom-wizard-unl.../assets/javascripts/discourse/controllers/admin-wizard.js.es6

38 Zeilen
994 B
Text

2017-10-06 04:59:02 +02:00
import { default as computed } from 'ember-addons/ember-computed-decorators';
2017-09-23 04:34:07 +02:00
export default Ember.Controller.extend({
2017-10-07 04:27:38 +02:00
@computed('model.id', 'model.name')
2017-10-06 04:59:02 +02:00
wizardUrl(wizardId) {
2017-10-13 15:02:34 +02:00
return window.location.origin + '/w/' + Ember.String.dasherize(wizardId);
2017-10-06 04:59:02 +02:00
},
2017-09-23 04:34:07 +02:00
actions: {
save() {
2017-10-13 15:02:34 +02:00
this.setProperties({
saving: true,
error: null
});
const wizard = this.get('model');
wizard.save().then(() => {
this.set('saving', false);
2017-10-07 04:27:38 +02:00
if (this.get('newWizard')) {
this.send("refreshAllWizards");
} else {
this.send("refreshWizard");
}
2017-10-30 07:24:51 +01:00
}).catch((result) => {
console.log(result)
2017-10-13 15:02:34 +02:00
this.set('saving', false);
2017-10-30 07:24:51 +01:00
this.set('error', I18n.t(`admin.wizard.error.${result.error}`));
2017-10-13 15:02:34 +02:00
Ember.run.later(() => this.set('error', null), 10000);
2017-09-23 04:34:07 +02:00
});
},
remove() {
2017-09-24 05:01:18 +02:00
this.get('model').remove().then(() => {
2017-10-07 04:27:38 +02:00
this.send("refreshAllWizards");
2017-09-23 04:34:07 +02:00
});
}
}
});