0
0
Fork 1
Spiegel von https://github.com/paviliondev/discourse-custom-wizard.git synchronisiert 2024-11-26 11:00:28 +01:00
discourse-custom-wizard/assets/javascripts/discourse/controllers/custom-wizard-step.js.es6

42 Zeilen
1,1 KiB
Text

2022-03-16 12:33:34 +01:00
import Controller from "@ember/controller";
import getUrl from "discourse-common/lib/get-url";
2023-09-14 15:59:22 +02:00
import { inject as service } from "@ember/service";
2022-03-16 12:33:34 +01:00
export default Controller.extend({
router: service(),
2022-03-16 12:33:34 +01:00
wizard: null,
step: null,
actions: {
goNext(response) {
let nextStepId = response["next_step_id"];
2019-08-29 01:51:18 +02:00
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() {
2023-09-14 16:03:15 +02:00
this.router.transitionToRoute(
"customWizardStep",
this.get("step.previous")
);
2017-10-13 15:02:34 +02:00
},
showMessage(message) {
this.set("stepMessage", message);
2019-07-27 09:01:29 +02:00
},
resetWizard() {
const id = this.get("wizard.id");
const stepId = this.get("step.id");
2019-07-27 09:01:29 +02:00
window.location.href = getUrl(`/w/${id}/steps/${stepId}?reset=true`);
},
},
});