From 75e0e8ac18e812b19044aa1f3b3f0a02cc7756a3 Mon Sep 17 00:00:00 2001 From: riefive Date: Wed, 3 Dec 2025 13:36:14 +0700 Subject: [PATCH] feat: enhance filter navigation with role-based visibility and active position handling --- .../app/encounter/dropdown-action.vue | 23 ++++++++----------- app/components/content/encounter/list.vue | 5 ++-- app/components/pub/my-ui/data/types.ts | 2 +- 3 files changed, 13 insertions(+), 17 deletions(-) diff --git a/app/components/app/encounter/dropdown-action.vue b/app/components/app/encounter/dropdown-action.vue index 0cd85204..49be1df0 100644 --- a/app/components/app/encounter/dropdown-action.vue +++ b/app/components/app/encounter/dropdown-action.vue @@ -13,32 +13,30 @@ const activeServicePosition = inject>('activeServicePosition')! // p const activeKey = ref(null) const linkItemsFiltered = ref([]) + const baseLinkItems: LinkItem[] = [ { label: 'Detail', value: 'detail', + groups: ['medical', 'registration'], onClick: () => { proceedItem(ActionEvents.showDetail) }, icon: 'i-lucide-eye', }, -] - -const medicalLinkItems: LinkItem[] = [ { label: 'Process', value: 'process', + groups: ['registration'], onClick: () => { proceedItem(ActionEvents.showProcess) }, icon: 'i-lucide-shuffle', }, -] - -const regLinkItems: LinkItem[] = [ { label: 'Print', value: 'print', + groups: ['registration'], onClick: () => { proceedItem(ActionEvents.showPrint) }, @@ -47,6 +45,7 @@ const regLinkItems: LinkItem[] = [ { label: 'Batalkan', value: 'cancel', + groups: ['registration'], onClick: () => { proceedItem(ActionEvents.showCancel) }, @@ -55,6 +54,7 @@ const regLinkItems: LinkItem[] = [ { label: 'Hapus', value: 'remove', + groups: ['registration'], onClick: () => { proceedItem(ActionEvents.showConfirmDelete) }, @@ -62,7 +62,7 @@ const regLinkItems: LinkItem[] = [ }, ] -const voidLinkItems: LinkItem[] = [ +const noneLinkItems: LinkItem[] = [ { label: 'Nothing', value: 'nothing', @@ -87,15 +87,12 @@ function proceedItem(action: string) { function getLinks() { switch (activeServicePosition.value) { case 'medical': - linkItemsFiltered.value = [...baseLinkItems, ...medicalLinkItems] + linkItemsFiltered.value = baseLinkItems.filter((item) => item.groups?.includes('medical')) break case 'registration': - linkItemsFiltered.value = [...baseLinkItems, ...regLinkItems] - case 'unit|resp': - linkItemsFiltered.value = [...baseLinkItems] - break + linkItemsFiltered.value = baseLinkItems.filter((item) => item.groups?.includes('medical')) default: - linkItemsFiltered.value = voidLinkItems + linkItemsFiltered.value = noneLinkItems break } } diff --git a/app/components/content/encounter/list.vue b/app/components/content/encounter/list.vue index 11e08301..12c8badd 100644 --- a/app/components/content/encounter/list.vue +++ b/app/components/content/encounter/list.vue @@ -106,14 +106,12 @@ watch(getActiveRole, (role? : string) => { watch(() => recAction.value, () => { const basePath = `/${props.classCode}/encounter` - // console.log(`${basePath}/${recId.value}`, recAction.value) - // return if (recAction.value === ActionEvents.showConfirmDelete) { isRecordConfirmationOpen.value = true } else if (recAction.value === ActionEvents.showCancel) { isRecordCancelOpen.value = true } else if (recAction.value === ActionEvents.showDetail) { - navigateTo(`${basePath}/${recId.value}`) + navigateTo(`${basePath}/${recId.value}/detail`) } else if (recAction.value === ActionEvents.showEdit) { navigateTo(`${basePath}/${recId.value}/edit`) } else if (recAction.value === ActionEvents.showProcess) { @@ -142,6 +140,7 @@ async function getPatientList() { const result = await getEncounterList(params) if (result.success) { data.value = result.body?.data || [] + dataFiltered.value = [...data.value] } } catch (error) { console.error('Error fetching encounter list:', error) diff --git a/app/components/pub/my-ui/data/types.ts b/app/components/pub/my-ui/data/types.ts index 6338667f..126c5d8d 100644 --- a/app/components/pub/my-ui/data/types.ts +++ b/app/components/pub/my-ui/data/types.ts @@ -75,6 +75,7 @@ export interface LinkItem { icon?: string href?: string // to cover the needs of stating full external origins full url action?: string // for local paths + groups?: string[] onClick?: (event: Event) => void headerStatus?: boolean } @@ -89,7 +90,6 @@ export const ActionEvents = { showVerify: 'showVerify', showConfirmVerify: 'showConfirmVerify', showValidate: 'showValidate', - showConfirmVerify: 'showConfirmVerify', showPrint: 'showPrint', }