2022-03-16 12:33:34 +01:00
|
|
|
import Controller from "@ember/controller";
|
2021-03-28 11:06:49 +02:00
|
|
|
import getUrl from "discourse-common/lib/get-url";
|
2017-09-29 13:27:03 +02:00
|
|
|
|
2022-03-16 12:33:34 +01:00
|
|
|
export default Controller.extend({
|
|
|
|
wizard: null,
|
|
|
|
step: null,
|
|
|
|
|
2017-09-29 13:27:03 +02:00
|
|
|
actions: {
|
|
|
|
goNext(response) {
|
2021-04-20 19:58:19 +02:00
|
|
|
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;
|
2019-07-02 06:49:14 +02:00
|
|
|
} else if (response.refresh_required) {
|
2021-04-20 19:58:19 +02:00
|
|
|
const wizardId = this.get("wizard.id");
|
|
|
|
window.location.href = getUrl(`/w/${wizardId}/steps/${nextStepId}`);
|
2017-09-29 13:27:03 +02:00
|
|
|
} else {
|
2022-03-16 12:33:34 +01:00
|
|
|
this.transitionToRoute("step", nextStepId);
|
2017-09-29 13:27:03 +02:00
|
|
|
}
|
|
|
|
},
|
|
|
|
|
|
|
|
goBack() {
|
2022-03-16 12:33:34 +01:00
|
|
|
this.transitionToRoute("step", this.get("step.previous"));
|
2017-10-13 15:02:34 +02:00
|
|
|
},
|
|
|
|
|
|
|
|
showMessage(message) {
|
2021-03-28 11:06:49 +02:00
|
|
|
this.set("stepMessage", message);
|
2019-07-27 09:01:29 +02:00
|
|
|
},
|
|
|
|
|
|
|
|
resetWizard() {
|
2021-03-28 11:06:49 +02:00
|
|
|
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`);
|
2021-03-28 11:06:49 +02:00
|
|
|
},
|
|
|
|
},
|
2017-09-29 13:27:03 +02:00
|
|
|
});
|