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

No files matched your search

@@ -13,32 +13,30 @@ const activeServicePosition = inject<Ref<string>>('activeServicePosition')! // p
const activeKey = ref<string | null>(null) const activeKey = ref<string | null>(null)
const linkItemsFiltered = ref<LinkItem[]>([]) const linkItemsFiltered = ref<LinkItem[]>([])
const baseLinkItems: LinkItem[] = [ const baseLinkItems: LinkItem[] = [
{ {
label: 'Detail', label: 'Detail',
value: 'detail', value: 'detail',
groups: ['medical', 'registration'],
onClick: () => { onClick: () => {
proceedItem(ActionEvents.showDetail) proceedItem(ActionEvents.showDetail)
}, },
icon: 'i-lucide-eye', icon: 'i-lucide-eye',
}, },
]
const medicalLinkItems: LinkItem[] = [
{ {
label: 'Process', label: 'Process',
value: 'process', value: 'process',
groups: ['registration'],
onClick: () => { onClick: () => {
proceedItem(ActionEvents.showProcess) proceedItem(ActionEvents.showProcess)
}, },
icon: 'i-lucide-shuffle', icon: 'i-lucide-shuffle',
}, },
]
const regLinkItems: LinkItem[] = [
{ {
label: 'Print', label: 'Print',
value: 'print', value: 'print',
groups: ['registration'],
onClick: () => { onClick: () => {
proceedItem(ActionEvents.showPrint) proceedItem(ActionEvents.showPrint)
}, },
@@ -47,6 +45,7 @@ const regLinkItems: LinkItem[] = [
{ {
label: 'Batalkan', label: 'Batalkan',
value: 'cancel', value: 'cancel',
groups: ['registration'],
onClick: () => { onClick: () => {
proceedItem(ActionEvents.showCancel) proceedItem(ActionEvents.showCancel)
}, },
@@ -55,6 +54,7 @@ const regLinkItems: LinkItem[] = [
{ {
label: 'Hapus', label: 'Hapus',
value: 'remove', value: 'remove',
groups: ['registration'],
onClick: () => { onClick: () => {
proceedItem(ActionEvents.showConfirmDelete) proceedItem(ActionEvents.showConfirmDelete)
}, },
@@ -62,7 +62,7 @@ const regLinkItems: LinkItem[] = [
}, },
] ]
const voidLinkItems: LinkItem[] = [ const noneLinkItems: LinkItem[] = [
{ {
label: 'Nothing', label: 'Nothing',
value: 'nothing', value: 'nothing',
@@ -87,15 +87,12 @@ function proceedItem(action: string) {
function getLinks() { function getLinks() {
switch (activeServicePosition.value) { switch (activeServicePosition.value) {
case 'medical': case 'medical':
linkItemsFiltered.value = [...baseLinkItems, ...medicalLinkItems] linkItemsFiltered.value = baseLinkItems.filter((item) => item.groups?.includes('medical'))
break break
case 'registration': case 'registration':
linkItemsFiltered.value = [...baseLinkItems, ...regLinkItems] linkItemsFiltered.value = baseLinkItems.filter((item) => item.groups?.includes('medical'))
case 'unit|resp':
linkItemsFiltered.value = [...baseLinkItems]
break
default: default:
linkItemsFiltered.value = voidLinkItems linkItemsFiltered.value = noneLinkItems
break break
} }
} }
+2 -3
View File
@@ -106,14 +106,12 @@ watch(getActiveRole, (role? : string) => {
watch(() => recAction.value, () => { watch(() => recAction.value, () => {
const basePath = `/${props.classCode}/encounter` const basePath = `/${props.classCode}/encounter`
// console.log(`${basePath}/${recId.value}`, recAction.value)
// return
if (recAction.value === ActionEvents.showConfirmDelete) { if (recAction.value === ActionEvents.showConfirmDelete) {
isRecordConfirmationOpen.value = true isRecordConfirmationOpen.value = true
} else if (recAction.value === ActionEvents.showCancel) { } else if (recAction.value === ActionEvents.showCancel) {
isRecordCancelOpen.value = true isRecordCancelOpen.value = true
} else if (recAction.value === ActionEvents.showDetail) { } else if (recAction.value === ActionEvents.showDetail) {
navigateTo(`${basePath}/${recId.value}`) navigateTo(`${basePath}/${recId.value}/detail`)
} else if (recAction.value === ActionEvents.showEdit) { } else if (recAction.value === ActionEvents.showEdit) {
navigateTo(`${basePath}/${recId.value}/edit`) navigateTo(`${basePath}/${recId.value}/edit`)
} else if (recAction.value === ActionEvents.showProcess) { } else if (recAction.value === ActionEvents.showProcess) {
@@ -142,6 +140,7 @@ async function getPatientList() {
const result = await getEncounterList(params) const result = await getEncounterList(params)
if (result.success) { if (result.success) {
data.value = result.body?.data || [] data.value = result.body?.data || []
dataFiltered.value = [...data.value]
} }
} catch (error) { } catch (error) {
console.error('Error fetching encounter list:', error) console.error('Error fetching encounter list:', error)
+1 -1
View File
@@ -75,6 +75,7 @@ export interface LinkItem {
icon?: string icon?: string
href?: string // to cover the needs of stating full external origins full url href?: string // to cover the needs of stating full external origins full url
action?: string // for local paths action?: string // for local paths
groups?: string[]
onClick?: (event: Event) => void onClick?: (event: Event) => void
headerStatus?: boolean headerStatus?: boolean
} }
@@ -89,7 +90,6 @@ export const ActionEvents = {
showVerify: 'showVerify', showVerify: 'showVerify',
showConfirmVerify: 'showConfirmVerify', showConfirmVerify: 'showConfirmVerify',
showValidate: 'showValidate', showValidate: 'showValidate',
showConfirmVerify: 'showConfirmVerify',
showPrint: 'showPrint', showPrint: 'showPrint',
} }