Spiegel von
https://github.com/paviliondev/discourse-custom-wizard.git
synchronisiert 2024-11-23 01:40:29 +01:00
cf50a7deb3
* Apply prettier * applied prettier for similar-topics-validator Co-authored-by: Faizaan Gagan <fzngagan@gmail.com>
49 Zeilen
1,3 KiB
JavaScript
49 Zeilen
1,3 KiB
JavaScript
import CustomWizard from "../models/custom-wizard";
|
|
import { ajax } from "discourse/lib/ajax";
|
|
import DiscourseRoute from "discourse/routes/discourse";
|
|
import I18n from "I18n";
|
|
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);
|
|
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: selectKitContent(
|
|
parentModel.custom_fields.map((f) => f.name)
|
|
),
|
|
apis: parentModel.apis,
|
|
themes: parentModel.themes,
|
|
wizard,
|
|
currentStep: wizard.steps[0],
|
|
currentAction: wizard.actions[0],
|
|
creating: model.create,
|
|
};
|
|
|
|
controller.setProperties(props);
|
|
},
|
|
});
|