#7136 - Enable paginate event in VnSelectFilter #255

Closed
jsegarra wants to merge 86 commits from 7136_vnselectFilter_paginate into dev
1 changed files with 5 additions and 7 deletions
Showing only changes of commit e775d922e8 - Show all commits

View File

@ -103,14 +103,13 @@ const arrayData = useURL.value
: ref(null); : ref(null);
onMounted(async () => { onMounted(async () => {
setOptions(options.value); setOptions(options.value);
if (!$props.options) fetchFilter($props.modelValue);
jsegarra marked this conversation as resolved Outdated
Outdated
Review

De primeras diria que esta linea no hace falta, dado que la primera ja lo hace

De primeras diria que esta linea no hace falta, dado que la primera ja lo hace

Pero quiero evitar que haga fetch
Un caso de uso sería: se lo declaro en el componente o una variable

Pero quiero evitar que haga fetch Un caso de uso sería: se lo declaro en el componente o una variable
Outdated
Review

updateRouter: false sino podrá cosas en la url

`updateRouter: false` sino podrá cosas en la url
if (useURL.value) { if (useURL.value) {
Outdated
Review

Esta parte solo debe hacerla si hay url. Y por como esta ahora ya habria hecho la peticion al entrar en if (useURL.value)

Esta parte solo debe hacerla si hay url. Y por como esta ahora ya habria hecho la peticion al entrar en `if (useURL.value)`

Lo cambio para dejarlo asi
if (!$props.options) fetchFilter($props.modelValue);

Lo cambio para dejarlo asi if (!$props.options) fetchFilter($props.modelValue);
arrayData.store.userFilter = $props.where; arrayData.store.userFilter = $props.where;
arrayData.store.filter.where = $props.where; arrayData.store.filter.where = $props.where;
const { data } = await arrayData.fetch({ append: true }); const { data } = await arrayData.fetch({ append: true });
setOptions(data); setOptions(data);
return;
} }
if (!$props.options) fetchFilter($props.modelValue);
}); });
watch(modelValue, (newValue) => { watch(modelValue, (newValue) => {
@ -125,7 +124,7 @@ function filter(val, options) {
Outdated
Review

El useLike no me lo quites pls

El useLike no me lo quites pls

hecho

hecho
if (!search) return options; if (!search) return options;
const optionsFiltered = options.filter((row) => { return options.filter((row) => {
if ($props.filterOptions.length) { if ($props.filterOptions.length) {
return $props.filterOptions.some((prop) => { return $props.filterOptions.some((prop) => {
const propValue = String(row[prop]).toLowerCase(); const propValue = String(row[prop]).toLowerCase();
@ -138,16 +137,15 @@ function filter(val, options) {
return id == search || optionLabel.includes(search); return id == search || optionLabel.includes(search);
}); });
return optionsFiltered;
} }
async function fetchFilter(val) { async function fetchFilter(val) {
if (!useURL.value || !dataRef.value) return; if (!useURL.value || !dataRef.value) return;
const { fields, sortBy, limit } = $props; const { fields, sortBy, limit } = $props;
let key = null; let key = new RegExp(/\d/g).test(val)
if (new RegExp(/\d/g).test(val)) key = optionFilter.value ?? optionValue.value; ? optionFilter.value ?? optionValue.value
jsegarra marked this conversation as resolved Outdated
Outdated
Review

Por como esta useArrayData, fetch no acepta los datos por paramtros. Solo { append = false, updateRouter = true }

Por como esta useArrayData, fetch no acepta los datos por paramtros. Solo `{ append = false, updateRouter = true }`
: optionValue.value;
const where = { ...{ [key]: { like: `%${val}%` } }, ...$props.where }; const where = { ...{ [key]: { like: `%${val}%` } }, ...$props.where };
return dataRef.value.fetch({ fields, where, order: sortBy, limit }); return dataRef.value.fetch({ fields, where, order: sortBy, limit });
Outdated
Review

Si de por si solo entra en fetchFilter si hay url, no hace falta separar la construccion del where en una funcion apart, que solo se usa en un sitio

Si de por si solo entra en fetchFilter si hay url, no hace falta separar la construccion del where en una funcion apart, que solo se usa en un sitio

Vale, lo debí separar para otra situación que acabé borrando y esto se quedó así
Lo limipio

Vale, lo debí separar para otra situación que acabé borrando y esto se quedó así Lo limipio