0
0
Fork 1
Spiegel von https://github.com/paviliondev/discourse-custom-wizard.git synchronisiert 2024-11-10 04:12:53 +01:00
discourse-custom-wizard/assets/javascripts/discourse/controllers/custom-wizard-step.js.es6
2023-09-14 15:03:15 +01:00

41 Zeilen
1,1 KiB
JavaScript

import Controller from "@ember/controller";
import getUrl from "discourse-common/lib/get-url";
import { inject as service } from "@ember/service";
export default Controller.extend({
router: service(),
wizard: null,
step: null,
actions: {
goNext(response) {
let nextStepId = response["next_step_id"];
if (response.redirect_on_next) {
window.location.href = response.redirect_on_next;
} else if (response.refresh_required) {
const wizardId = this.get("wizard.id");
window.location.href = getUrl(`/w/${wizardId}/steps/${nextStepId}`);
} else {
this.router.transitionToRoute("customWizardStep", nextStepId);
}
},
goBack() {
this.router.transitionToRoute(
"customWizardStep",
this.get("step.previous")
);
},
showMessage(message) {
this.set("stepMessage", message);
},
resetWizard() {
const id = this.get("wizard.id");
const stepId = this.get("step.id");
window.location.href = getUrl(`/w/${id}/steps/${stepId}?reset=true`);
},
},
});