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

57 Zeilen
1,2 KiB
JavaScript

import WizardI18n from "../lib/wizard-i18n";
import { getCachedWizard } from "../models/custom";
import showModal from "discourse/lib/show-modal";
export default Ember.Route.extend({
beforeModel() {
this.set("wizard", getCachedWizard());
},
model(params) {
const wizard = this.wizard;
if (wizard && wizard.steps) {
const step = wizard.steps.findBy("id", params.step_id);
return step ? step : wizard.steps[0];
} else {
return wizard;
}
},
afterModel(model) {
if (model.completed) {
return this.transitionTo("index");
}
return model.set("wizardId", this.wizard.id);
},
setupController(controller, model) {
let props = {
step: model,
wizard: this.wizard,
};
if (!model.permitted) {
props["stepMessage"] = {
state: "not-permitted",
text:
model.permitted_message || WizardI18n("wizard.step_not_permitted"),
};
if (model.index > 0) {
props["showReset"] = true;
}
}
controller.setProperties(props);
},
renderTemplate() {
this.render("custom.step");
const modalController = showModal('resume-popup-modal');
},
actions: {
closeModal(initiatedBy) {
}
}
});