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/routes/admin-wizard.js.es6

39 Zeilen
943 B
Text

2017-09-23 04:34:07 +02:00
import CustomWizard from '../models/custom-wizard';
2017-10-05 02:36:46 +02:00
import { ajax } from 'discourse/lib/ajax';
2017-09-23 04:34:07 +02:00
export default Discourse.Route.extend({
model(params) {
if (params.wizard_id === 'new') {
2017-10-07 04:27:38 +02:00
this.set('newWizard', true);
return CustomWizard.create();
2017-09-23 04:34:07 +02:00
}
2017-10-07 04:27:38 +02:00
this.set('newWizard', false);
2017-09-23 04:34:07 +02:00
2017-10-07 04:27:38 +02:00
const wizard = this.modelFor('admin-wizards-custom').findBy('id', params.wizard_id.underscore());
2017-09-24 05:01:18 +02:00
if (!wizard) return this.transitionTo('adminWizardsCustom.index');
2017-09-23 04:34:07 +02:00
return wizard;
},
2017-10-05 02:36:46 +02:00
afterModel(model) {
return ajax('/admin/wizards/field-types')
.then((result) => model.set('fieldTypes', result.types));
},
2017-09-23 04:34:07 +02:00
setupController(controller, model) {
2017-10-07 04:27:38 +02:00
const newWizard = this.get('newWizard');
const steps = model.get('steps') || [];
controller.setProperties({
newWizard,
model,
currentStep: steps[0]
});
2017-10-06 04:59:02 +02:00
},
actions: {
2017-10-07 04:27:38 +02:00
refreshWizard() {
2017-10-06 04:59:02 +02:00
this.refresh();
}
2017-09-23 04:34:07 +02:00
}
});