FIX: makes houses hads work with sk2
This commit is contained in:
parent
63ae1672ad
commit
af346fc1c2
|
@ -1,28 +1,41 @@
|
||||||
import MultiSelectComponent from "select-kit/components/multi-select";
|
import MultiSelectComponent from "select-kit/components/multi-select";
|
||||||
const { makeArray } = Ember;
|
const { makeArray } = Ember;
|
||||||
|
import { computed } from "@ember/object";
|
||||||
|
|
||||||
export default MultiSelectComponent.extend({
|
export default MultiSelectComponent.extend({
|
||||||
classNames: "house-ads-chooser",
|
classNames: ["house-ads-chooser"],
|
||||||
filterable: true,
|
filterable: true,
|
||||||
filterPlaceholder: "admin.adplugin.house_ads.filter_placeholder",
|
filterPlaceholder: "admin.adplugin.house_ads.filter_placeholder",
|
||||||
tokenSeparator: "|",
|
tokenSeparator: "|",
|
||||||
allowCreate: false,
|
allowCreate: false,
|
||||||
allowAny: false,
|
allowAny: false,
|
||||||
settingValue: "",
|
settingValue: "",
|
||||||
|
valueAttribute: null,
|
||||||
|
nameProperty: null,
|
||||||
|
|
||||||
computeContent() {
|
value: computed("settingValue", function() {
|
||||||
return makeArray(this.get("choices"));
|
return this.settingValue
|
||||||
},
|
.toString()
|
||||||
|
.split(this.tokenSeparator)
|
||||||
|
.filter(Boolean);
|
||||||
|
}),
|
||||||
|
|
||||||
// called after a selection is made
|
// TODO: kept for legacy, remove when Discourse is 2.5
|
||||||
mutateValues(values) {
|
mutateValues(values) {
|
||||||
this.set("settingValue", values.join(this.get("tokenSeparator")));
|
this.set("settingValue", values.join(this.tokenSeparator));
|
||||||
|
},
|
||||||
|
computeValues() {
|
||||||
|
return this.settingValue.split(this.tokenSeparator).filter(Boolean);
|
||||||
},
|
},
|
||||||
|
|
||||||
// called when first rendered
|
content: computed("choices", function() {
|
||||||
computeValues() {
|
return makeArray(this.choices);
|
||||||
return this.get("settingValue")
|
}),
|
||||||
.split(this.get("tokenSeparator"))
|
|
||||||
.filter(c => c);
|
actions: {
|
||||||
|
onChange(value) {
|
||||||
|
const settingValue = makeArray(value).join(this.tokenSeparator);
|
||||||
|
this.attrs.onChange && this.attrs.onChange(settingValue);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
|
@ -1,5 +1,9 @@
|
||||||
<label for="{{name}}">{{title}}</label>
|
<label for="{{name}}">{{title}}</label>
|
||||||
{{house-ads-chooser settingValue=adValue choices=adNames}}
|
{{house-ads-chooser
|
||||||
|
settingValue=adValue
|
||||||
|
choices=adNames
|
||||||
|
onChange=(action (mut adValue))
|
||||||
|
}}
|
||||||
<div class='setting-controls'>
|
<div class='setting-controls'>
|
||||||
{{#if changed}}
|
{{#if changed}}
|
||||||
{{d-button class="ok" action=(action "save") icon="check"}}
|
{{d-button class="ok" action=(action "save") icon="check"}}
|
||||||
|
|
Loading…
Reference in New Issue