0
0
Fork 1
Spiegel von https://github.com/paviliondev/discourse-custom-wizard.git synchronisiert 2024-11-15 06:12:54 +01:00
discourse-custom-wizard/assets/javascripts/discourse/routes/custom-wizard-index.js.es6
2023-02-07 12:46:17 +01:00

39 Zeilen
998 B
JavaScript

import { getCachedWizard } from "../models/custom-wizard";
import Route from "@ember/routing/route";
export default Route.extend({
beforeModel() {
const wizard = getCachedWizard();
if (wizard && wizard.permitted && !wizard.completed && wizard.start) {
this.replaceWith("customWizardStep", wizard.start);
}
},
model() {
return getCachedWizard();
},
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;
const notPermitted = !permitted;
const props = {
requiresLogin,
user,
name,
completed,
notPermitted,
wizardId,
};
controller.setProperties(props);
} else {
controller.set("noWizard", true);
}
},
});