From 23e4726c7447d26ed866a5735fe1b6caa90aae02 Mon Sep 17 00:00:00 2001 From: Jepp9350 <2jepp9350@gmail.com> Date: Wed, 16 Apr 2025 13:46:09 +0200 Subject: [PATCH] Add date filtering shortcuts and enhance filter handling Introduced predefined date filters (e.g., Today, This Month) for easier user access in the invoice orders pagination module. Improved filter logic to remove duplicates, ensure null values for empty filters, and apply new filters dynamically. Updated UI to include buttons for quick time-based filter setting. --- .../InvoiceOrdersPagination.vue | 228 ++++++++++++++++-- src/components/pagination/paginatedList.vue | 6 + src/components/session/token/SessionUser.vue | 8 +- .../SessionUser/Objects/ObjectsGlobal.vue | 4 + 4 files changed, 230 insertions(+), 16 deletions(-) diff --git a/src/components/displays/pagination/models/SuperUserDashboard/InvoiceOrdersPagination.vue b/src/components/displays/pagination/models/SuperUserDashboard/InvoiceOrdersPagination.vue index 89b18827..99d6ac27 100644 --- a/src/components/displays/pagination/models/SuperUserDashboard/InvoiceOrdersPagination.vue +++ b/src/components/displays/pagination/models/SuperUserDashboard/InvoiceOrdersPagination.vue @@ -1,4 +1,5 @@ diff --git a/src/components/pagination/paginatedList.vue b/src/components/pagination/paginatedList.vue index 6dde5170..73658458 100644 --- a/src/components/pagination/paginatedList.vue +++ b/src/components/pagination/paginatedList.vue @@ -104,6 +104,12 @@ export const setFilter = (newFilter, value, autoLoad = true) => { // If the filter is not set, add it to the filter filter.value = filter.value ? `${filter.value},${newFilter}:${value}` : `${newFilter}:${value}`; } + // Remove duplicates + filter.value = [...new Set(filter.value.split(','))].join(','); + // If the filter is empty, set it to null + if (filter.value === '') { + filter.value = null; + } // Reset the page to 1 setPage(1); // Load the list (If the endpoint is set) diff --git a/src/components/session/token/SessionUser.vue b/src/components/session/token/SessionUser.vue index 86fcf509..3deeb99f 100644 --- a/src/components/session/token/SessionUser.vue +++ b/src/components/session/token/SessionUser.vue @@ -350,7 +350,13 @@ export const SessionUser = { friday: 5, saturday: 6, sunday: 7, - } + }, + getDateMonthStart() { + return new Date(new Date().getFullYear(), new Date().getMonth(), 1); + }, + getDateMonthEnd() { + return new Date(new Date().getFullYear(), new Date().getMonth() + 1, 0); + }, }, /** Redirect to */ redirectTo: { diff --git a/src/components/session/token/SessionUser/Objects/ObjectsGlobal.vue b/src/components/session/token/SessionUser/Objects/ObjectsGlobal.vue index f5cbe3c4..eea43617 100644 --- a/src/components/session/token/SessionUser/Objects/ObjectsGlobal.vue +++ b/src/components/session/token/SessionUser/Objects/ObjectsGlobal.vue @@ -42,6 +42,10 @@ export const ObjectsGlobal = { at_hour: 'Kl.', today: 'I dag', yesterday: 'I går', + this_month: 'Denne måned', + last_month: 'Sidste måned', + this_year: 'I år', + all: 'Altid', }, nothing_left_to_show: 'Der er ikke mere at vise', pending: 'Afventer',