From 433823c2acc246b7fdf0eea26545dbe8eecbf48c Mon Sep 17 00:00:00 2001 From: wbuezas Date: Fri, 15 Dec 2023 10:23:57 -0300 Subject: [PATCH] Invoice out negative bases refactor --- src/components/ui/VnFilterPanel.vue | 30 ++- src/composables/useArrayData.js | 5 +- .../InvoiceOut/InvoiceOutNegativeBases.vue | 201 +++++------------- .../InvoiceOutNegativeBasesFilter.vue | 134 ++++++++++++ src/pages/Travel/TravelFilter.vue | 28 +-- src/pages/Travel/TravelList.vue | 2 +- src/services/invoiceOut.service.js | 4 - 7 files changed, 230 insertions(+), 174 deletions(-) create mode 100644 src/pages/InvoiceOut/InvoiceOutNegativeBasesFilter.vue diff --git a/src/components/ui/VnFilterPanel.vue b/src/components/ui/VnFilterPanel.vue index 9cd5a052f..84893b667 100644 --- a/src/components/ui/VnFilterPanel.vue +++ b/src/components/ui/VnFilterPanel.vue @@ -24,6 +24,13 @@ const props = defineProps({ type: Boolean, default: true, }, + unremovableParams: { + type: Array, + required: false, + default: () => [], + description: + 'Algunos filtros vienen con parametros de búsqueda por default y necesitan tener si o si un valor, por eso de ser necesario, esta prop nos sirve para saber que filtros podemos remover y cuales no', + }, }); const emit = defineEmits(['refresh', 'clear', 'search']); @@ -63,12 +70,25 @@ async function reload() { } async function clearFilters() { - userParams.value = {}; isLoading.value = true; - await arrayData.applyFilter({ params: {} }); - if (!props.showAll) store.data = []; - isLoading.value = false; + // Filtrar los params no removibles + const removableFilters = Object.keys(userParams.value).filter((param) => + props.unremovableParams.includes(param) + ); + const newParams = {}; + // Conservar solo los params que no son removibles + for (const key of removableFilters) { + newParams[key] = userParams.value[key]; + } + userParams.value = { ...newParams }; // Actualizar los params con los removibles + await arrayData.applyFilter({ params: userParams.value }); + + if (!props.showAll) { + store.data = []; + } + + isLoading.value = false; emit('clear'); } @@ -156,7 +176,7 @@ function formatValue(value) { class="text-dark" color="primary" icon="label" - removable + :removable="!unremovableParams.includes(chip.label)" size="sm" v-for="chip of tags" > diff --git a/src/composables/useArrayData.js b/src/composables/useArrayData.js index 523340cc9..5e80949f3 100644 --- a/src/composables/useArrayData.js +++ b/src/composables/useArrayData.js @@ -132,6 +132,7 @@ export function useArrayData(key, userOptions) { async function applyFilter({ filter, params }) { if (filter) store.userFilter = filter; + store.filter = {}; if (params) store.userParams = Object.assign({}, params); await fetch({ append: false }); @@ -155,7 +156,9 @@ export function useArrayData(key, userOptions) { delete store.userParams[param]; delete params[param]; if (store.filter?.where) { - delete store.filter.where[Object.keys(exprBuilder ? exprBuilder(param) : param)[0]]; + delete store.filter.where[ + Object.keys(exprBuilder ? exprBuilder(param) : param)[0] + ]; if (Object.keys(store.filter.where).length === 0) { delete store.filter.where; } diff --git a/src/pages/InvoiceOut/InvoiceOutNegativeBases.vue b/src/pages/InvoiceOut/InvoiceOutNegativeBases.vue index 7265a0b08..d0e45724e 100644 --- a/src/pages/InvoiceOut/InvoiceOutNegativeBases.vue +++ b/src/pages/InvoiceOut/InvoiceOutNegativeBases.vue @@ -1,44 +1,54 @@ @@ -344,10 +257,6 @@ onMounted(async () => { border-radius: 4px; padding: 6px 6px 6px 6px; } - -.text-results { - color: var(--vn-label); -} diff --git a/src/pages/InvoiceOut/InvoiceOutNegativeBasesFilter.vue b/src/pages/InvoiceOut/InvoiceOutNegativeBasesFilter.vue new file mode 100644 index 000000000..028246aeb --- /dev/null +++ b/src/pages/InvoiceOut/InvoiceOutNegativeBasesFilter.vue @@ -0,0 +1,134 @@ + + + + + + + +en: + params: + from: From + to: To + company: Company + country: Country + clientId: Client Id + clientSocialName: Client + amount: Amount + comercialName: Comercial +es: + params: + from: Desde + to: Hasta + company: Empresa + country: País + clientId: Id cliente + clientSocialName: Cliente + amount: Importe + comercialName: Comercial + Date is required: La fecha es requerida + + diff --git a/src/pages/Travel/TravelFilter.vue b/src/pages/Travel/TravelFilter.vue index d4cb286c2..52a755c34 100644 --- a/src/pages/Travel/TravelFilter.vue +++ b/src/pages/Travel/TravelFilter.vue @@ -1,5 +1,5 @@