refs #6694 VnLocation #154

Merged
jsegarra merged 31 commits from 6280_vnLocation into dev 2024-01-29 13:23:04 +00:00
2 changed files with 5 additions and 55 deletions
Showing only changes of commit 4b3ca3bbd9 - Show all commits

View File

@ -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"
/>
<!-- @input-value="filter"
:default-filter="false" -->
<VnSelectCreate
v-model="value"
jsegarra marked this conversation as resolved Outdated
Outdated
Review

Igual se lo pondria mas alto, ver como esta en salix

Igual se lo pondria mas alto, ver como esta en salix

Corregido 6809e9bddb

Corregido 6809e9bddb37ba812c3e56a8f62f3beb255a051d
:options="postcodesOptions"
:label="t('Location')"
option-label="code"
option-value="geoFk"
:option-label="showLabel"
:placeholder="t('Min. 3 char')"
v-bind="$attrs"
emit-value
map-options
use-input
:filter-options="['code','town.name']"
jsegarra marked this conversation as resolved Outdated
Outdated
Review

Com veus esta part? @jgallego
Es una reglat de filtrat que t'obliga a escriure al menys 3 caracters per a que te filtre.
No ho acabe de vore. Pq si per exemple lo que volen es filtrar per pais pq hi ha un pais q saben q soles tenen 1 codi postal o molt pocs. i fiquen per exemple "J" (pq estan buscant Japon). no els trauria res

Com veus esta part? @jgallego Es una reglat de filtrat que t'obliga a escriure al menys 3 caracters per a que te filtre. No ho acabe de vore. Pq si per exemple lo que volen es filtrar per pais pq hi ha un pais q saben q soles tenen 1 codi postal o molt pocs. i fiquen per exemple "J" (pq estan buscant Japon). no els trauria res

Si la consulta no es muy lenta/pesada yo no pondria nada.

Si la consulta no es muy lenta/pesada yo no pondria nada.

Es una reglat de filtrat que t'obliga a escriure al menys 3 caracters per a que te filtre.
No ho acabe de vore. Pq si per exemple lo que volen es filtrar per pais pq hi ha un pais q saben q soles tenen 1 codi postal o molt pocs. i fiquen per exemple "J" (pq estan buscant Japon). no els trauria res

Lo comentamos.

> Es una reglat de filtrat que t'obliga a escriure al menys 3 caracters per a que te filtre. > No ho acabe de vore. Pq si per exemple lo que volen es filtrar per pais pq hi ha un pais q saben q soles tenen 1 codi postal o molt pocs. i fiquen per exemple "J" (pq estan buscant Japon). no els trauria res > Lo comentamos.
:filter-rules="['val.length>2',{code:'.length > 2'}]"
:filter-rules="['val.length>2']"
clearable
hide-selected
jsegarra marked this conversation as resolved Outdated
Outdated
Review

Si al final se fa la peticio en la back li possaria un delay (input-bounce) crec que se dia

Si al final se fa la peticio en la back li possaria un delay (input-bounce) crec que se dia

Lo comentamos

Lo comentamos

corregido 655c821075

corregido 655c8210751f819ad4aff1480f94e57f73e22931
fill-input

View File

@ -72,7 +72,6 @@ const filter = (val, options) => {
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);
});
}