diff --git a/CHANGELOG.md b/CHANGELOG.md index dbf6bdcc3..51dd2010c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,6 +9,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Added +- (Tickets) => Se añade la opción de clonar ticket. #6951 + ### Changed ### Fixed diff --git a/src/pages/Ticket/Card/TicketDescriptorMenu.vue b/src/pages/Ticket/Card/TicketDescriptorMenu.vue index 61167d722..c7784bc2a 100644 --- a/src/pages/Ticket/Card/TicketDescriptorMenu.vue +++ b/src/pages/Ticket/Card/TicketDescriptorMenu.vue @@ -24,7 +24,42 @@ const { openReport, sendEmail } = usePrintService(); const ticket = ref(props.ticket); const ticketId = currentRoute.value.params.id; -const actions = { remove: remove, clone: clone }; +const actions = { + clone: async () => { + const opts = { message: t('Ticket cloned'), type: 'positive' }; + let clonedTicketId; + + try { + const { data } = await axios.post(`Tickets/${ticketId}/clone`, { + shipped: ticket.value.shipped, + }); + clonedTicketId = data; + } catch (e) { + opts.message = t('It was not able to clone the ticket'); + opts.type = 'negative'; + } finally { + notify(opts); + + if (clonedTicketId) + push({ name: 'TicketSummary', params: { id: clonedTicketId } }); + } + }, + remove: async () => { + try { + await axios.post(`Tickets/${ticketId}/setDeleted`); + + notify({ message: t('Ticket deleted'), type: 'positive' }); + notify({ + message: t('You can undo this action within the first hour'), + icon: 'info', + }); + + push({ name: 'TicketList' }); + } catch (e) { + notify({ message: e.message, type: 'negative' }); + } + }, +}; function openDeliveryNote(type = 'deliveryNote', documentType = 'pdf') { const path = `Tickets/${ticket.value.id}/delivery-note-${documentType}`; @@ -118,42 +153,6 @@ function openConfirmDialog(callback) { }, }); } - -async function clone() { - const opts = { message: t('Ticket cloned'), type: 'positive' }; - let clonedTicketId; - - try { - const { data } = await axios.post(`Tickets/${ticketId}/clone`, { - shipped: ticket.value.shipped, - }); - clonedTicketId = data; - } catch (e) { - opts.message = t('It was not able to clone the ticket'); - opts.type = 'negative'; - } finally { - notify(opts); - - if (clonedTicketId) - push({ name: 'TicketSummary', params: { id: clonedTicketId } }); - } -} - -async function remove() { - try { - await axios.post(`Tickets/${ticketId}/setDeleted`); - - notify({ message: t('Ticket deleted'), type: 'positive' }); - notify({ - message: t('You can undo this action within the first hour'), - icon: 'info', - }); - - push({ name: 'TicketList' }); - } catch (e) { - notify({ message: e.message, type: 'negative' }); - } -}