discourse/app/assets/javascripts/wizard/addon/controllers/wizard-step.js
Jarek Radosz fcb4e5a1a1
DEV: Make wizard an ember addon (#17027)
Co-authored-by: David Taylor <david@taylorhq.com>
2022-06-17 14:50:21 +02:00

25 lines
565 B
JavaScript

import getUrl from "discourse-common/lib/get-url";
import Controller from "@ember/controller";
import { action } from "@ember/object";
export default Controller.extend({
wizard: null,
step: null,
@action
goNext(response) {
const next = this.get("step.next");
if (response?.refresh_required) {
document.location = getUrl(`/wizard/steps/${next}`);
} else if (response?.success) {
this.transitionToRoute("wizard.step", next);
}
},
@action
goBack() {
this.transitionToRoute("wizard.step", this.step.previous);
},
});