Skip to content
This repository was archived by the owner on Jul 22, 2025. It is now read-only.

Commit 44b1714

Browse files
FIX: HouseAdsChooser onChange handling (#234)
Having an action named the same as an argument is no longer possible in a classic component. Move the logic to the parent instead. Followup to 7685ebf
1 parent 00298bf commit 44b1714

File tree

3 files changed

+10
-13
lines changed

3 files changed

+10
-13
lines changed

admin/assets/javascripts/discourse/components/house-ads-chooser.js

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { action, computed } from "@ember/object";
1+
import { computed } from "@ember/object";
22
import { classNames } from "@ember-decorators/component";
33
import { makeArray } from "discourse-common/lib/helpers";
44
import MultiSelectComponent from "select-kit/components/multi-select";
@@ -22,11 +22,6 @@ export default class HouseAdsChooser extends MultiSelectComponent {
2222
.filter(Boolean);
2323
}
2424

25-
// TODO: kept for legacy, remove when Discourse is 2.5
26-
mutateValues(values) {
27-
this.set("settingValue", values.join(this.tokenSeparator));
28-
}
29-
3025
computeValues() {
3126
return this.settingValue.split(this.tokenSeparator).filter(Boolean);
3227
}
@@ -35,10 +30,4 @@ export default class HouseAdsChooser extends MultiSelectComponent {
3530
get content() {
3631
return makeArray(this.choices);
3732
}
38-
39-
@action
40-
onChange(value) {
41-
const settingValue = makeArray(value).join(this.tokenSeparator);
42-
this.onChange?.(settingValue);
43-
}
4433
}

admin/assets/javascripts/discourse/components/house-ads-list-setting.hbs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
{{house-ads-chooser
33
settingValue=this.adValue
44
choices=this.adNames
5-
onChange=(action (mut this.adValue))
5+
onChange=this.changeAdValue
66
}}
77
<div class="setting-controls">
88
{{#if this.changed}}
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,16 @@
1+
import { action } from "@ember/object";
12
import { mapBy } from "@ember/object/computed";
23
import { classNames } from "@ember-decorators/component";
4+
import { makeArray } from "discourse-common/lib/helpers";
35
import HouseAdsSetting from "discourse/plugins/discourse-adplugin/discourse/components/house-ads-setting";
46

57
@classNames("house-ads-setting house-ads-list-setting")
68
export default class HouseAdsListSetting extends HouseAdsSetting {
79
@mapBy("allAds", "name") adNames;
10+
11+
@action
12+
changeAdValue(value) {
13+
const settingValue = makeArray(value).join("|");
14+
this.set("adValue", settingValue);
15+
}
816
}

0 commit comments

Comments
 (0)