mirror of
https://github.com/discourse/discourse.git
synced 2025-01-19 03:22:46 +08:00
DEV: Use @action
decorator in wizard (#16996)
This commit is contained in:
parent
f4b9d4e285
commit
8a58ce6578
|
@ -1,6 +1,7 @@
|
|||
import Component from "@ember/component";
|
||||
import I18n from "I18n";
|
||||
import { schedule } from "@ember/runloop";
|
||||
import { action } from "@ember/object";
|
||||
|
||||
export default Component.extend({
|
||||
classNames: ["invite-list"],
|
||||
|
@ -42,7 +43,7 @@ export default Component.extend({
|
|||
this.set("field.warning", showWarning ? "invites.none_added" : null);
|
||||
},
|
||||
|
||||
actions: {
|
||||
@action
|
||||
addUser() {
|
||||
const user = {
|
||||
email: this.inviteEmail || "",
|
||||
|
@ -69,9 +70,9 @@ export default Component.extend({
|
|||
);
|
||||
},
|
||||
|
||||
@action
|
||||
removeUser(user) {
|
||||
this.users.removeObject(user);
|
||||
this.updateField();
|
||||
},
|
||||
},
|
||||
});
|
||||
|
|
|
@ -5,6 +5,7 @@ import {
|
|||
} from "wizard/lib/preview";
|
||||
import I18n from "I18n";
|
||||
import { bind, observes } from "discourse-common/utils/decorators";
|
||||
import { action } from "@ember/object";
|
||||
|
||||
const LOREM = `
|
||||
Lorem ipsum dolor sit amet, consectetur adipiscing.
|
||||
|
@ -189,13 +190,13 @@ export default createPreviewComponent(659, 320, {
|
|||
ctx.fillText("1 / 20", timelineX + margin, height * 0.3 + margin * 1.5);
|
||||
},
|
||||
|
||||
actions: {
|
||||
@action
|
||||
setPreviewHomepage() {
|
||||
this.set("previewTopic", false);
|
||||
},
|
||||
|
||||
@action
|
||||
setPreviewTopic() {
|
||||
this.set("previewTopic", true);
|
||||
},
|
||||
},
|
||||
});
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
import Component from "@ember/component";
|
||||
import { set } from "@ember/object";
|
||||
import { action, set } from "@ember/object";
|
||||
|
||||
export default Component.extend({
|
||||
init(...args) {
|
||||
|
@ -12,7 +12,8 @@ export default Component.extend({
|
|||
}
|
||||
}
|
||||
},
|
||||
actions: {
|
||||
|
||||
@action
|
||||
changed(checkbox) {
|
||||
let newFieldValue = this.field.value;
|
||||
const checkboxValue = checkbox.parentElement
|
||||
|
@ -29,5 +30,4 @@ export default Component.extend({
|
|||
}
|
||||
this.set("field.value", newFieldValue);
|
||||
},
|
||||
},
|
||||
});
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
import Component from "@ember/component";
|
||||
import discourseComputed from "discourse-common/utils/decorators";
|
||||
import { set } from "@ember/object";
|
||||
import { action, set } from "@ember/object";
|
||||
|
||||
export default Component.extend({
|
||||
init(...args) {
|
||||
|
@ -27,7 +27,7 @@ export default Component.extend({
|
|||
e.stopPropagation();
|
||||
},
|
||||
|
||||
actions: {
|
||||
@action
|
||||
onChangeValue(value) {
|
||||
this.set("field.value", value);
|
||||
|
||||
|
@ -35,5 +35,4 @@ export default Component.extend({
|
|||
this.wizard.trigger("homepageStyleChanged");
|
||||
}
|
||||
},
|
||||
},
|
||||
});
|
||||
|
|
|
@ -1,8 +1,9 @@
|
|||
import Component from "@ember/component";
|
||||
import { action } from "@ember/object";
|
||||
|
||||
export default Component.extend({
|
||||
actions: {
|
||||
@action
|
||||
changed(value) {
|
||||
this.set("field.value", value);
|
||||
},
|
||||
},
|
||||
});
|
||||
|
|
|
@ -4,6 +4,7 @@ import I18n from "I18n";
|
|||
import getUrl from "discourse-common/lib/get-url";
|
||||
import { htmlSafe } from "@ember/template";
|
||||
import { schedule } from "@ember/runloop";
|
||||
import { action } from "@ember/object";
|
||||
|
||||
const alreadyWarned = {};
|
||||
|
||||
|
@ -107,11 +108,12 @@ export default Component.extend({
|
|||
.finally(() => this.set("saving", false));
|
||||
},
|
||||
|
||||
actions: {
|
||||
@action
|
||||
quit() {
|
||||
document.location = getUrl("/");
|
||||
},
|
||||
|
||||
@action
|
||||
exitEarly() {
|
||||
const step = this.step;
|
||||
step.validate();
|
||||
|
@ -128,6 +130,7 @@ export default Component.extend({
|
|||
}
|
||||
},
|
||||
|
||||
@action
|
||||
backStep() {
|
||||
if (this.saving) {
|
||||
return;
|
||||
|
@ -136,6 +139,7 @@ export default Component.extend({
|
|||
this.goBack();
|
||||
},
|
||||
|
||||
@action
|
||||
nextStep() {
|
||||
if (this.saving) {
|
||||
return;
|
||||
|
@ -167,5 +171,4 @@ export default Component.extend({
|
|||
this.autoFocus();
|
||||
}
|
||||
},
|
||||
},
|
||||
});
|
||||
|
|
|
@ -1,11 +1,12 @@
|
|||
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,
|
||||
|
||||
actions: {
|
||||
@action
|
||||
goNext(response) {
|
||||
const next = this.get("step.next");
|
||||
if (response && response.refresh_required) {
|
||||
|
@ -13,15 +14,16 @@ export default Controller.extend({
|
|||
document.location = getUrl(`/wizard/steps/${next}`);
|
||||
return;
|
||||
} else {
|
||||
this.send("refresh");
|
||||
this.send("refreshRoute");
|
||||
}
|
||||
}
|
||||
if (response && response.success) {
|
||||
this.transitionToRoute("step", next);
|
||||
}
|
||||
},
|
||||
|
||||
@action
|
||||
goBack() {
|
||||
this.transitionToRoute("step", this.get("step.previous"));
|
||||
},
|
||||
},
|
||||
});
|
||||
|
|
|
@ -1,14 +1,14 @@
|
|||
import Route from "@ember/routing/route";
|
||||
import { findWizard } from "wizard/models/wizard";
|
||||
import { action } from "@ember/object";
|
||||
|
||||
export default Route.extend({
|
||||
model() {
|
||||
return findWizard();
|
||||
},
|
||||
|
||||
actions: {
|
||||
refresh() {
|
||||
@action
|
||||
refreshRoute() {
|
||||
this.refresh();
|
||||
},
|
||||
},
|
||||
});
|
||||
|
|
Loading…
Reference in New Issue
Block a user