diff --git a/src/pages/Ticket/Card/TicketSale.vue b/src/pages/Ticket/Card/TicketSale.vue index 92936b26a..f5fb50ecf 100644 --- a/src/pages/Ticket/Card/TicketSale.vue +++ b/src/pages/Ticket/Card/TicketSale.vue @@ -174,17 +174,21 @@ const getSaleTotal = (sale) => { return price - discount; }; +const getRowUpdateInputEvents = (sale) => ({ + 'keyup.enter': () => { + changeQuantity(sale); + }, + blur: () => { + changeQuantity(sale); + }, +}); + const resetChanges = async () => { arrayData.fetch({ append: false }); tableRef.value.reload(); }; -const rowToUpdate = ref(null); const changeQuantity = async (sale) => { - if ( - !sale.itemFk || - sale.quantity == null || - edit.value?.oldQuantity === sale.quantity - ) + if (!sale.itemFk || sale.quantity == null || sale?.originalQuantity === sale.quantity) return; if (!sale.id) return addSale(sale); @@ -196,11 +200,8 @@ const changeQuantity = async (sale) => { const updateQuantity = async (sale) => { try { let { quantity, id } = sale; - if (!rowToUpdate.value) return; - rowToUpdate.value = null; sale.isNew = false; - const params = { quantity: quantity }; - await axios.post(`Sales/${id}/updateQuantity`, params); + await axios.post(`Sales/${id}/updateQuantity`, { quantity }); notify('globals.dataSaved', 'positive'); tableRef.value.reload(); } catch (e) { @@ -816,9 +817,7 @@ watch( v-if="row.isNew || isTicketEditable" type="number" v-model.number="row.quantity" - @blur="changeQuantity(row)" - @keyup.enter.stop="changeQuantity(row)" - @update:model-value="() => (rowToUpdate = row)" + v-on="getRowUpdateInputEvents(row)" @focus="edit.oldQuantity = row.quantity" /> {{ row.quantity }} diff --git a/src/pages/Ticket/Card/TicketSaleMoreActions.vue b/src/pages/Ticket/Card/TicketSaleMoreActions.vue index 4cc96e9e2..8b5537edc 100644 --- a/src/pages/Ticket/Card/TicketSaleMoreActions.vue +++ b/src/pages/Ticket/Card/TicketSaleMoreActions.vue @@ -50,6 +50,7 @@ const { dialog } = useQuasar(); const { notify } = useNotify(); const acl = useAcl(); const btnDropdownRef = ref(null); +const editManaProxyRef = ref(null); const { openConfirmationModal } = useVnConfirm(); const newDiscount = ref(null); @@ -131,13 +132,13 @@ const createClaim = () => { openConfirmationModal( t('Claim out of time'), t('Do you want to continue?'), - onCreateClaimAccepted + onCreateClaimAccepted, ); else openConfirmationModal( t('Do you want to create a claim?'), false, - onCreateClaimAccepted + onCreateClaimAccepted, ); }; @@ -216,8 +217,15 @@ const createRefund = async (withWarehouse) => { {{ t('Update discount') }} - + { ticketUrl.value = (await getUrl('ticket/')) + entityId.value + '/'; }); +const formattedAddress = computed(() => { + if (!ticket.value) return ''; + + const address = ticket.value.address; + const postcode = address.postalCode; + const province = address.province ? `(${address.province.name})` : ''; + + return `${address.street} - ${postcode} - ${address.city} ${province}`; +}); function isEditable() { try { @@ -237,7 +246,7 @@ onMounted(async () => { />