FEATURE: ability to add all active components to theme (#8447)

* FEATURE: ability to add all active components to theme

* FIX: add a component to all themes takes only active ones

* FIX: move select components/themes to top

* FIX: improve defaultIsAvailable

* FIX: Add filter(Boolean) and remove btn class
This commit is contained in:
Krzysztof Kotlarek
2019-12-04 17:13:41 +11:00
committed by GitHub
parent 46fc45de99
commit bb69e8942e
7 changed files with 118 additions and 81 deletions

View File

@ -100,6 +100,28 @@ export default Mixin.create({
return settingDefault !== bufferedValue;
},
@discourseComputed("buffered.value")
bufferedValues(bufferedValuesString) {
return (
bufferedValuesString && bufferedValuesString.split("|").filter(Boolean)
);
},
@discourseComputed("setting.defaultValues")
defaultValues(defaultValuesString) {
return (
defaultValuesString && defaultValuesString.split("|").filter(Boolean)
);
},
@discourseComputed("defaultValues", "bufferedValues")
defaultIsAvailable(defaultValues, bufferedValues) {
return (
defaultValues &&
!defaultValues.every(value => bufferedValues.includes(value))
);
},
_watchEnterKey: on("didInsertElement", function() {
$(this.element).on("keydown.setting-enter", ".input-setting-string", e => {
if (e.keyCode === 13) {
@ -216,7 +238,13 @@ export default Mixin.create({
},
setDefaultValues() {
this.set("buffered.value", this.get("setting.defaultValues"));
this.set(
"buffered.value",
this.bufferedValues
.concat(this.defaultValues)
.uniq()
.join("|")
);
}
}
});