From e77ac42673d65eb8edfea0f8ea65e9d433ad3d54 Mon Sep 17 00:00:00 2001 From: LrxGaelle Date: Fri, 13 Oct 2023 11:03:54 +0200 Subject: [PATCH] PATCH: Fix/search in components (#321) * add elementLabelKey to BIMDataDropdownList component * fix DropdownList documentation * fix search for object * fix search for object in BIMDataSelectMulti component * refactoring --- .../BIMDataDropdownList.vue | 10 ++ .../BIMDataSelect/BIMDataSelectMulti.vue | 23 ++- .../BIMDataSelect/BIMDataSelectSingle.vue | 23 ++- .../Components/DropdownList/DropdownList.vue | 137 +++++++----------- .../Components/DropdownList/events-data.js | 5 + .../Components/DropdownList/option-sets.js | 21 +++ .../Components/DropdownList/props-data.js | 57 ++++++++ .../Components/DropdownList/slots-data.js | 10 ++ 8 files changed, 192 insertions(+), 94 deletions(-) create mode 100644 src/web/views/Components/DropdownList/events-data.js create mode 100644 src/web/views/Components/DropdownList/option-sets.js create mode 100644 src/web/views/Components/DropdownList/props-data.js create mode 100644 src/web/views/Components/DropdownList/slots-data.js diff --git a/src/BIMDataComponents/BIMDataDropdownList/BIMDataDropdownList.vue b/src/BIMDataComponents/BIMDataDropdownList/BIMDataDropdownList.vue index df285faa..a5de355b 100644 --- a/src/BIMDataComponents/BIMDataDropdownList/BIMDataDropdownList.vue +++ b/src/BIMDataComponents/BIMDataDropdownList/BIMDataDropdownList.vue @@ -90,6 +90,9 @@ export default { elementKey: { type: String, }, + elementLabelKey: { + type: String, + }, disabled: { type: Boolean, default: false, @@ -152,6 +155,13 @@ export default { return this.list; } else { const lowerCaseSearchText = this.searchText.toLowerCase(); + if (this.elementLabelKey) { + return this.list.filter(element => + element[this.elementLabelKey] + .toLowerCase() + .includes(lowerCaseSearchText), + ); + } return this.list.filter(element => element.toLowerCase().includes(lowerCaseSearchText), ); diff --git a/src/BIMDataComponents/BIMDataSelect/BIMDataSelectMulti.vue b/src/BIMDataComponents/BIMDataSelect/BIMDataSelectMulti.vue index 443f1a68..1c334bc8 100644 --- a/src/BIMDataComponents/BIMDataSelect/BIMDataSelectMulti.vue +++ b/src/BIMDataComponents/BIMDataSelect/BIMDataSelectMulti.vue @@ -137,9 +137,26 @@ export default { return this.options; } else { const lowerCaseSearchText = this.searchText.toLowerCase(); - return this.options.filter(option => - option.toLowerCase().includes(lowerCaseSearchText), - ); + if (this.optionLabelKey) { + return this.options.filter(option => + option[this.optionLabelKey] + .toLowerCase() + .includes(lowerCaseSearchText), + ); + } + if (this.optionKey) { + return this.options.filter( + option => + option.optionGroup || + option[this.optionKey] + .toLowerCase() + .includes(lowerCaseSearchText), + ); + } else { + return this.options.filter(option => + option.toLowerCase().includes(lowerCaseSearchText), + ); + } } }, }, diff --git a/src/BIMDataComponents/BIMDataSelect/BIMDataSelectSingle.vue b/src/BIMDataComponents/BIMDataSelect/BIMDataSelectSingle.vue index 681a8b47..d0c93f50 100644 --- a/src/BIMDataComponents/BIMDataSelect/BIMDataSelectSingle.vue +++ b/src/BIMDataComponents/BIMDataSelect/BIMDataSelectSingle.vue @@ -138,9 +138,26 @@ export default { return this.options; } else { const lowerCaseSearchText = this.searchText.toLowerCase(); - return this.options.filter(option => - option.toLowerCase().includes(lowerCaseSearchText), - ); + if (this.optionLabelKey) { + return this.options.filter(option => + option[this.optionLabelKey] + .toLowerCase() + .includes(lowerCaseSearchText), + ); + } + if (this.optionKey) { + return this.options.filter( + option => + option.optionGroup || + option[this.optionKey] + .toLowerCase() + .includes(lowerCaseSearchText), + ); + } else { + return this.options.filter(option => + option.toLowerCase().includes(lowerCaseSearchText), + ); + } } }, }, diff --git a/src/web/views/Components/DropdownList/DropdownList.vue b/src/web/views/Components/DropdownList/DropdownList.vue index 284cb2a7..3b6d6cfc 100644 --- a/src/web/views/Components/DropdownList/DropdownList.vue +++ b/src/web/views/Components/DropdownList/DropdownList.vue @@ -18,6 +18,7 @@ :closeOnElementClick="checkboxCloseOnElementClickChecked" @element-click="onItemClick" :search="checkboxSearchChecked" + :elementLabelKey="elementLabelKey" > @@ -77,6 +79,14 @@ placeholder="Number of items per page" type="number" > +
+ +
Events: - +