2022-07-27 12:47:50 +02:00
|
|
|
import { getCachedWizard } from "../models/custom-wizard";
|
2022-03-16 12:33:34 +01:00
|
|
|
import Route from "@ember/routing/route";
|
2021-04-20 19:58:19 +02:00
|
|
|
|
2022-03-16 12:33:34 +01:00
|
|
|
export default Route.extend({
|
2017-09-29 13:27:03 +02:00
|
|
|
beforeModel() {
|
2021-04-20 19:58:19 +02:00
|
|
|
const wizard = getCachedWizard();
|
2023-02-07 12:46:17 +01:00
|
|
|
if (wizard && wizard.permitted && !wizard.completed && wizard.start) {
|
2022-07-26 16:18:09 +02:00
|
|
|
this.replaceWith("customWizardStep", wizard.start);
|
2017-10-13 15:02:34 +02:00
|
|
|
}
|
|
|
|
},
|
|
|
|
|
2017-11-29 10:48:49 +01:00
|
|
|
model() {
|
2021-04-20 19:58:19 +02:00
|
|
|
return getCachedWizard();
|
2017-11-29 10:48:49 +01:00
|
|
|
},
|
|
|
|
|
|
|
|
setupController(controller, model) {
|
2021-04-20 19:58:19 +02:00
|
|
|
if (model && model.id) {
|
2021-03-28 11:06:49 +02:00
|
|
|
const completed = model.get("completed");
|
|
|
|
const permitted = model.get("permitted");
|
|
|
|
const wizardId = model.get("id");
|
|
|
|
const user = model.get("user");
|
|
|
|
const name = model.get("name");
|
2023-02-07 12:46:17 +01:00
|
|
|
const requiresLogin = !user && !permitted;
|
2022-03-16 12:33:34 +01:00
|
|
|
const notPermitted = !permitted;
|
2018-05-09 07:06:43 +02:00
|
|
|
|
2022-03-16 12:33:34 +01:00
|
|
|
const props = {
|
|
|
|
requiresLogin,
|
2019-06-19 07:23:10 +02:00
|
|
|
user,
|
2019-06-19 07:39:39 +02:00
|
|
|
name,
|
2017-12-03 08:57:40 +01:00
|
|
|
completed,
|
2022-03-16 12:33:34 +01:00
|
|
|
notPermitted,
|
2021-03-28 11:06:49 +02:00
|
|
|
wizardId,
|
2022-03-16 12:33:34 +01:00
|
|
|
};
|
|
|
|
controller.setProperties(props);
|
2017-12-03 08:57:40 +01:00
|
|
|
} else {
|
2021-03-28 11:06:49 +02:00
|
|
|
controller.set("noWizard", true);
|
2017-12-03 08:57:40 +01:00
|
|
|
}
|
2022-06-15 08:59:09 +02:00
|
|
|
},
|
2017-09-29 13:27:03 +02:00
|
|
|
});
|