FIX: update minimum required tag when switching categories in composer

This commit is contained in:
Penar Musaraj 2020-06-08 17:10:26 -04:00
parent fbeaba4acf
commit c5b1f028ed
No known key found for this signature in database
GPG Key ID: E390435D881FF0F7
2 changed files with 27 additions and 22 deletions

View File

@ -10,7 +10,6 @@ const SELECTED_TAGS_COLLECTION = "MINI_TAG_CHOOSER_SELECTED_TAGS";
import { ERRORS_COLLECTION } from "select-kit/components/select-kit";
export default ComboBox.extend(TagsMixin, {
headerComponent: "mini-tag-chooser/mini-tag-chooser-header",
pluginApiIdentifiers: ["mini-tag-chooser"],
attributeBindings: ["selectKit.options.categoryId:category-id"],
classNames: ["mini-tag-chooser"],
@ -31,6 +30,7 @@ export default ComboBox.extend(TagsMixin, {
),
selectKitOptions: {
headerComponent: "mini-tag-chooser/mini-tag-chooser-header",
fullWidthOnMobile: true,
filterable: true,
caretDownIcon: "caretIcon",

View File

@ -12,31 +12,36 @@ export default SelectKitComponent.extend({
headerComponent: "select-kit/single-select-header"
},
selectedContent: computed("value", "content.[]", function() {
if (!isEmpty(this.value)) {
let content;
selectedContent: computed(
"value",
"content.[]",
"selectKit.noneItem",
function() {
if (!isEmpty(this.value)) {
let content;
const value =
this.selectKit.options.castInteger && this._isNumeric(this.value)
? Number(this.value)
: this.value;
const value =
this.selectKit.options.castInteger && this._isNumeric(this.value)
? Number(this.value)
: this.value;
if (this.selectKit.valueProperty) {
content = (this.content || []).findBy(
this.selectKit.valueProperty,
value
);
if (this.selectKit.valueProperty) {
content = (this.content || []).findBy(
this.selectKit.valueProperty,
value
);
return this.selectKit.modifySelection(
content || this.defaultItem(value, value)
);
return this.selectKit.modifySelection(
content || this.defaultItem(value, value)
);
} else {
return this.selectKit.modifySelection(
(this.content || []).filter(c => c === value)
);
}
} else {
return this.selectKit.modifySelection(
(this.content || []).filter(c => c === value)
);
return this.selectKit.noneItem;
}
} else {
return this.selectKit.noneItem;
}
})
)
});