From 0cb925abc36d8c9e62ebdb8074cd2391922cb9f5 Mon Sep 17 00:00:00 2001 From: alexm Date: Wed, 2 Aug 2023 15:15:23 +0200 Subject: [PATCH] refs #5673 feat: create VnSelectFilter --- src/components/common/VnSelectFilter.vue | 58 +++++++++++ src/pages/Claim/Card/ClaimCard.vue | 1 + src/pages/Claim/Card/ClaimDevelopment.vue | 111 +++------------------- 3 files changed, 74 insertions(+), 96 deletions(-) create mode 100644 src/components/common/VnSelectFilter.vue diff --git a/src/components/common/VnSelectFilter.vue b/src/components/common/VnSelectFilter.vue new file mode 100644 index 000000000..61566f777 --- /dev/null +++ b/src/components/common/VnSelectFilter.vue @@ -0,0 +1,58 @@ + + + diff --git a/src/pages/Claim/Card/ClaimCard.vue b/src/pages/Claim/Card/ClaimCard.vue index 2b6e275f9..b77f95d38 100644 --- a/src/pages/Claim/Card/ClaimCard.vue +++ b/src/pages/Claim/Card/ClaimCard.vue @@ -64,6 +64,7 @@ onMounted(async () => { +
diff --git a/src/pages/Claim/Card/ClaimDevelopment.vue b/src/pages/Claim/Card/ClaimDevelopment.vue index 774ecff01..ace7b3e4d 100644 --- a/src/pages/Claim/Card/ClaimDevelopment.vue +++ b/src/pages/Claim/Card/ClaimDevelopment.vue @@ -4,6 +4,7 @@ import { useI18n } from 'vue-i18n'; import { useRoute } from 'vue-router'; import FormModel from 'components/FormModel.vue'; import FetchData from 'components/FetchData.vue'; +import VnSelectFilter from 'components/common/VnSelectFilter.vue'; const route = useRoute(); const { t } = useI18n(); @@ -87,66 +88,6 @@ const columns = computed(() => [ optionLabel: 'description', }, ]); - -// function filterFn(val, update) { -// if (val === '') { -// update(() => { -// options.value = stringOptions; -// }); -// return; -// } - -// update(() => { -// const needle = val.toLowerCase(); -// options.value = stringOptions.filter((v) => v.toLowerCase().indexOf(needle) > -1); -// }); -// } - -// 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, - field, - filterFn: (options, value, field) => { - const search = value.toLowerCase(); - - if (value === '') return options; - - return options.value.filter((row) => { - console.log(row); - const id = row.id; - const name = row[field ?? 'name'].toLowerCase(); - - const idMatches = id == search; - const nameMatches = name.indexOf(search) > -1; - - return idMatches || nameMatches; - }); - }, - }; -};