From ba772b96db96c75b1518e5d0a803e7b876f042d2 Mon Sep 17 00:00:00 2001 From: flutistar Date: Thu, 24 Oct 2024 07:28:28 -0700 Subject: [PATCH 1/2] Preserve date filter on registration table --- .../src/components/common/RangeDatePicker.vue | 2 ++ .../components/tables/RegistrationTable.vue | 19 ++++++++++++++++--- ppr-ui/src/composables/useRegistration.ts | 2 +- ppr-ui/src/utils/date-helper.ts | 2 +- 4 files changed, 20 insertions(+), 5 deletions(-) diff --git a/ppr-ui/src/components/common/RangeDatePicker.vue b/ppr-ui/src/components/common/RangeDatePicker.vue index 2e959575e..ee07051cf 100644 --- a/ppr-ui/src/components/common/RangeDatePicker.vue +++ b/ppr-ui/src/components/common/RangeDatePicker.vue @@ -15,6 +15,7 @@ @@ -419,7 +421,7 @@ import { import { storeToRefs } from 'pinia' import { useTableFeatures, useTransferOwners } from '@/composables' import { RangeDatePicker } from '@/components/common' -import { dateToYyyyMmDd, localTodayDate } from '@/utils' +import { dateToYyyyMmDd, yyyyMmDdToPacificDate, localTodayDate } from '@/utils' import TableObserver from '@/components/tables/common/TableObserver.vue' export default defineComponent({ @@ -728,7 +730,7 @@ export default defineComponent({ const updateDateRange = (dates: { endDate: Date, startDate: Date }) => { if (!(dates.endDate && dates.startDate)) dateTxt.value = '' else dateTxt.value = 'Custom' - + submittedStartDate.value = dateToYyyyMmDd(dates.startDate) submittedEndDate.value = dateToYyyyMmDd(dates.endDate) localState.showDatePicker = false @@ -755,7 +757,16 @@ export default defineComponent({ }, 2000) } }) - + const getPstDateObj = (date: string): Date => { + if(!date) return null + // Regular expression to match timezone offset (e.g., +05:00 or Z for UTC) + const timeZoneRegex = /([+-]\d{2}:\d{2}|Z)$/; + + if(timeZoneRegex.test(date)) { + return new Date(date) + } + return new Date(yyyyMmDdToPacificDate(date)) + } watch(() => dateTxt.value, (val) => { if (!val) { submittedStartDate.value = null @@ -845,6 +856,7 @@ export default defineComponent({ isMiscTransfersEnabled, getNext, localTodayDate, + yyyyMmDdToPacificDate, dateSortHandler, datePicker, dateTxt, @@ -888,6 +900,7 @@ export default defineComponent({ clientReferenceIdRef, toggleGroup, hideAllGroups, + getPstDateObj, ...toRefs(localState) } } diff --git a/ppr-ui/src/composables/useRegistration.ts b/ppr-ui/src/composables/useRegistration.ts index 7f11bb4f7..635c218a9 100644 --- a/ppr-ui/src/composables/useRegistration.ts +++ b/ppr-ui/src/composables/useRegistration.ts @@ -14,7 +14,7 @@ import { RegistrationSortIF, RegistrationSummaryIF } from '@/interfaces' export const useRegistration = (setSort: RegistrationSortIF) => { const localState = reactive({ - dateTxt: '', + dateTxt: (setSort?.startDate && setSort.endDate) ? 'Custom' : '', registrationNumber: setSort?.regNum || '', registrationType: setSort?.regType || '', status: setSort?.status || '', diff --git a/ppr-ui/src/utils/date-helper.ts b/ppr-ui/src/utils/date-helper.ts index a1ddc89de..806b78022 100644 --- a/ppr-ui/src/utils/date-helper.ts +++ b/ppr-ui/src/utils/date-helper.ts @@ -189,7 +189,7 @@ export function dateToYyyyMmDd (date: Date): string { day: 'numeric', // 31 year: 'numeric' // 2020 }) - + return convertDateFormat(localDate) } From e9a555d243f80a832a1cedc6a0e361aa1fa3170c Mon Sep 17 00:00:00 2001 From: flutistar Date: Fri, 25 Oct 2024 07:36:58 -0700 Subject: [PATCH 2/2] updated versio number --- ppr-ui/package-lock.json | 4 ++-- ppr-ui/package.json | 2 +- ppr-ui/src/components/tables/RegistrationTable.vue | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/ppr-ui/package-lock.json b/ppr-ui/package-lock.json index ac214f44d..090235f23 100644 --- a/ppr-ui/package-lock.json +++ b/ppr-ui/package-lock.json @@ -1,12 +1,12 @@ { "name": "ppr-ui", - "version": "3.2.67", + "version": "3.2.68", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "ppr-ui", - "version": "3.2.67", + "version": "3.2.68", "dependencies": { "@bcrs-shared-components/input-field-date-picker": "^1.0.0", "@lemoncode/fonk": "^1.5.1", diff --git a/ppr-ui/package.json b/ppr-ui/package.json index ae5bb2a57..427790dff 100644 --- a/ppr-ui/package.json +++ b/ppr-ui/package.json @@ -1,6 +1,6 @@ { "name": "ppr-ui", - "version": "3.2.67", + "version": "3.2.68", "private": true, "appName": "Assets UI", "sbcName": "SBC Common Components", diff --git a/ppr-ui/src/components/tables/RegistrationTable.vue b/ppr-ui/src/components/tables/RegistrationTable.vue index 4688d4aaf..2151bd42e 100644 --- a/ppr-ui/src/components/tables/RegistrationTable.vue +++ b/ppr-ui/src/components/tables/RegistrationTable.vue @@ -9,8 +9,8 @@ v-if="showDatePicker" id="ranged-date-picker" ref="datePicker" - :default-start-date="getPstDateObj(submittedStartDate)" - :default-end-date="getPstDateObj(submittedEndDate)" + :defaultStartDate="getPstDateObj(submittedStartDate)" + :defaultEndDate="getPstDateObj(submittedEndDate)" :defaultMaxDate="new Date()" @submit="updateDateRange($event)" />