Skip to content

Commit

Permalink
Preserve Table Filters for both PPR/MHR (#2005)
Browse files Browse the repository at this point in the history
* Preserve Table Filters for both PPR/MHR

* clean up
  • Loading branch information
cameron-eyds authored Aug 22, 2024
1 parent cd9b7a2 commit b71479b
Show file tree
Hide file tree
Showing 9 changed files with 41 additions and 40 deletions.
4 changes: 2 additions & 2 deletions ppr-ui/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion ppr-ui/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "ppr-ui",
"version": "3.2.47",
"version": "3.2.48",
"private": true,
"appName": "Assets UI",
"sbcName": "SBC Common Components",
Expand Down
28 changes: 13 additions & 15 deletions ppr-ui/src/components/common/RegistrationsWrapper.vue
Original file line number Diff line number Diff line change
Expand Up @@ -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)"
Expand Down Expand Up @@ -357,19 +357,16 @@ export default defineComponent({
getRegTableBaseRegs, getRegTableDraftsBaseReg, isMhrRegistration, isMhrManufacturerRegistration,
getRegTableTotalRowCount, getStateModel, getRegTableDraftsChildReg, hasMorePages, getRegTableNewItem,
getRegTableSortOptions, getRegTableSortPage, getUserSettings, getMhRegTableBaseRegs, isRoleStaffReg,
isRoleQualifiedSupplier
isRoleQualifiedSupplier, getRegTableMhSortOptions
} = storeToRefs(useStore())
const {
initNewMhr,
initNewManufacturerMhr,
fetchMhRegistrations
} = useNewMhrRegistration(true)
const { initDraftMhrCorrection } = useMhrCorrections()
const { goToExemptions } = useExemptions()
const { initMhrReRegistration, initDraftMhrReRegistration } = useMhrReRegistration()
const localState = reactive({
Expand Down Expand Up @@ -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
Expand All @@ -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)
}
Expand Down Expand Up @@ -703,7 +700,7 @@ export default defineComponent({
prevDraft: ''
}
setRegTableNewItem(newRegItem)
await fetchMhRegistrations()
await fetchMhRegistrations(getRegTableMhSortOptions.value)
}
localState.loading = false
}
Expand Down Expand Up @@ -869,7 +866,7 @@ export default defineComponent({
const removeMhrDraft = async (mhrNumber: string): Promise<void> => {
localState.myRegDataLoading = true
await deleteMhrDraft(mhrNumber)
await fetchMhRegistrations() // Refresh the table with update Registration History
await fetchMhRegistrations(getRegTableMhSortOptions.value)
localState.myRegDataLoading = false
}
Expand Down Expand Up @@ -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 {
Expand Down Expand Up @@ -1029,7 +1026,7 @@ export default defineComponent({
const myRegSort = async (args: { sortOptions: RegistrationSortIF, sorting: boolean }): Promise<void> => {
localState.myRegDataLoading = true
setRegTableSortOptions(args.sortOptions)
setRegTableSortOptions(args.sortOptions, props.isMhr)
const sorting = args.sorting
let sortedDrafts = { drafts: [] as DraftResultIF[], error: null }
Expand Down Expand Up @@ -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
}
Expand All @@ -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
Expand Down Expand Up @@ -1177,7 +1174,7 @@ export default defineComponent({
}
}
} else {
await fetchMhRegistrations()
await fetchMhRegistrations(getRegTableMhSortOptions.value)
}
localState.myRegDataAdding = false
Expand Down Expand Up @@ -1282,6 +1279,7 @@ export default defineComponent({
getRegTableNewItem,
getRegTableTotalRowCount,
getRegTableSortOptions,
getRegTableMhSortOptions,
getMhRegTableBaseRegs,
hasMorePages,
myRegSort,
Expand Down
3 changes: 2 additions & 1 deletion ppr-ui/src/components/dashboard/DashboardTabs.vue
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,7 @@ export default defineComponent({
} = useStore()
const {
// Getters
getRegTableMhSortOptions,
getMhRegTableBaseRegs,
getRegTableBaseRegs,
getRegTableTotalRowCount,
Expand Down Expand Up @@ -133,7 +134,7 @@ export default defineComponent({
}
onMounted(async () => {
await fetchMhRegistrations()
await fetchMhRegistrations(getRegTableMhSortOptions.value)
})
return {
Expand Down
6 changes: 0 additions & 6 deletions ppr-ui/src/components/tables/RegistrationTable.vue
Original file line number Diff line number Diff line change
Expand Up @@ -369,7 +369,6 @@
import {
computed,
defineComponent,
onBeforeMount,
onUpdated,
reactive,
ref,
Expand Down Expand Up @@ -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) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ export interface RegTableDataI {
newItem: RegTableNewItemI
sortHasMorePages: boolean
sortOptions: RegistrationSortIF
mhSortOptions: RegistrationSortIF
sortPage: number
totalRowCount: number
}
13 changes: 13 additions & 0 deletions ppr-ui/src/store/state/state-model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
},
Expand Down
23 changes: 8 additions & 15 deletions ppr-ui/src/store/store.ts
Original file line number Diff line number Diff line change
Expand Up @@ -582,6 +582,9 @@ export const useStore = defineStore('assetsStore', () => {
const getRegTableSortOptions = computed<RegistrationSortIF>(() => {
return state.value.registrationTable.sortOptions
})
const getRegTableMhSortOptions = computed<RegistrationSortIF>(() => {
return state.value.registrationTable.mhSortOptions
})
const getRegTableSortPage = computed<number>(() => {
return state.value.registrationTable.sortPage
})
Expand Down Expand Up @@ -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
}
Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -1644,6 +1636,7 @@ export const useStore = defineStore('assetsStore', () => {
getRegTableDraftsChildReg,
getRegTableNewItem,
getRegTableSortOptions,
getRegTableMhSortOptions,
getRegTableSortPage,
getRegTableTotalRowCount,
hasMorePages,
Expand Down
1 change: 1 addition & 0 deletions ppr-ui/src/utils/mhr-api-helper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down

0 comments on commit b71479b

Please sign in to comment.