Skip to content

Commit 3909f60

Browse files
authored
feat: implemented routing to registrations from registrations table (bcgov#1004)
1 parent 8572a99 commit 3909f60

2 files changed

Lines changed: 63 additions & 8 deletions

File tree

strr-examiner-web/app/pages/dashboard.vue

Lines changed: 62 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@ import isEmpty from 'lodash/isEmpty'
33
import { sub } from 'date-fns'
44
55
const localePath = useLocalePath()
6+
const route = useRoute()
7+
const router = useRouter()
68
const { t } = useNuxtApp().$i18n
79
// TODO: ApplicationStatus.FULL_REVIEW is temporary until we have reqs defined
810
// const { limit, page, getApplicationList } = useStrrBasePermitList(undefined, undefined) // leaving this for reference
@@ -83,7 +85,36 @@ const enableLastModifiedFilter = computed<boolean>(() => {
8385
})
8486
8587
// applications or registration tab in split dashboard view
86-
const isApplicationTab = ref(true)
88+
// Initialize from query parameter to persist state across navigation
89+
// Check for 'returnTab' first (when coming back from registration page), then 'tab'
90+
const getInitialTab = () => {
91+
const returnTab = route.query.returnTab as string
92+
const tab = route.query.tab as string
93+
if (returnTab) {
94+
return returnTab === 'applications'
95+
}
96+
if (tab) {
97+
return tab !== 'registrations'
98+
}
99+
return true // default to applications
100+
}
101+
102+
const isApplicationTab = ref(getInitialTab())
103+
104+
// Watch for route query changes to restore tab state when navigating back
105+
// Only handle returnTab (from registration page), tab is managed by updateTabQuery
106+
watch(() => route.query.returnTab, (returnTab) => {
107+
if (returnTab) {
108+
isApplicationTab.value = returnTab === 'applications'
109+
// Clean up returnTab from URL after using it and preserve tab parameter
110+
const query = { ...route.query }
111+
delete query.returnTab
112+
if (!query.tab) {
113+
query.tab = returnTab === 'applications' ? 'applications' : 'registrations'
114+
}
115+
router.replace({ query })
116+
}
117+
}, { immediate: true })
87118
88119
useHead({
89120
title: t('page.dashboardList.title')
@@ -330,6 +361,7 @@ const { data: registrationListResp, status: regStatus } = await useAsyncData(
330361
return { registrations: [], total: 0 }
331362
}
332363
const registrations = res.registrations.map((reg: HousRegistrationResponse) => ({
364+
id: reg.id,
333365
registrationNumber: reg.registrationNumber,
334366
status: reg.status,
335367
sortOrder: reg.sortOrder,
@@ -456,16 +488,24 @@ const sort = ref<TableSort>({ column: 'submissionDate', direction: 'asc' as cons
456488
457489
async function handleRowSelect (row: any) {
458490
// Fix: Filter Input Double Click Event Propagation
459-
if (!row.applicationNumber) {
491+
// Handle applications
492+
if (row.applicationNumber) {
493+
status.value = 'pending'
494+
await navigateTo(localePath(`${RoutesE.EXAMINE}/${row.applicationNumber}`))
460495
return
461496
}
462-
status.value = 'pending'
463-
await navigateTo(localePath(`${RoutesE.EXAMINE}/${row.applicationNumber}`))
497+
// Handle registrations - preserve tab state in query parameter
498+
if (row.id) {
499+
regStatus.value = 'pending'
500+
const currentTab = isApplicationTab.value ? 'applications' : 'registrations'
501+
await navigateTo(localePath(`${RoutesE.REGISTRATION}/${row.id}?returnTab=${currentTab}`))
502+
}
464503
}
465504
466505
async function goToRegistration (registrationId: string) {
467-
status.value = 'pending'
468-
await navigateTo(localePath(`${RoutesE.REGISTRATION}/${registrationId}`))
506+
regStatus.value = 'pending'
507+
const currentTab = isApplicationTab.value ? 'applications' : 'registrations'
508+
await navigateTo(localePath(`${RoutesE.REGISTRATION}/${registrationId}?returnTab=${currentTab}`))
469509
}
470510
471511
function handleColumnSort (column: string) {
@@ -518,17 +558,32 @@ const statusFilterOptions = computed((): { label: string; value: any; disabled?:
518558
return isApplicationTab.value ? applicationStatusOptions : registrationStatusOptions
519559
})
520560
561+
// Update query parameter when tab changes to persist state
562+
const updateTabQuery = (isApp: boolean) => {
563+
const query = { ...route.query }
564+
if (isApp) {
565+
query.tab = 'applications'
566+
} else {
567+
query.tab = 'registrations'
568+
}
569+
router.replace({ query })
570+
}
571+
521572
const tabLinks = computed(() => [
522573
{
523574
label: t('label.newApplicationsTab'),
524-
click: () => { isApplicationTab.value = true },
575+
click: () => {
576+
isApplicationTab.value = true
577+
updateTabQuery(true)
578+
},
525579
active: isApplicationTab.value
526580
},
527581
{
528582
label: t('label.registrationsAndRenewalsTab'),
529583
click: () => {
530584
exStore.resetFilters()
531585
isApplicationTab.value = false
586+
updateTabQuery(false)
532587
},
533588
active: !isApplicationTab.value
534589
}

strr-examiner-web/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"name": "strr-examiner-web",
33
"private": true,
44
"type": "module",
5-
"version": "0.2.4",
5+
"version": "0.2.5",
66
"scripts": {
77
"build-check": "nuxt build",
88
"build": "nuxt generate",

0 commit comments

Comments
 (0)