feat: enhance filter navigation with role-based visibility and active position handling

This commit is contained in:
riefive
2025-12-03 13:36:14 +07:00
parent 4c670701c4
commit 75e0e8ac18
3 changed files with 13 additions and 17 deletions
@@ -13,32 +13,30 @@ const activeServicePosition = inject<Ref<string>>('activeServicePosition')! // p
const activeKey = ref<string | null>(null)
const linkItemsFiltered = ref<LinkItem[]>([])
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
}
}
+2 -3
View File
@@ -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)
+1 -1
View File
@@ -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',
}