Spiegel von
https://github.com/paviliondev/discourse-custom-wizard.git
synchronisiert 2024-11-22 17:30:29 +01:00
36 Zeilen
958 B
JavaScript
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");
|
|
});
|
|
}
|
|
}
|
|
});
|