From 92e914adad91920e5dda00dcf05fba90696a423f Mon Sep 17 00:00:00 2001 From: alexm Date: Tue, 1 Aug 2023 15:17:48 +0200 Subject: [PATCH] refs #5673 feat(formModel): global qselect filter --- src/components/FormModel.vue | 4 +-- src/pages/Claim/Card/ClaimDevelopment.vue | 37 ++++++++++++++++++++--- 2 files changed, 34 insertions(+), 7 deletions(-) diff --git a/src/components/FormModel.vue b/src/components/FormModel.vue index 0d5f75ec1..0b22dd3b7 100644 --- a/src/components/FormModel.vue +++ b/src/components/FormModel.vue @@ -99,9 +99,9 @@ function reset() { function filter(value, update, filterOptions) { update( () => { - const { options, filterFn } = filterOptions; + const { options, filterFn, field } = filterOptions; - options.value = filterFn(options, value); + options.value = filterFn(options, value, field); }, (ref) => { ref.setOptionIndex(-1); diff --git a/src/pages/Claim/Card/ClaimDevelopment.vue b/src/pages/Claim/Card/ClaimDevelopment.vue index a4a8dccd4..774ecff01 100644 --- a/src/pages/Claim/Card/ClaimDevelopment.vue +++ b/src/pages/Claim/Card/ClaimDevelopment.vue @@ -102,10 +102,34 @@ const columns = computed(() => [ // }); // } -const basicFilter = (options) => { +// const basicFilter = () => { +// return { +// options: claimReasons, +// filterFn: (options, value) => { +// console.log('ENTRY', value); +// const search = value.toLowerCase(); +// if (value === '') return claimReasons.value; + +// const arr = options.value.filter((row) => { +// const id = row.id; +// const name = row.description.toLowerCase(); +// console.log('SEARCH', search, id); +// const idMatches = id == search; +// const nameMatches = name.indexOf(search) > -1; +// return idMatches || nameMatches; +// }); +// console.log(arr); +// return arr; +// }, +// }; +// }; + +const basicFilter = (options, field) => { + console.log(options, field); return { options, - filterFn: (options, value) => { + field, + filterFn: (options, value, field) => { const search = value.toLowerCase(); if (value === '') return options; @@ -113,7 +137,7 @@ const basicFilter = (options) => { return options.value.filter((row) => { console.log(row); const id = row.id; - const name = row.name.toLowerCase(); + const name = row[field ?? 'name'].toLowerCase(); const idMatches = id == search; const nameMatches = name.indexOf(search) > -1; @@ -192,7 +216,7 @@ const basicFilter = (options) => { filter( value, update, - basicFilter(col.options) + basicFilter(col.options, col.optionLabel) ) " /> @@ -223,7 +247,10 @@ const basicFilter = (options) => { filter( value, update, - basicFilter(col.options) + basicFilter( + col.options, + col.optionLabel + ) ) " />