From ae655dabe210664f4616e142bd4b1bf68ef3b7b8 Mon Sep 17 00:00:00 2001 From: carlossa Date: Thu, 9 Nov 2023 13:52:45 +0100 Subject: [PATCH] refs #6157 refactor stateColor, updateDestinations, change responsability --- src/pages/Claim/Card/ClaimAction.vue | 20 +++++--------------- src/pages/Claim/Card/ClaimDescriptor.vue | 11 ++++++++--- src/pages/Claim/Card/ClaimSummary.vue | 11 ++++++++--- src/pages/Claim/ClaimList.vue | 14 +++++++++----- test/cypress/integration/claimAction.spec.js | 4 ++-- 5 files changed, 32 insertions(+), 28 deletions(-) diff --git a/src/pages/Claim/Card/ClaimAction.vue b/src/pages/Claim/Card/ClaimAction.vue index 962edac73..c52741160 100644 --- a/src/pages/Claim/Card/ClaimAction.vue +++ b/src/pages/Claim/Card/ClaimAction.vue @@ -103,27 +103,17 @@ function getDestination(destinationId) { return destinationTypes.value.find((type) => type.id == destinationId); } -async function deleteSale(sale) { - await axios.post(`ClaimEnds/deleteClamedSales`, { sales: [sale] }); - claimActionsForm.value.reload(); -} - async function updateDestinations(claimDestinationFk) { - if (claimDestinationFk) { - await axios.post('Claims/updateClaimDestination', { - claimDestinationFk, - rows: [...selectedRows.value], - }); - claimActionsForm.value.reload(); - } + await updateDestination(claimDestinationFk, selectedRows.value, { reload: true }); } -async function updateDestination(claimDestinationFk, row) { +async function updateDestination(claimDestinationFk, row, options = {}) { if (claimDestinationFk) { await axios.post('Claims/updateClaimDestination', { claimDestinationFk, - rows: [row], + rows: Array.isArray(row) ? row : [row], }); + options.reload && claimActionsForm.value.reload(); } } @@ -251,7 +241,7 @@ async function importToNewRefundTicket() { class="responsibility { 'background-color:primary': quasar.platform.is.mobile }" v-model="claim.responsibility" :label-value="t('claim.summary.responsibility')" - @update:model-value="(value) => save({ responsibility: value })" + @change="(value) => save({ responsibility: value })" label-always color="primary" markers diff --git a/src/pages/Claim/Card/ClaimDescriptor.vue b/src/pages/Claim/Card/ClaimDescriptor.vue index 00f48f36f..147974c36 100644 --- a/src/pages/Claim/Card/ClaimDescriptor.vue +++ b/src/pages/Claim/Card/ClaimDescriptor.vue @@ -62,10 +62,15 @@ const filter = { ], }; +const STATE_COLOR = { + pending: 'positive', + + managed: 'warning', + + resolved: 'negative', +}; function stateColor(code) { - if (code === 'pending') return 'positive'; - if (code === 'managed') return 'warning'; - if (code === 'resolved') return 'negative'; + return STATE_COLOR[code]; } const data = ref(useCardDescription()); const setData = (entity) => { diff --git a/src/pages/Claim/Card/ClaimSummary.vue b/src/pages/Claim/Card/ClaimSummary.vue index dc5ec9544..64d7b721b 100644 --- a/src/pages/Claim/Card/ClaimSummary.vue +++ b/src/pages/Claim/Card/ClaimSummary.vue @@ -85,10 +85,15 @@ const detailsColumns = ref([ }, ]); +const STATE_COLOR = { + pending: 'positive', + + managed: 'warning', + + resolved: 'negative', +}; function stateColor(code) { - if (code === 'pending') return 'green'; - if (code === 'managed') return 'orange'; - if (code === 'resolved') return 'red'; + return STATE_COLOR[code]; } const developmentColumns = ref([ diff --git a/src/pages/Claim/ClaimList.vue b/src/pages/Claim/ClaimList.vue index 79afc7e91..54b842f0d 100644 --- a/src/pages/Claim/ClaimList.vue +++ b/src/pages/Claim/ClaimList.vue @@ -17,12 +17,16 @@ const router = useRouter(); const quasar = useQuasar(); const { t } = useI18n(); -function stateColor(code) { - if (code === 'pending') return 'green'; - if (code === 'managed') return 'orange'; - if (code === 'resolved') return 'red'; -} +const STATE_COLOR = { + pending: 'positive', + managed: 'warning', + + resolved: 'negative', +}; +function stateColor(code) { + return STATE_COLOR[code]; +} function navigate(id) { router.push({ path: `/claim/${id}` }); } diff --git a/test/cypress/integration/claimAction.spec.js b/test/cypress/integration/claimAction.spec.js index 522cedced..09023e137 100644 --- a/test/cypress/integration/claimAction.spec.js +++ b/test/cypress/integration/claimAction.spec.js @@ -1,7 +1,7 @@ /// describe('ClaimAction', () => { const claimId = 2; - const firstLineReason = 'tbody > :nth-child(1) > :nth-child(2)'; + const firstRow = 'tbody > :nth-child(1)'; beforeEach(() => { @@ -15,7 +15,7 @@ describe('ClaimAction', () => { }); it('should change destination', () => { - const rowData = [true, null, null, 'Bueno', null, null, null, null, null, null]; + const rowData = [true, null, null, 'Bueno']; cy.fillRow(firstRow, rowData); });