0
0
Fork 1
Spiegel von https://github.com/paviliondev/discourse-custom-wizard.git synchronisiert 2024-11-27 03:20:27 +01:00
discourse-custom-wizard/assets/javascripts/discourse/routes/admin-wizards-wizard-show.js.es6

38 Zeilen
1,1 KiB
Text

2020-04-13 14:17:22 +02:00
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');
}
},
2020-04-14 01:39:21 +02:00
setupController(controller, model) {
2020-04-13 14:17:22 +02:00
const parentModel = this.modelFor('adminWizardsWizard');
const wizard = CustomWizard.create((!model || model.create) ? {} : model);
2020-04-14 07:46:06 +02:00
2020-04-13 14:17:22 +02:00
controller.setProperties({
wizardList: parentModel.wizard_list,
fieldTypes: selectKitContent(parentModel.field_types),
userFields: parentModel.userFields,
apis: parentModel.apis,
themes: parentModel.themes,
wizard,
currentStep: wizard.steps[0],
currentAction: wizard.actions[0],
creating: model.create
});
}
});