1
0
Fork 0
discourse-custom-wizard-unl.../assets/javascripts/wizard/routes/custom-step.js.es6
Faizaan Gagan 0205d8ccb5
fixed linting issues for javascripts/wizard folder (#94)
* ran eslint and fixes linting issues for javascripts/wizard folder

* ran prettier
2021-04-12 11:56:22 +05:30

41 Zeilen
939 B
JavaScript

import WizardI18n from "../lib/wizard-i18n";
export default Ember.Route.extend({
model(params) {
const appModel = this.modelFor("custom");
const allSteps = appModel.steps;
if (allSteps) {
const step = allSteps.findBy("id", params.step_id);
return step ? step : allSteps[0];
}
return appModel;
},
afterModel(model) {
if (model.completed) {
return this.transitionTo("index");
}
return model.set("wizardId", this.modelFor("custom").id);
},
setupController(controller, model) {
let props = {
step: model,
wizard: this.modelFor("custom"),
};
if (!model.permitted) {
props["stepMessage"] = {
state: "not-permitted",
text:
model.permitted_message || WizardI18n("wizard.step_not_permitted"),
};
if (model.index > 0) {
props["showReset"] = true;
}
}
controller.setProperties(props);
},
});