From b71479bab51e6d2d40e907cdca92c5ccff630c58 Mon Sep 17 00:00:00 2001 From: CameronEYDS <53542131+cameron-eyds@users.noreply.github.com> Date: Thu, 22 Aug 2024 12:53:52 -0700 Subject: [PATCH] Preserve Table Filters for both PPR/MHR (#2005) * Preserve Table Filters for both PPR/MHR * clean up --- ppr-ui/package-lock.json | 4 +-- ppr-ui/package.json | 2 +- .../common/RegistrationsWrapper.vue | 28 +++++++++---------- .../components/dashboard/DashboardTabs.vue | 3 +- .../components/tables/RegistrationTable.vue | 6 ---- .../reg-table-data-interface.ts | 1 + ppr-ui/src/store/state/state-model.ts | 13 +++++++++ ppr-ui/src/store/store.ts | 23 ++++++--------- ppr-ui/src/utils/mhr-api-helper.ts | 1 + 9 files changed, 41 insertions(+), 40 deletions(-) diff --git a/ppr-ui/package-lock.json b/ppr-ui/package-lock.json index 79374a6aa..bbcae6ba1 100644 --- a/ppr-ui/package-lock.json +++ b/ppr-ui/package-lock.json @@ -1,12 +1,12 @@ { "name": "ppr-ui", - "version": "3.2.47", + "version": "3.2.48", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "ppr-ui", - "version": "3.2.47", + "version": "3.2.48", "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 8aef59772..baa8e2d92 100644 --- a/ppr-ui/package.json +++ b/ppr-ui/package.json @@ -1,6 +1,6 @@ { "name": "ppr-ui", - "version": "3.2.47", + "version": "3.2.48", "private": true, "appName": "Assets UI", "sbcName": "SBC Common Components", diff --git a/ppr-ui/src/components/common/RegistrationsWrapper.vue b/ppr-ui/src/components/common/RegistrationsWrapper.vue index bf0fc24de..56dfe1663 100644 --- a/ppr-ui/src/components/common/RegistrationsWrapper.vue +++ b/ppr-ui/src/components/common/RegistrationsWrapper.vue @@ -201,7 +201,7 @@ :setNewRegItem="getRegTableNewItem" :setRegistrationHistory="myRegistrations" :setSearch="myRegFilter" - :setSort="getRegTableSortOptions" + :setSort="isPpr ? getRegTableSortOptions : getRegTableMhSortOptions" @action="myRegActionHandler($event)" @error="emitError($event)" @sort="myRegSort($event)" @@ -357,7 +357,7 @@ export default defineComponent({ getRegTableBaseRegs, getRegTableDraftsBaseReg, isMhrRegistration, isMhrManufacturerRegistration, getRegTableTotalRowCount, getStateModel, getRegTableDraftsChildReg, hasMorePages, getRegTableNewItem, getRegTableSortOptions, getRegTableSortPage, getUserSettings, getMhRegTableBaseRegs, isRoleStaffReg, - isRoleQualifiedSupplier + isRoleQualifiedSupplier, getRegTableMhSortOptions } = storeToRefs(useStore()) const { @@ -365,11 +365,8 @@ export default defineComponent({ initNewManufacturerMhr, fetchMhRegistrations } = useNewMhrRegistration(true) - const { initDraftMhrCorrection } = useMhrCorrections() - const { goToExemptions } = useExemptions() - const { initMhrReRegistration, initDraftMhrReRegistration } = useMhrReRegistration() const localState = reactive({ @@ -447,8 +444,8 @@ export default defineComponent({ } else if (props.isPpr) { // load in registrations from scratch resetRegTableData(null) - const myRegDrafts = await draftHistory(cloneDeep(getRegTableSortOptions.value)) - const myRegHistory = await registrationHistory() + const myRegDrafts = await draftHistory(getRegTableSortOptions.value) + const myRegHistory = await registrationHistory(getRegTableSortOptions.value) if (myRegDrafts?.error || myRegHistory?.error) { // prioritize reg error @@ -469,7 +466,7 @@ export default defineComponent({ setRegTableTotalRowCount(getRegTableTotalRowCount.value + historyDraftsCollapsed.drafts.length) } } else if (props.isMhr && !props.isTabView) { // If Tab view, Mhr Data will be loaded in dashboardTabs component - await fetchMhRegistrations() + await fetchMhRegistrations(getRegTableMhSortOptions.value) } @@ -703,7 +700,7 @@ export default defineComponent({ prevDraft: '' } setRegTableNewItem(newRegItem) - await fetchMhRegistrations() + await fetchMhRegistrations(getRegTableMhSortOptions.value) } localState.loading = false } @@ -869,7 +866,7 @@ export default defineComponent({ const removeMhrDraft = async (mhrNumber: string): Promise => { localState.myRegDataLoading = true await deleteMhrDraft(mhrNumber) - await fetchMhRegistrations() // Refresh the table with update Registration History + await fetchMhRegistrations(getRegTableMhSortOptions.value) localState.myRegDataLoading = false } @@ -916,7 +913,7 @@ export default defineComponent({ localState.myRegDataLoading = true const page = getRegTableSortPage.value + 1 setRegTableSortPage(page) - const nextRegs = await registrationHistory(cloneDeep(getRegTableSortOptions.value), page) + const nextRegs = await registrationHistory(getRegTableSortOptions.value, page) if (nextRegs.error) { emitError(nextRegs.error) } else { @@ -1029,7 +1026,7 @@ export default defineComponent({ const myRegSort = async (args: { sortOptions: RegistrationSortIF, sorting: boolean }): Promise => { localState.myRegDataLoading = true - setRegTableSortOptions(args.sortOptions) + setRegTableSortOptions(args.sortOptions, props.isMhr) const sorting = args.sorting let sortedDrafts = { drafts: [] as DraftResultIF[], error: null } @@ -1062,7 +1059,7 @@ export default defineComponent({ setRegTableBaseRegs(updatedRegs.registrations) } } else if (props.isMhr) { - await fetchMhRegistrations(cloneDeep(args.sortOptions)) + await fetchMhRegistrations(getRegTableMhSortOptions.value) } localState.myRegDataLoading = false } @@ -1086,7 +1083,7 @@ export default defineComponent({ val.addedRegSummary = regSummary } else { // its a draft - get draft summary - const drafts = await draftHistory(null) + const drafts = await draftHistory(getRegTableSortOptions.value) if (drafts.error) { emitError(drafts.error) // dialog and will reload the dash after localState.myRegDataAdding = false @@ -1177,7 +1174,7 @@ export default defineComponent({ } } } else { - await fetchMhRegistrations() + await fetchMhRegistrations(getRegTableMhSortOptions.value) } localState.myRegDataAdding = false @@ -1282,6 +1279,7 @@ export default defineComponent({ getRegTableNewItem, getRegTableTotalRowCount, getRegTableSortOptions, + getRegTableMhSortOptions, getMhRegTableBaseRegs, hasMorePages, myRegSort, diff --git a/ppr-ui/src/components/dashboard/DashboardTabs.vue b/ppr-ui/src/components/dashboard/DashboardTabs.vue index 2526933db..813f89d0e 100644 --- a/ppr-ui/src/components/dashboard/DashboardTabs.vue +++ b/ppr-ui/src/components/dashboard/DashboardTabs.vue @@ -104,6 +104,7 @@ export default defineComponent({ } = useStore() const { // Getters + getRegTableMhSortOptions, getMhRegTableBaseRegs, getRegTableBaseRegs, getRegTableTotalRowCount, @@ -133,7 +134,7 @@ export default defineComponent({ } onMounted(async () => { - await fetchMhRegistrations() + await fetchMhRegistrations(getRegTableMhSortOptions.value) }) return { diff --git a/ppr-ui/src/components/tables/RegistrationTable.vue b/ppr-ui/src/components/tables/RegistrationTable.vue index 0d7e5f5ad..1e964d5fb 100644 --- a/ppr-ui/src/components/tables/RegistrationTable.vue +++ b/ppr-ui/src/components/tables/RegistrationTable.vue @@ -369,7 +369,6 @@ import { computed, defineComponent, - onBeforeMount, onUpdated, reactive, ref, @@ -812,11 +811,6 @@ export default defineComponent({ { deep: true } ) - // Ensures filtering is cleared when returing to dashboard from registrations - onBeforeMount(() => { - clearFilters() - }) - onUpdated(() => { // needed to set overrideWidth to true if (localState.firstColRef?.value?.length > 0) { diff --git a/ppr-ui/src/interfaces/store-interfaces/state-interfaces/reg-table-data-interface.ts b/ppr-ui/src/interfaces/store-interfaces/state-interfaces/reg-table-data-interface.ts index 8e25b0f9d..0c6ff4f6e 100644 --- a/ppr-ui/src/interfaces/store-interfaces/state-interfaces/reg-table-data-interface.ts +++ b/ppr-ui/src/interfaces/store-interfaces/state-interfaces/reg-table-data-interface.ts @@ -21,6 +21,7 @@ export interface RegTableDataI { newItem: RegTableNewItemI sortHasMorePages: boolean sortOptions: RegistrationSortIF + mhSortOptions: RegistrationSortIF sortPage: number totalRowCount: number } diff --git a/ppr-ui/src/store/state/state-model.ts b/ppr-ui/src/store/state/state-model.ts index 81375a800..55f8bea47 100644 --- a/ppr-ui/src/store/state/state-model.ts +++ b/ppr-ui/src/store/state/state-model.ts @@ -116,6 +116,19 @@ export const stateModel: StateModelIF = { startDate: null, status: '' }, + mhSortOptions: { + endDate: null, + folNum: '', + orderBy: 'createDateTime', + orderVal: 'desc', + regBy: '', + regNum: '', + regParty: '', + regType: '', + secParty: '', + startDate: null, + status: '' + }, sortPage: 1, totalRowCount: 0 }, diff --git a/ppr-ui/src/store/store.ts b/ppr-ui/src/store/store.ts index f51113023..d27b8af9b 100644 --- a/ppr-ui/src/store/store.ts +++ b/ppr-ui/src/store/store.ts @@ -582,6 +582,9 @@ export const useStore = defineStore('assetsStore', () => { const getRegTableSortOptions = computed(() => { return state.value.registrationTable.sortOptions }) + const getRegTableMhSortOptions = computed(() => { + return state.value.registrationTable.mhSortOptions + }) const getRegTableSortPage = computed(() => { return state.value.registrationTable.sortPage }) @@ -957,19 +960,6 @@ export const useStore = defineStore('assetsStore', () => { prevDraft: '' } state.value.registrationTable.sortHasMorePages = true - state.value.registrationTable.sortOptions = { - endDate: null, - folNum: '', - orderBy: 'createDateTime', - orderVal: 'desc', - regBy: '', - regNum: '', - regParty: '', - regType: '', - secParty: '', - startDate: null, - status: '' - } state.value.registrationTable.sortPage = 1 state.value.registrationTable.totalRowCount = 0 } @@ -1223,8 +1213,10 @@ export const useStore = defineStore('assetsStore', () => { state.value.registrationTable.sortHasMorePages = hasMorePages } - function setRegTableSortOptions (options: RegistrationSortIF) { - state.value.registrationTable.sortOptions = options + function setRegTableSortOptions (options: RegistrationSortIF, isMhr: boolean = false) { + isMhr + ? state.value.registrationTable.mhSortOptions = options + : state.value.registrationTable.sortOptions = options } function setRegTableSortPage (page: number) { @@ -1644,6 +1636,7 @@ export const useStore = defineStore('assetsStore', () => { getRegTableDraftsChildReg, getRegTableNewItem, getRegTableSortOptions, + getRegTableMhSortOptions, getRegTableSortPage, getRegTableTotalRowCount, hasMorePages, diff --git a/ppr-ui/src/utils/mhr-api-helper.ts b/ppr-ui/src/utils/mhr-api-helper.ts index e63c62338..25501f6e4 100644 --- a/ppr-ui/src/utils/mhr-api-helper.ts +++ b/ppr-ui/src/utils/mhr-api-helper.ts @@ -325,6 +325,7 @@ export async function submitMhrRegistration (payloadData, staffPayment) { * Method to return Mhr registrations. * * @param withCollapse // Used to indicate whether api should return registrations collapsed + * @param sortOptions // Used to sort the registration results * @returns MhRegistrationSummaryIF */ export async function mhrRegistrationHistory (withCollapse: boolean = false, sortOptions: RegistrationSortIF = null) {