From 2314f02239486fa26d586bebef581eb6fbebf244 Mon Sep 17 00:00:00 2001 From: Jeppe Bundgaard Date: Wed, 10 Dec 2025 14:01:24 +0100 Subject: [PATCH] "Refactor OrderBookingsTable.vue: simplify table logic by removing unnecessary filters and pagination handling, migrate pagination to OrderBookingsPagination.vue, and update components for improved code maintainability and usability." --- .../buttons/ActionSettingsWheelButton.vue | 24 ++ .../UserDashboard/OrderBookingsPagination.vue | 207 +++++++++ .../InvoiceCollectionsTable.vue | 9 + .../Objects/CollectedOrderInvoices.vue | 18 + .../modules/bookings/DepartmentBookings.vue | 6 +- .../userDashboard/bookings/MyBookings.vue | 6 +- .../displays/tables/OrderBookingsTable.vue | 402 +----------------- 7 files changed, 275 insertions(+), 397 deletions(-) create mode 100644 src/components/displays/pagination/models/UserDashboard/OrderBookingsPagination.vue diff --git a/src/components/displays/buttons/ActionSettingsWheelButton.vue b/src/components/displays/buttons/ActionSettingsWheelButton.vue index 0015eea4..5d548464 100644 --- a/src/components/displays/buttons/ActionSettingsWheelButton.vue +++ b/src/components/displays/buttons/ActionSettingsWheelButton.vue @@ -363,6 +363,17 @@ const defaultActions = computed(() => { }, disabled: false, }, + { + icon: 'fas fa-download', + label: 'Download faktura', + clickAction: () => { + return SessionUser.objects.collectedOrderInvoices.functions.download(props.invoice_collection_id); + }, + showFunction: () => { + return true; + }, + disabled: false, + }, { icon: 'fas fa-trash-alt', label: 'Slet ordre', @@ -739,6 +750,19 @@ const defaultActions = computed(() => { + + diff --git a/src/components/session/token/SessionUser/Objects/CollectedOrderInvoices.vue b/src/components/session/token/SessionUser/Objects/CollectedOrderInvoices.vue index c9efb9b0..9252ca3e 100644 --- a/src/components/session/token/SessionUser/Objects/CollectedOrderInvoices.vue +++ b/src/components/session/token/SessionUser/Objects/CollectedOrderInvoices.vue @@ -254,6 +254,24 @@ export const CollectedOrderInvoices = { } }, functions: { + download: async (id) => { + // Send the request + return authenticatedRequest('/invoices/pdf', 'GET', { + id: parseInt(id) + }).then((response) => { + //console.warn(response); + // Create a blob from the response + window.open(response.data.data.url, '_blank'); + return response; + }).catch((error) => { + Swal.fire({ + title: 'Der skete en fejl under hentning af PDF', + text: SessionUser.functions.parseErrorMessage(error), + icon: 'error' + }); + throw error; + }); + }, split_invoice: async (id) => { // Send the request return authenticatedRequest('/collected-invoices/split', 'POST', { diff --git a/src/views/dashboards/departmentDashboard/modules/bookings/DepartmentBookings.vue b/src/views/dashboards/departmentDashboard/modules/bookings/DepartmentBookings.vue index 915d475f..732b09d1 100644 --- a/src/views/dashboards/departmentDashboard/modules/bookings/DepartmentBookings.vue +++ b/src/views/dashboards/departmentDashboard/modules/bookings/DepartmentBookings.vue @@ -1,10 +1,9 @@