#7129 - fixFilters #559

Merged
pablone merged 6 commits from 7129-fixFilters into test 2024-07-22 16:00:14 +00:00
7 changed files with 150 additions and 50 deletions

View File

@ -177,7 +177,8 @@ function splitColumns(columns) {
if (col.create) splittedColumns.value.create.push(col); if (col.create) splittedColumns.value.create.push(col);
if (col.cardVisible) splittedColumns.value.cardVisible.push(col); if (col.cardVisible) splittedColumns.value.cardVisible.push(col);
if ($props.isEditable && col.disable == null) col.disable = false; if ($props.isEditable && col.disable == null) col.disable = false;
if ($props.useModel) col.columnFilter = { ...col.columnFilter, inWhere: true }; if ($props.useModel && col.columnFilter != false)
pablone marked this conversation as resolved
Review

usar comparación estricta !==

usar comparación estricta !==
col.columnFilter = { ...col.columnFilter, inWhere: true };
splittedColumns.value.columns.push(col); splittedColumns.value.columns.push(col);
} }
// Status column // Status column
@ -273,6 +274,10 @@ defineExpose({
:search-url="searchUrl" :search-url="searchUrl"
/> />
<VnTableOrder <VnTableOrder
v-if="
col?.columnFilter !== false &&
pablone marked this conversation as resolved Outdated

porque no poner el ! dentro del parentesis?

porque no poner el ! dentro del parentesis?
col?.name !== 'tableActions'
"
v-model="orders[col.name]" v-model="orders[col.name]"
:name="col.orderBy ?? col.name" :name="col.orderBy ?? col.name"
:data-key="$attrs['data-key']" :data-key="$attrs['data-key']"

View File

@ -3,7 +3,7 @@ import { onBeforeMount, onMounted, computed, ref } from 'vue';
import { useI18n } from 'vue-i18n'; import { useI18n } from 'vue-i18n';
import { Notify } from 'quasar'; import { Notify } from 'quasar';
import { useSession } from 'src/composables/useSession'; import { useSession } from 'src/composables/useSession';
import { toDate } from 'filters/index'; import { toDate, toDateHourMin } from 'filters/index';
import { useStateStore } from 'src/stores/useStateStore'; import { useStateStore } from 'src/stores/useStateStore';
import axios from 'axios'; import axios from 'axios';
@ -30,53 +30,69 @@ const columns = computed(() => [
isId: true, isId: true,
}, },
{ {
align: 'left', align: 'center',
name: 'hasCmrDms', name: 'hasCmrDms',
label: t('route.cmr.list.hasCmrDms'), label: t('route.cmr.list.hasCmrDms'),
component: 'checkbox', component: 'checkbox',
cardVisible: true, cardVisible: true,
}, },
{ {
align: 'left',
label: t('route.cmr.list.ticketFk'), label: t('route.cmr.list.ticketFk'),
name: 'ticketFk', name: 'ticketFk',
}, },
{ {
align: 'left',
label: t('route.cmr.list.routeFk'), label: t('route.cmr.list.routeFk'),
name: 'routeFk', name: 'routeFk',
}, },
{ {
align: 'left',
label: t('route.cmr.list.clientFk'), label: t('route.cmr.list.clientFk'),
name: 'clientFk', name: 'clientFk',
}, },
{ {
align: 'left', align: 'right',
label: t('route.cmr.list.country'), label: t('route.cmr.list.country'),
name: 'country', name: 'countryFk',
cardVisible: true, cardVisible: true,
},
{
align: 'center',
label: t('route.cmr.list.shipped'),
name: 'shipped',
cardVisible: true,
component: 'date',
columnFilter: {
alias: 'c',
inWhere: true,
},
format: ({ date }) => toDate(date),
},
{
align: 'center',
name: 'warehouseFk',
label: t('globals.warehouse'),
component: 'select',
attrs: { attrs: {
options: warehouses.value, url: 'countries',
fields: ['id', 'name'],
optionLabel: 'name',
optionValue: 'id',
}, },
columnFilter: {
inWhere: true,
component: 'select',
},
format: ({ countryName }) => countryName,
}, },
{ {
align: 'right', align: 'right',
label: t('route.cmr.list.shipped'),
name: 'shipped',
cardVisible: true,
columnFilter: {
component: 'date',
inWhere: true,
},
format: ({ shipped }) => toDateHourMin(shipped),
},
{
align: 'right',
name: 'warehouseFk',
label: t('globals.warehouse'),
columnFilter: {
component: 'select',
},
attrs: {
options: warehouses.value,
},
format: ({ warehouseName }) => warehouseName,
},
{
align: 'center',
name: 'tableActions', name: 'tableActions',
actions: [ actions: [
{ {
@ -153,7 +169,7 @@ function downloadPdfs() {
</template> </template>
pablone marked this conversation as resolved Outdated

porque no usas format dentro de la definición de la columna?

porque no usas format dentro de la definición de la columna?
<template #column-clientFk="{ row }"> <template #column-clientFk="{ row }">
<span class="link" @click.stop> <span class="link" @click.stop>
{{ row.ticketFk }} {{ row.clientFk }}
pablone marked this conversation as resolved
Review

porque no usas format dentro de la definición de la columna?

porque no usas format dentro de la definición de la columna?
<CustomerDescriptorProxy :id="row.clientFk" /> <CustomerDescriptorProxy :id="row.clientFk" />
</span> </span>
</template> </template>
pablone marked this conversation as resolved Outdated

porque no usas format dentro de la definición de la columna?

porque no usas format dentro de la definición de la columna?

View File

@ -36,23 +36,20 @@ const tableRef = ref();
const columns = computed(() => [ const columns = computed(() => [
{ {
align: 'left', align: 'left',
name: 'id', name: 'routeFk',
label: 'Id', label: 'Id',
chip: { chip: {
condition: () => true, condition: () => true,
}, },
isId: true, isId: true,
columnFilter: false,
}, },
{ {
align: 'left', align: 'left',
name: 'created', name: 'created',
label: t('Date'), label: t('Date'),
component: 'date', columnFilter: false,
columnFilter: { format: ({ created }) => toDate(created),
alias: 'c',
inWhere: true,
},
format: ({ date }) => toDate(date),
}, },
{ {
align: 'left', align: 'left',
@ -66,40 +63,63 @@ const columns = computed(() => [
label: t('Agency agreement'), label: t('Agency agreement'),
cardVisible: true, cardVisible: true,
}, },
{
align: 'left',
name: 'to',
label: t('To'),
visible: false,
cardVisible: true,
create: true,
component: 'date',
format: ({ date }) => toDate(date),
},
{
align: 'left',
name: 'from',
label: t('From'),
visible: false,
cardVisible: true,
create: true,
component: 'date',
format: ({ date }) => toDate(date),
},
{ {
align: 'left', align: 'left',
name: 'packages', name: 'packages',
label: t('Packages'), label: t('Packages'),
columnFilter: false,
}, },
{ {
align: 'left', align: 'left',
name: 'm3', name: 'm3',
label: 'm³', label: 'm³',
cardVisible: true, cardVisible: true,
columnFilter: { columnFilter: false,
inWhere: true,
},
}, },
{ {
align: 'left', align: 'left',
name: 'kmTotal', name: 'kmTotal',
label: t('Km'), label: t('Km'),
cardVisible: true, cardVisible: true,
columnFilter: false,
}, },
{ {
align: 'left', align: 'left',
name: 'price', name: 'price',
label: t('Price'), label: t('Price'),
columnFilter: false,
}, },
{ {
align: 'left', align: 'left',
name: 'invoiceInFk', name: 'invoiceInFk',
label: t('Received'), label: t('Received'),
columnFilter: false,
}, },
{ {
align: 'left', align: 'left',
name: 'supplierName', name: 'supplierName',
label: t('Autonomous'), label: t('Autonomous'),
columnFilter: false,
}, },
{ {
align: 'right', align: 'right',

View File

@ -24,7 +24,6 @@ const selectedRows = ref([]);
const tableRef = ref([]); const tableRef = ref([]);
const confirmationDialog = ref(false); const confirmationDialog = ref(false);
const startingDate = ref(null); const startingDate = ref(null);
const refreshKey = ref(0);
const router = useRouter(); const router = useRouter();
const routeFilter = { const routeFilter = {
include: [ include: [
@ -45,9 +44,7 @@ const columns = computed(() => [
condition: () => true, condition: () => true,
}, },
isId: true, isId: true,
columnFilter: { columnFilter: false,
name: 'search',
},
}, },
{ {
align: 'left', align: 'left',
@ -65,6 +62,9 @@ const columns = computed(() => [
label: 'workerUserName', label: 'workerUserName',
}, },
}, },
columnFilter: {
inWhere: true,
},
useLike: false, useLike: false,
cardVisible: true, cardVisible: true,
format: (row, dashIfEmpty) => dashIfEmpty(row.travelRef), format: (row, dashIfEmpty) => dashIfEmpty(row.travelRef),
@ -102,18 +102,38 @@ const columns = computed(() => [
label: 'vehiclePlateNumber', label: 'vehiclePlateNumber',
}, },
}, },
columnFilter: {
inWhere: true,
},
}, },
{ {
align: 'left', align: 'left',
name: 'created', name: 'created',
label: t('Date'), label: t('Date'),
columnFilter: false,
cardVisible: true,
create: true,
component: 'date',
format: ({ date }) => toDate(date),
},
{
align: 'left',
name: 'to',
label: t('To'),
visible: false,
cardVisible: true,
create: true,
component: 'date',
format: ({ date }) => toDate(date),
},
{
align: 'left',
name: 'from',
label: t('From'),
visible: false,
cardVisible: true, cardVisible: true,
create: true, create: true,
component: 'date', component: 'date',
columnFilter: {
alias: 'c',
inWhere: true,
},
format: ({ date }) => toDate(date), format: ({ date }) => toDate(date),
}, },
{ {
@ -136,18 +156,21 @@ const columns = computed(() => [
name: 'started', name: 'started',
label: t('hourStarted'), label: t('hourStarted'),
component: 'time', component: 'time',
columnFilter: false,
}, },
{ {
align: 'left', align: 'left',
name: 'finished', name: 'finished',
label: t('hourFinished'), label: t('hourFinished'),
component: 'time', component: 'time',
columnFilter: false,
}, },
{ {
align: 'left', align: 'left',
name: 'isOk', name: 'isOk',
label: t('Served'), label: t('Served'),
component: 'checkbox', component: 'checkbox',
columnFilter: false,
}, },
{ {
align: 'right', align: 'right',
@ -183,8 +206,8 @@ const cloneRoutes = () => {
created: startingDate.value, created: startingDate.value,
ids: selectedRows.value.map((row) => row?.id), ids: selectedRows.value.map((row) => row?.id),
}); });
tableRef.value.reload();
startingDate.value = null; startingDate.value = null;
tableRef.value.reload();
}; };
const showRouteReport = () => { const showRouteReport = () => {
@ -220,7 +243,7 @@ const openTicketsDialog = (id) => {
id, id,
}, },
}) })
.onOk(() => refreshKey.value++); .onOk(() => tableRef.value.reload());
}; };
</script> </script>
@ -249,6 +272,7 @@ const openTicketsDialog = (id) => {
</QDialog> </QDialog>
<VnSubToolbar /> <VnSubToolbar />
<VnTable <VnTable
class="route-list"
ref="tableRef" ref="tableRef"
data-key="RouteList" data-key="RouteList"
url="Routes/filter" url="Routes/filter"
@ -266,7 +290,6 @@ const openTicketsDialog = (id) => {
}" }"
save-url="Routes/crud" save-url="Routes/crud"
:disable-option="{ card: true }" :disable-option="{ card: true }"
:use-model="true"
table-height="85vh" table-height="85vh"
v-model:selected="selectedRows" v-model:selected="selectedRows"
:table="{ :table="{
@ -332,6 +355,8 @@ en:
hourStarted: Started hour hourStarted: Started hour
hourFinished: Finished hour hourFinished: Finished hour
es: es:
From: Desde
To: Hasta
Worker: Trabajador Worker: Trabajador
Agency: Agencia Agency: Agencia
Vehicle: Vehículo Vehicle: Vehículo

View File

@ -2,7 +2,7 @@
import { useI18n } from 'vue-i18n'; import { useI18n } from 'vue-i18n';
import { computed, ref } from 'vue'; import { computed, ref } from 'vue';
import { dashIfEmpty } from 'src/filters'; import { dashIfEmpty } from 'src/filters';
import { toDate } from 'filters/index'; import { toDate, toDateHourMin } from 'filters/index';
import { useQuasar } from 'quasar'; import { useQuasar } from 'quasar';
import { useSummaryDialog } from 'composables/useSummaryDialog'; import { useSummaryDialog } from 'composables/useSummaryDialog';
import toCurrency from 'filters/toCurrency'; import toCurrency from 'filters/toCurrency';
@ -43,10 +43,9 @@ const columns = computed(() => [
label: t('ETD'), label: t('ETD'),
component: 'date', component: 'date',
columnFilter: { columnFilter: {
alias: 'c',
inWhere: true, inWhere: true,
}, },
format: ({ date }) => toDate(date), format: ({ created }) => toDate(created),
cardVisible: true, cardVisible: true,
}, },
{ {
@ -200,6 +199,12 @@ function confirmRemove() {
}" }"
:disable-option="{ card: true }" :disable-option="{ card: true }"
> >
<template #column-etd="{ row }">
{{ toDateHourMin(row.etd) }}
</template>
<template #column-supplierFk="{ row }">
{{ row.supplierFk }}
</template>
<template #more-create-dialog="{ data }"> <template #more-create-dialog="{ data }">
<VnInputDate v-model="data.etd" /> <VnInputDate v-model="data.etd" />
<VnInputTime v-model="data.etd" /> <VnInputTime v-model="data.etd" />

View File

@ -0,0 +1,13 @@
describe('RoadMap', () => {
beforeEach(() => {
cy.viewport(1920, 1080);
cy.login('developer');
cy.visit(`/#/route/roadmap`);
});
it('Route list create roadmap and redirect', () => {
cy.get('.q-page-sticky > div > .q-btn > .q-btn__content > .q-icon').click();
cy.get('input[name="name"]').eq(1).type('roadMapTestOne{enter}');
cy.get('.q-notification__message').should('have.text', 'Data created');
cy.url().should('include', '/summary');
});
});

View File

@ -4,12 +4,28 @@ describe('Route', () => {
cy.login('developer'); cy.login('developer');
cy.visit(`/#/route/list`); cy.visit(`/#/route/list`);
}); });
const getVnSelect =
'> :nth-child(1) > .column > .q-field > .q-field__inner > .q-field__control > .q-field__control-container';
const getRowColumn = (row, column) => `:nth-child(${row}) > :nth-child(${column})`;
it('Route list create route', () => { it('Route list create route', () => {
cy.visit(`/#/route/list`);
cy.get('.q-page-sticky > div > .q-btn > .q-btn__content > .q-icon').click(); cy.get('.q-page-sticky > div > .q-btn > .q-btn__content > .q-icon').click();
cy.get('input[name="description"]').eq(1).type('routeTestOne{enter}'); cy.get('input[name="description"]').eq(1).type('routeTestOne{enter}');
cy.get('.q-notification__message').should('have.text', 'Data created'); cy.get('.q-notification__message').should('have.text', 'Data created');
cy.url().should('include', '/summary'); cy.url().should('include', '/summary');
}); });
it('Route list search and edit', () => {
cy.get('input[name="description"]').type('routeTestOne{enter}');
cy.get('.q-table tr')
.its('length')
.then((rowCount) => {
expect(rowCount).to.be.greaterThan(0);
});
cy.get(getRowColumn(1, 3) + getVnSelect).type('{downArrow}{enter}');
cy.get(getRowColumn(1, 4) + getVnSelect).type('{downArrow}{enter}');
cy.get(getRowColumn(1, 5) + getVnSelect).type('{downArrow}{enter}');
cy.get('button[title="Save"]').click();
cy.get('.q-notification__message').should('have.text', 'Data created');
});
}); });