6825-fix_vnSelectCache_and_autoload #557

Merged
alexm merged 2 commits from 6825-fix_vnSelectCache_and_autoload into test 2024-07-19 06:01:57 +00:00
5 changed files with 49 additions and 25 deletions
Showing only changes of commit f8026dd3f6 - Show all commits

View File

@ -48,6 +48,17 @@ const forceAttrs = {
label: $props.showTitle ? '' : $props.column.label, label: $props.showTitle ? '' : $props.column.label,
}; };
const selectComponent = {
component: markRaw(VnSelect),
event: updateEvent,
attrs: {
class: 'q-px-sm q-pb-xs q-pt-none fit',
alexm marked this conversation as resolved
Review

Molaria dejar hueco a customizacion, poniendo $props.componentClass antes

Molaria dejar hueco a customizacion, poniendo $props.componentClass antes
dense: true,
filled: !$props.showTitle,
},
forceAttrs,
};
const components = { const components = {
input: { input: {
component: markRaw(VnInput), component: markRaw(VnInput),
@ -97,16 +108,8 @@ const components = {
}, },
forceAttrs, forceAttrs,
}, },
select: { select: selectComponent,
Review

en la rama dev, en VnColumn, tenemos select: VnSelectCache y rawSelect: VnSelect, ya me dices si es correcto

en la rama dev, en VnColumn, tenemos select: VnSelectCache y rawSelect: VnSelect, ya me dices si es correcto
Review

En los filtros no tienes un valor cargado por defecto, entonces VnSelectCache no hace falta

En los filtros no tienes un valor cargado por defecto, entonces VnSelectCache no hace falta
component: markRaw(VnSelect), rawSelect: selectComponent,
event: updateEvent,
attrs: {
class: 'q-px-sm q-pb-xs q-pt-none fit',
dense: true,
filled: !$props.showTitle,
},
forceAttrs,
},
}; };
async function addFilter(value) { async function addFilter(value) {

View File

@ -125,7 +125,8 @@ function filter(val, options) {
}); });
} }
const id = row.id; if (!row) return;
const id = row[$props.optionValue];
const optionLabel = String(row[$props.optionLabel]).toLowerCase(); const optionLabel = String(row[$props.optionLabel]).toLowerCase();
return id == search || optionLabel.includes(search); return id == search || optionLabel.includes(search);

View File

@ -8,18 +8,31 @@ const $props = defineProps({
default: null, default: null,
}, },
find: { find: {
type: String, type: [String, Object],
default: null, default: null,
}, },
}); });
const options = ref([]); const options = ref([]);
onBeforeMount(async () => { onBeforeMount(async () => {
const { url } = useAttrs(); const { url, optionValue, optionLabel } = useAttrs();
const findBy = $props.find ?? url?.charAt(0)?.toLocaleLowerCase() + url?.slice(1, -1); const findBy = $props.find ?? url?.charAt(0)?.toLocaleLowerCase() + url?.slice(1, -1);
if (findBy) options.value = [$props.row[findBy]]; if (!findBy || !$props.row) return;
// is object
if (typeof findBy == 'object') {
const { value, label } = findBy;
if (!$props.row[value] || !$props.row[label]) return;
return (options.value = [
{
[optionValue ?? 'id']: $props.row[value],
[optionLabel ?? 'name']: $props.row[label],
},
]);
}
// is string
if ($props.row[findBy]) options.value = [$props.row[findBy]];
}); });
</script> </script>
<template> <template>
<VnSelect v-bind="$attrs" :options="$attrs.options ?? options" /> <VnSelect v-bind="$attrs" :options="$attrs.options ?? options" />
</template> </template>

View File

@ -72,10 +72,7 @@ const columns = computed(() => [
label: t('globals.warehouse'), label: t('globals.warehouse'),
component: 'select', component: 'select',
attrs: { attrs: {
url: 'warehouses', options: warehouses.value,
fields: ['id', 'name'],
optionLabel: 'name',
optionValue: 'id',
}, },
}, },
{ {

View File

@ -57,9 +57,13 @@ const columns = computed(() => [
component: 'select', component: 'select',
attrs: { attrs: {
url: 'Workers/activeWithInheritedRole', url: 'Workers/activeWithInheritedRole',
fields: ['id', 'nickname'], fields: ['id', 'name'],
optionValue: 'id', useLike: false,
optionLabel: 'nickname', optionFilter: 'firstName',
find: {
value: 'workerFk',
label: 'workerUserName',
},
}, },
useLike: false, useLike: false,
cardVisible: true, cardVisible: true,
@ -76,8 +80,10 @@ const columns = computed(() => [
attrs: { attrs: {
url: 'agencyModes', url: 'agencyModes',
fields: ['id', 'name'], fields: ['id', 'name'],
optionLabel: 'name', find: {
optionValue: 'id', value: 'agencyModeFk',
label: 'agencyName',
},
}, },
}, },
{ {
@ -91,7 +97,10 @@ const columns = computed(() => [
url: 'vehicles', url: 'vehicles',
fields: ['id', 'numberPlate'], fields: ['id', 'numberPlate'],
optionLabel: 'numberPlate', optionLabel: 'numberPlate',
optionValue: 'id', find: {
value: 'vehicleFk',
label: 'vehiclePlateNumber',
},
}, },
}, },
{ {
@ -248,6 +257,7 @@ const openTicketsDialog = (id) => {
:is-editable="true" :is-editable="true"
:filter="routeFilter" :filter="routeFilter"
redirect="route" redirect="route"
:row-click="false"
:create="{ :create="{
urlCreate: 'Routes', urlCreate: 'Routes',
title: t('Create route'), title: t('Create route'),