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