0
0
Fork 1
Spiegel von https://github.com/paviliondev/discourse-custom-wizard.git synchronisiert 2024-11-28 20:00:28 +01:00
discourse-custom-wizard/assets/javascripts/discourse/routes/admin-wizards-wizard-show.js
Angus McLeod ce55b4671e Linting
2024-11-22 17:11:51 +01:00

53 Zeilen
1,4 KiB
JavaScript

import { service } from "@ember/service";
import { ajax } from "discourse/lib/ajax";
import DiscourseRoute from "discourse/routes/discourse";
import I18n from "I18n";
import CustomWizardAdmin from "../models/custom-wizard-admin";
export default DiscourseRoute.extend({
router: service(),
model(params) {
if (params.wizardId === "create") {
return { create: true };
} else {
return ajax(`/admin/wizards/wizard/${params.wizardId}`);
}
},
afterModel(model) {
if (model.none) {
return this.router.transitionTo("adminWizardsWizard");
}
},
setupController(controller, model) {
const parentModel = this.modelFor("adminWizardsWizard");
const wizard = CustomWizardAdmin.create(
!model || model.create ? {} : model
);
const fieldTypes = Object.keys(parentModel.field_types).map((type) => {
return {
id: type,
name: I18n.t(`admin.wizard.field.type.${type}`),
};
});
let props = {
wizardList: parentModel.wizard_list,
fieldTypes,
userFields: parentModel.userFields,
customFields: parentModel.custom_fields,
apis: parentModel.apis,
themes: parentModel.themes,
wizard,
currentStep: wizard.steps[0],
currentAction: wizard.actions[0],
creating: model.create,
afterTimeGroupIds: [],
};
controller.setProperties(props);
controller.setAfterTimeGroupIds();
},
});