perf: rename prop
This commit is contained in:
parent
89673b05db
commit
f62f72832a
|
@ -61,9 +61,12 @@ const $props = defineProps({
|
||||||
type: Object,
|
type: Object,
|
||||||
default: null,
|
default: null,
|
||||||
},
|
},
|
||||||
useSearchbar: {
|
searchbarOptions: {
|
||||||
type: [Boolean, Function],
|
type: Object,
|
||||||
default: false,
|
default: () => ({
|
||||||
|
use: false,
|
||||||
|
validateFn: null,
|
||||||
|
}),
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -99,17 +102,17 @@ defineExpose({ search, params: userParams, remove });
|
||||||
|
|
||||||
async function search(evt) {
|
async function search(evt) {
|
||||||
try {
|
try {
|
||||||
if ($props.useSearchbar) {
|
if ($props.searchbarOptions.use) {
|
||||||
if (!searchbar.value) {
|
if (!searchbar.value) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (typeof $props.useSearchbar === 'function') {
|
if (typeof $props.searchbarOptions.validateFn === 'function') {
|
||||||
$props.useSearchbar(userParams.value);
|
$props.searchbarOptions.validateFn(userParams.value);
|
||||||
|
}
|
||||||
|
|
||||||
if (!Object.keys(userParams.value).length) {
|
if (!Object.keys(userParams.value).length) {
|
||||||
searchbar.value();
|
searchbar.value();
|
||||||
return;
|
return;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (evt && $props.disableSubmitEvent) return;
|
if (evt && $props.disableSubmitEvent) return;
|
||||||
|
|
|
@ -76,7 +76,7 @@ function validateDateRange(params) {
|
||||||
<VnFilterPanel
|
<VnFilterPanel
|
||||||
:data-key="props.dataKey"
|
:data-key="props.dataKey"
|
||||||
:search-button="true"
|
:search-button="true"
|
||||||
:use-searchbar="validateDateRange"
|
:searchbar-options="{ use: true, validateFn: validateDateRange }"
|
||||||
>
|
>
|
||||||
<template #tags="{ tag, formatFn }">
|
<template #tags="{ tag, formatFn }">
|
||||||
<div class="q-gutter-x-xs">
|
<div class="q-gutter-x-xs">
|
||||||
|
|
|
@ -19,16 +19,16 @@ describe('TicketFilter', () => {
|
||||||
cy.on('uncaught:exception', () => {
|
cy.on('uncaught:exception', () => {
|
||||||
return false;
|
return false;
|
||||||
});
|
});
|
||||||
cy.get('.q-field__control-container > [data-cy="From_date"]').type(
|
cy.get('.q-field__control-container > [data-cy="From_date"]')
|
||||||
'14-02-2025{enter}',
|
.type(`${today()} `)
|
||||||
);
|
.type('{enter}');
|
||||||
cy.get('.q-notification').should(
|
cy.get('.q-notification').should(
|
||||||
'contain',
|
'contain',
|
||||||
`The date range must have both 'from' and 'to'`,
|
`The date range must have both 'from' and 'to'`,
|
||||||
);
|
);
|
||||||
|
|
||||||
cy.get('.q-field__control-container > [data-cy="To_date"]').type(
|
cy.get('.q-field__control-container > [data-cy="To_date"]').type(
|
||||||
'16/02/2025{enter}',
|
`${today()}{enter}`,
|
||||||
);
|
);
|
||||||
cy.intercept('GET', /\/api\/Tickets\/filter/).as('ticketFilter');
|
cy.intercept('GET', /\/api\/Tickets\/filter/).as('ticketFilter');
|
||||||
cy.searchBtnFilterPanel();
|
cy.searchBtnFilterPanel();
|
||||||
|
@ -40,3 +40,12 @@ describe('TicketFilter', () => {
|
||||||
cy.location('href').should('contain', '#/ticket/999999');
|
cy.location('href').should('contain', '#/ticket/999999');
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
function today() {
|
||||||
|
// return new Date().toISOString().split('T')[0];
|
||||||
|
|
||||||
|
return new Intl.DateTimeFormat('es-ES', {
|
||||||
|
day: '2-digit',
|
||||||
|
month: '2-digit',
|
||||||
|
year: 'numeric',
|
||||||
|
}).format(new Date());
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in New Issue