2021-04-21 03:58:19 +10:00
|
|
|
import { getCachedWizard } from "../models/custom";
|
|
|
|
|
2017-10-13 21:02:34 +08:00
|
|
|
export default Ember.Route.extend({
|
2017-09-29 19:27:03 +08:00
|
|
|
beforeModel() {
|
2021-04-21 03:58:19 +10:00
|
|
|
const wizard = getCachedWizard();
|
|
|
|
if (wizard && wizard.permitted && !wizard.completed && wizard.start) {
|
|
|
|
this.replaceWith("custom.step", wizard.start);
|
2017-10-13 21:02:34 +08:00
|
|
|
}
|
|
|
|
},
|
|
|
|
|
2017-11-29 17:48:49 +08:00
|
|
|
model() {
|
2021-04-21 03:58:19 +10:00
|
|
|
return getCachedWizard();
|
2017-11-29 17:48:49 +08:00
|
|
|
},
|
|
|
|
|
|
|
|
setupController(controller, model) {
|
2021-04-21 03:58:19 +10:00
|
|
|
if (model && model.id) {
|
2021-03-28 20:06:49 +11: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");
|
2018-05-09 15:06:43 +10:00
|
|
|
|
2017-12-03 15:57:40 +08:00
|
|
|
controller.setProperties({
|
2019-06-19 13:23:10 +08:00
|
|
|
requiresLogin: !user,
|
|
|
|
user,
|
2019-06-19 13:39:39 +08:00
|
|
|
name,
|
2017-12-03 15:57:40 +08:00
|
|
|
completed,
|
|
|
|
notPermitted: !permitted,
|
2021-03-28 20:06:49 +11:00
|
|
|
wizardId,
|
2017-12-03 15:57:40 +08:00
|
|
|
});
|
|
|
|
} else {
|
2021-03-28 20:06:49 +11:00
|
|
|
controller.set("noWizard", true);
|
2017-12-03 15:57:40 +08:00
|
|
|
}
|
2021-03-28 20:06:49 +11:00
|
|
|
},
|
2017-09-29 19:27:03 +08:00
|
|
|
});
|