1
0
Fork 0
discourse-custom-wizard-unl.../assets/javascripts/discourse/routes/admin-wizards-wizard-show.js.es6
Angus McLeod d26744cf56 Schema handling updates
- support custom field types
- move client schema to seperate helper
- handle schema defaults properly
2020-04-16 12:04:27 +10:00

37 Zeilen
1,1 KiB
JavaScript

import CustomWizard from '../models/custom-wizard';
import { ajax } from 'discourse/lib/ajax';
import DiscourseRoute from "discourse/routes/discourse";
import { selectKitContent } from '../lib/wizard';
export default DiscourseRoute.extend({
model(params) {
if (params.wizardId === 'create') {
return { create: true };
} else {
return ajax(`/admin/wizards/wizard/${params.wizardId}`);
}
},
afterModel(model) {
if (model.none) {
return this.transitionTo('adminWizardsWizard');
}
},
setupController(controller, model) {
const parentModel = this.modelFor('adminWizardsWizard');
const wizard = CustomWizard.create((!model || model.create) ? {} : model);
controller.setProperties({
wizardList: parentModel.wizard_list,
fieldTypes: selectKitContent(Object.keys(parentModel.field_types)),
userFields: parentModel.userFields,
apis: parentModel.apis,
themes: parentModel.themes,
wizard,
currentStep: wizard.steps[0],
currentAction: wizard.actions[0],
creating: model.create
});
}
});