0
0
Fork 1
Spiegel von https://github.com/paviliondev/discourse-custom-wizard.git synchronisiert 2024-11-22 09:20:29 +01:00
discourse-custom-wizard/assets/javascripts/discourse/routes/custom-wizard-index.js.es6

43 Zeilen
1,1 KiB
Text

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";
2023-09-14 15:47:52 +02:00
import { inject as service } from "@ember/service";
2022-03-16 12:33:34 +01:00
export default Route.extend({
router: service(),
beforeModel() {
const wizard = getCachedWizard();
if (wizard && wizard.permitted && !wizard.completed && wizard.start) {
this.router.replaceWith("customWizardStep", wizard.start);
2017-10-13 15:02:34 +02:00
}
},
2017-11-29 10:48:49 +01:00
model() {
return getCachedWizard();
2017-11-29 10:48:49 +01:00
},
setupController(controller, model) {
if (model && model.id) {
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");
const requiresLogin = !user && !permitted;
2022-03-16 12:33:34 +01:00
const notPermitted = !permitted;
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,
wizardId,
2022-03-16 12:33:34 +01:00
};
controller.setProperties(props);
2017-12-03 08:57:40 +01:00
} else {
controller.set("noWizard", true);
2017-12-03 08:57:40 +01:00
}
2022-06-15 08:59:09 +02:00
},
});