0
0
Fork 1
Spiegel von https://github.com/paviliondev/discourse-custom-wizard.git synchronisiert 2024-11-29 20:20:29 +01:00
discourse-custom-wizard/assets/javascripts/wizard/routes/custom-step.js.es6
Angus McLeod cf50a7deb3
Apply prettier 💄 (#80)
* Apply prettier

* applied prettier for similar-topics-validator

Co-authored-by: Faizaan Gagan <fzngagan@gmail.com>
2021-03-28 14:36:49 +05:30

39 Zeilen
925 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);
},
});