2020-11-26 06:45:30 +01:00
|
|
|
import WizardI18n from "../lib/wizard-i18n";
|
2020-05-14 05:42:11 +02:00
|
|
|
|
2017-10-13 15:02:34 +02:00
|
|
|
export default Ember.Route.extend({
|
|
|
|
model(params) {
|
2021-03-28 11:06:49 +02:00
|
|
|
const appModel = this.modelFor("custom");
|
2017-10-13 15:02:34 +02:00
|
|
|
const allSteps = appModel.steps;
|
|
|
|
if (allSteps) {
|
2021-03-28 11:06:49 +02:00
|
|
|
const step = allSteps.findBy("id", params.step_id);
|
2017-10-13 15:02:34 +02:00
|
|
|
return step ? step : allSteps[0];
|
2021-03-28 11:06:49 +02:00
|
|
|
}
|
2017-09-29 13:27:03 +02:00
|
|
|
|
2017-10-13 15:02:34 +02:00
|
|
|
return appModel;
|
|
|
|
},
|
|
|
|
|
|
|
|
afterModel(model) {
|
2021-03-28 11:06:49 +02:00
|
|
|
if (model.completed) return this.transitionTo("index");
|
|
|
|
return model.set("wizardId", this.modelFor("custom").id);
|
2017-10-13 15:02:34 +02:00
|
|
|
},
|
|
|
|
|
2019-07-02 06:49:14 +02:00
|
|
|
setupController(controller, model) {
|
|
|
|
let props = {
|
|
|
|
step: model,
|
2021-03-28 11:06:49 +02:00
|
|
|
wizard: this.modelFor("custom"),
|
2019-07-02 06:49:14 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
if (!model.permitted) {
|
2021-03-28 11:06:49 +02:00
|
|
|
props["stepMessage"] = {
|
|
|
|
state: "not-permitted",
|
|
|
|
text:
|
|
|
|
model.permitted_message || WizardI18n("wizard.step_not_permitted"),
|
2019-07-02 06:49:14 +02:00
|
|
|
};
|
2019-07-27 09:01:29 +02:00
|
|
|
if (model.index > 0) {
|
2021-03-28 11:06:49 +02:00
|
|
|
props["showReset"] = true;
|
2019-07-27 09:01:29 +02:00
|
|
|
}
|
2019-07-02 06:49:14 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
controller.setProperties(props);
|
2021-03-28 11:06:49 +02:00
|
|
|
},
|
2017-10-13 15:02:34 +02:00
|
|
|
});
|