0
0
Fork 1
Spiegel von https://github.com/paviliondev/discourse-custom-wizard.git synchronisiert 2024-11-10 12:22:54 +01:00
discourse-custom-wizard/assets/javascripts/discourse/routes/admin-wizard.js.es6
Angus McLeod 9f40821db0 Various
2017-10-06 10:59:02 +08:00

35 Zeilen
906 B
JavaScript

import CustomWizard from '../models/custom-wizard';
import { ajax } from 'discourse/lib/ajax';
export default Discourse.Route.extend({
model(params) {
if (params.wizard_id === 'new') {
this.set('new', true);
return CustomWizard.create();
}
this.set('new', false);
const wizard = this.modelFor('admin-wizards-custom').findBy('id', params.wizard_id);
if (!wizard) return this.transitionTo('adminWizardsCustom.index');
return wizard;
},
afterModel(model) {
return ajax('/admin/wizards/field-types')
.then((result) => model.set('fieldTypes', result.types));
},
setupController(controller, model) {
let props = { new: this.get('new'), model };
const steps = model.get('steps');
if (steps[0]) props['currentStep'] = steps[0];
controller.setProperties(props);
},
actions: {
refreshRoute() {
this.refresh();
}
}
});