From b37923e194a81c4b5fd607739214bc1c393d5ff3 Mon Sep 17 00:00:00 2001 From: pablone Date: Sun, 9 Feb 2025 18:24:41 +0100 Subject: [PATCH] feat: refs #6897 add success messages for entry lock and improve data attributes for better testing --- src/components/FilterTravelForm.vue | 4 +- src/components/LeftMenuItem.vue | 1 + src/components/VnTable/VnOrder.vue | 4 - src/components/VnTable/VnTable.vue | 17 +- .../common/VnSelectTravelExtended.vue | 1 + src/components/ui/CardDescriptor.vue | 4 +- src/components/ui/VnConfirm.vue | 3 +- src/components/ui/VnMoreOptions.vue | 2 +- src/composables/checkEntryLock.js | 6 +- src/pages/Entry/Card/EntryBasicData.vue | 3 +- src/pages/Entry/Card/EntryBuys.vue | 59 +++-- src/pages/Entry/Card/EntryDescriptor.vue | 70 ++++-- src/pages/Entry/Card/EntrySummary.vue | 3 +- src/pages/Entry/EntryList.vue | 5 +- src/pages/Entry/locale/en.yml | 1 + src/pages/Entry/locale/es.yml | 2 +- src/pages/Item/Card/ItemDescriptor.vue | 2 +- .../Card/BasicData/TicketBasicDataForm.vue | 4 +- src/router/modules/entry.js | 1 + .../integration/entry/entrylist.spec.js | 216 +++++++++++++++++- test/cypress/support/waitUntil.js | 2 +- 21 files changed, 340 insertions(+), 70 deletions(-) diff --git a/src/components/FilterTravelForm.vue b/src/components/FilterTravelForm.vue index 9fc91457a..ab50d0899 100644 --- a/src/components/FilterTravelForm.vue +++ b/src/components/FilterTravelForm.vue @@ -181,6 +181,7 @@ const selectTravel = ({ id }) => { color="primary" :disabled="isLoading" :loading="isLoading" + data-cy="save-filter-travel-form" /> { :no-data-label="t('Enter a new search')" class="q-mt-lg" @row-click="(_, row) => selectTravel(row)" + data-cy="table-filter-travel-form" > diff --git a/src/pages/Entry/Card/EntryDescriptor.vue b/src/pages/Entry/Card/EntryDescriptor.vue index 7ea3bd0d2..8559b104a 100644 --- a/src/pages/Entry/Card/EntryDescriptor.vue +++ b/src/pages/Entry/Card/EntryDescriptor.vue @@ -94,25 +94,53 @@ const getEntryRedirectionFilter = (entry) => { function showEntryReport() { openReport(`Entries/${entityId.value}/entry-order-pdf`); } -async function recalculateRates(entity) { - const entryConfig = await axios.get('EntryConfigs/findOne'); - if (entryConfig.data?.inventorySupplierFk === entity.supplierFk) { - quasar.notify({ - type: 'negative', - message: t('Cannot recalculate prices because this is an inventory entry'), - }); - return; - } - await axios.post(`Entries/${entityId.value}/recalcEntryPrices`); +function showNotification(type, message) { + quasar.notify({ + type: type, + message: t(message), + }); } + +async function recalculateRates(entity) { + try { + const entryConfig = await axios.get('EntryConfigs/findOne'); + if (entryConfig.data?.inventorySupplierFk === entity.supplierFk) { + showNotification( + 'negative', + 'Cannot recalculate prices because this is an inventory entry', + ); + return; + } + + await axios.post(`Entries/${entityId.value}/recalcEntryPrices`); + showNotification('positive', 'Entry prices recalculated'); + } catch (error) { + showNotification('negative', 'Failed to recalculate rates'); + console.error(error); + } +} + async function cloneEntry() { - await axios - .post(`Entries/${entityId.value}/cloneEntry`) - .then((response) => push(`/entry/${response.data[0].vNewEntryFk}`)); + try { + const response = await axios.post(`Entries/${entityId.value}/cloneEntry`); + push({ path: `/entry/${response.data[0].vNewEntryFk}` }); + showNotification('positive', 'Entry cloned'); + } catch (error) { + showNotification('negative', 'Failed to clone entry'); + console.error(error); + } } + async function deleteEntry() { - await axios.post(`Entries/${entityId.value}/deleteEntry`).then(() => push(`/entry/`)); + try { + await axios.post(`Entries/${entityId.value}/deleteEntry`); + push({ path: `/entry/list` }); + showNotification('positive', 'Entry deleted'); + } catch (error) { + showNotification('negative', 'Failed to delete entry'); + console.error(error); + } } @@ -146,7 +174,13 @@ async function deleteEntry() { {{ t('Clone') }} - + {{ t('Delete') }} @@ -253,4 +287,10 @@ es: landed: Recibido This entry is deleted: Esta entrada está eliminada Cannot recalculate prices because this is an inventory entry: No se pueden recalcular los precios porque es una entrada de inventario + Entry deleted: Entrada eliminada + Entry cloned: Entrada clonada + Entry prices recalculated: Precios de la entrada recalculados + Failed to recalculate rates: No se pudieron recalcular las tarifas + Failed to clone entry: No se pudo clonar la entrada + Failed to delete entry: No se pudo eliminar la entrada diff --git a/src/pages/Entry/Card/EntrySummary.vue b/src/pages/Entry/Card/EntrySummary.vue index c25a7c186..6b7477cfc 100644 --- a/src/pages/Entry/Card/EntrySummary.vue +++ b/src/pages/Entry/Card/EntrySummary.vue @@ -176,9 +176,8 @@ onMounted(async () => { /> diff --git a/src/pages/Entry/EntryList.vue b/src/pages/Entry/EntryList.vue index ad66ebb58..a41af5cee 100644 --- a/src/pages/Entry/EntryList.vue +++ b/src/pages/Entry/EntryList.vue @@ -263,12 +263,12 @@ onBeforeMount(async () => {