DEV: Fix category-selector's searching (#24023)
This commit is contained in:
parent
7b6e32c238
commit
a6b570681b
|
@ -54,20 +54,27 @@ export default MultiSelectComponent.extend({
|
|||
},
|
||||
|
||||
async search(filter) {
|
||||
return this.siteSettings.lazy_load_categories
|
||||
? await Category.asyncSearch(filter, {
|
||||
includeUncategorized:
|
||||
this.attrs.options?.allowUncategorized !== undefined
|
||||
? this.attrs.options.allowUncategorized
|
||||
: this.selectKit.options.allowUncategorized,
|
||||
selectCategoryIds: this.categories
|
||||
? this.categories.map((x) => x.id)
|
||||
: null,
|
||||
rejectCategoryIds: this.blockedCategories
|
||||
? this.blockedCategories.map((x) => x.id)
|
||||
: null,
|
||||
})
|
||||
: this._super(filter);
|
||||
if (!this.siteSettings.lazy_load_categories) {
|
||||
return this._super(filter);
|
||||
}
|
||||
|
||||
const rejectCategoryIds = new Set();
|
||||
// Reject selected options
|
||||
if (this.categories) {
|
||||
this.categories.forEach((c) => rejectCategoryIds.add(c.id));
|
||||
}
|
||||
// Reject blocked categories
|
||||
if (this.blockedCategories) {
|
||||
this.blockedCategories.forEach((c) => rejectCategoryIds.add(c.id));
|
||||
}
|
||||
|
||||
return await Category.asyncSearch(filter, {
|
||||
includeUncategorized:
|
||||
this.attrs.options?.allowUncategorized !== undefined
|
||||
? this.attrs.options.allowUncategorized
|
||||
: this.selectKit.options.allowUncategorized,
|
||||
rejectCategoryIds: Array.from(rejectCategoryIds),
|
||||
});
|
||||
},
|
||||
|
||||
select(value, item) {
|
||||
|
|
Loading…
Reference in New Issue