From 4b3ca3bbd97872f8c8935f0ec30ee3d442f14788 Mon Sep 17 00:00:00 2001 From: Javier Segarra Date: Fri, 12 Jan 2024 11:27:54 +0100 Subject: [PATCH] refs #6280 feat: return geoFk VnLocation --- src/components/common/VnLocation.vue | 51 +++--------------------- src/components/common/VnSelectFilter.vue | 9 ----- 2 files changed, 5 insertions(+), 55 deletions(-) diff --git a/src/components/common/VnLocation.vue b/src/components/common/VnLocation.vue index 3a296e168..5c41144ac 100644 --- a/src/components/common/VnLocation.vue +++ b/src/components/common/VnLocation.vue @@ -2,7 +2,6 @@ import { ref, toRefs, computed, watch } from 'vue'; import CreateNewPostcode from 'src/components/CreateNewPostcodeForm.vue'; import VnSelectCreate from 'components/common/VnSelectCreate.vue'; -import VnSelectFilter from 'components/common/VnSelectFilter.vue'; import FetchData from 'components/FetchData.vue'; const emit = defineEmits(['update:modelValue', 'update:options']); import { useI18n } from 'vue-i18n'; @@ -44,14 +43,10 @@ const $props = defineProps({ default: true, }, }); -const locationsRef = ref(); -const locationsRefFilter = ref({ fields: ['code', 'nickname'], limit: 30 }); -const { optionLabel, optionValue, options } = toRefs($props); +const { options } = toRefs($props); const myOptions = ref([]); const myOptionsOriginal = ref([]); -const vnSelectRef = ref(); -const showForm = ref(false); const value = computed({ get() { @@ -67,42 +62,6 @@ function setOptions(data) { myOptionsOriginal.value = JSON.parse(JSON.stringify(data)); } setOptions(options.value); -const filter = (val, options) => { - const search = val.toString().toLowerCase(); - - if (!search) return options; - // if (!search.length < 2) return options; - - return options -}; - -const filterHandler = (val, update) => { - update( - () => { - // if (val.length>2) - myOptions.value = filter(val, myOptionsOriginal.value); - }, - (ref) => { - if (val !== '' && ref.options.length > 0) { - ref.setOptionIndex(-1); - ref.moveOptionSelection(1, true); - } - } - ); -}; - -function locationFilter(val) { - let where = { limit: 30 }; - let params = {}; - let key = 'nickname'; - - if (new RegExp(/\d/g).test(val)) { - key = 'id'; - } - params = { [key]: { like: `%${val}%` } }; - where = Object.assign(where, params); - locationsRef.value.fetch({ where }); -} watch(options, (newValue) => { setOptions(newValue); }); @@ -135,19 +94,19 @@ function showLabel(data){ auto-load url="Countries" /> - { if (!search) return options; if($props.filterRules.length) { const passSomeRule = $props.filterRules.some((rule) => { - if(typeof rule === 'object') return true const cond = eval(rule) return cond; }); @@ -82,15 +81,7 @@ const filter = (val, options) => { return options.filter((row) => { if ($props.filterOptions.length) { return $props.filterOptions.some((prop) => { - const passRules = $props.filterRules - .filter(rule=>typeof rule === 'object') - .every(rule=>{ - const propExists = Object.keys(rule).includes(prop); - if(!propExists) return false; - return eval(prop.concat(rule[prop])) - }); const propValue = String(deepFind(row,prop)).toLowerCase(); - if(passRules) return propValue.includes(search); }); }