From ecf131ba78847e8eb8c0f02bff45f3e495da9a8b Mon Sep 17 00:00:00 2001 From: Javier Segarra Date: Thu, 14 Nov 2024 12:06:12 +0100 Subject: [PATCH 1/2] feat: move buttons to DescriptorMenu --- .../Customer/Card/CustomerDescriptor.vue | 34 -------------- .../Customer/Card/CustomerDescriptorMenu.vue | 44 +++++++++++++++++++ src/pages/Ticket/TicketList.vue | 12 ++--- 3 files changed, 51 insertions(+), 39 deletions(-) diff --git a/src/pages/Customer/Card/CustomerDescriptor.vue b/src/pages/Customer/Card/CustomerDescriptor.vue index 974b05181..e46d2cb29 100644 --- a/src/pages/Customer/Card/CustomerDescriptor.vue +++ b/src/pages/Customer/Card/CustomerDescriptor.vue @@ -174,23 +174,6 @@ const setData = (entity) => (data.value = useCardDescription(entity?.name, entit > {{ t('Customer ticket list') }} - - {{ t('New ticket') }} - - {{ t('New order') }} - + + {{ t('globals.pageTitles.createTicket') }} + + + + + {{ t('globals.pageTitles.createOrder') }} + + {{ t('Send SMS') }} diff --git a/src/pages/Ticket/TicketList.vue b/src/pages/Ticket/TicketList.vue index a3876a1a6..0685217ac 100644 --- a/src/pages/Ticket/TicketList.vue +++ b/src/pages/Ticket/TicketList.vue @@ -45,6 +45,13 @@ const userParams = { from: null, to: null, }; + +onMounted(() => { + initializeFromQuery(); + stateStore.rightDrawer = true; + if (!route.query.createForm) return; + onClientSelected(JSON.parse(route.query.createForm)); +}); // Método para inicializar las variables desde la query string const initializeFromQuery = () => { const query = route.query.table ? JSON.parse(route.query.table) : {}; @@ -301,11 +308,6 @@ const getDateColor = (date) => { if (comparation < 0) return 'bg-success'; }; -onMounted(() => { - initializeFromQuery(); - stateStore.rightDrawer = true; -}); - async function makeInvoice(ticket) { const ticketsIds = ticket.map((item) => item.id); const { data } = await axios.post(`Tickets/invoiceTicketsAndPdf`, { ticketsIds }); From 291e97e540b7a16e7fa6587fe233d5e648b2e853 Mon Sep 17 00:00:00 2001 From: Javier Segarra Date: Thu, 14 Nov 2024 12:48:33 +0100 Subject: [PATCH 2/2] feat: #6943 use openURL quasar --- src/composables/useOpenURL.js | 8 ++++ .../Customer/Card/CustomerDescriptorMenu.vue | 40 +++++++------------ 2 files changed, 22 insertions(+), 26 deletions(-) create mode 100644 src/composables/useOpenURL.js diff --git a/src/composables/useOpenURL.js b/src/composables/useOpenURL.js new file mode 100644 index 000000000..008774c20 --- /dev/null +++ b/src/composables/useOpenURL.js @@ -0,0 +1,8 @@ +import { openURL } from 'quasar'; +const defaultWindowFeatures = { + noopener: true, + noreferrer: true, +}; +export default function (url, windowFeatures = defaultWindowFeatures, fn = undefined) { + openURL(url, fn, windowFeatures); +} diff --git a/src/pages/Customer/Card/CustomerDescriptorMenu.vue b/src/pages/Customer/Card/CustomerDescriptorMenu.vue index 5ef217a31..aeaeaef57 100644 --- a/src/pages/Customer/Card/CustomerDescriptorMenu.vue +++ b/src/pages/Customer/Card/CustomerDescriptorMenu.vue @@ -6,8 +6,8 @@ import axios from 'axios'; import { useQuasar } from 'quasar'; import useNotify from 'src/composables/useNotify'; - import VnSmsDialog from 'src/components/common/VnSmsDialog.vue'; +import useOpenURL from 'src/composables/useOpenURL'; const $props = defineProps({ customer: { @@ -15,7 +15,6 @@ const $props = defineProps({ required: true, }, }); - const { notify } = useNotify(); const { t } = useI18n(); const quasar = useQuasar(); @@ -41,48 +40,37 @@ const sendSms = async (payload) => { } }; -const openTicketCreateForm = () => { +const openCreateForm = (type) => { const query = { table: { clientFk: $props.customer.id, }, createForm: { - clientId: $props.customer.id, addressId: $props.customer.defaultAddressFk, }, }; - openWindow('ticket', query); -}; -const openOrderCreateForm = () => { - const query = { - table: { - clientFk: $props.customer.id, - }, - createForm: { - clientFk: $props.customer.id, - addressId: $props.customer.defaultAddressFk, - }, + const clientFk = { + ticket: 'clientId', + order: 'clientFk', }; - openWindow('order', query); -}; + const key = clientFk[type]; + if (!key) return; + query.createForm[key] = $props.customer.id; -const openWindow = (type, { createForm, table }) => { - window.open( - `/#/${type}/list?createForm=${JSON.stringify(createForm)}&table=${JSON.stringify( - table - )}`, - '_blank' - ); + const params = Object.entries(query) + .map(([key, value]) => `${key}=${JSON.stringify(value)}`) + .join('&'); + useOpenURL(`/#/${type}/list?${params}`); };