From 1c7ad7946e2ea468b0f0bcd3a7e34e1c503d6b0e Mon Sep 17 00:00:00 2001 From: Javier Segarra Date: Fri, 2 Feb 2024 14:41:59 +0100 Subject: [PATCH] refs #5888 feat: change layout --- src/components/common/VnLocation.vue | 25 ++++--- test/cypress/integration/VnLocation.spec.js | 81 +++++++++++++++------ 2 files changed, 72 insertions(+), 34 deletions(-) diff --git a/src/components/common/VnLocation.vue b/src/components/common/VnLocation.vue index 0b30faaa7..7e42d4b85 100644 --- a/src/components/common/VnLocation.vue +++ b/src/components/common/VnLocation.vue @@ -55,7 +55,7 @@ const value = computed({ }); onMounted(() => { - locationFilter() + locationFilter($props.modelValue); }); function setOptions(data) { @@ -69,34 +69,39 @@ watch(options, (newValue) => { }); function showLabel(data) { - return `${data.code} - ${data.town}(${data.province}), ${data.country}`; + return `${data.code} - ${data.town}(${data.province}), ${data.country}`; } -function locationFilter(search) { +function locationFilter(search = '') { + if ( + search && + (search.includes('undefined') || search.startsWith(`${$props.modelValue} - `)) + ) + return; let where = { search }; - postcodesRef.value.fetch({filter:{ where}, limit: 30}); + postcodesRef.value.fetch({ filter: { where }, limit: 30 }); } -function handleFetch( data) { +function handleFetch(data) { postcodesOptions.value = data; } - -