fix(encounter): add guard for encounter home
This commit is contained in:
@@ -10,11 +10,19 @@ const recId = inject<Ref<number>>('rec_id')!
|
||||
const recAction = inject<Ref<string>>('rec_action')!
|
||||
const recItem = inject<Ref<any>>('rec_item')!
|
||||
const activeKey = ref<string | null>(null)
|
||||
const activePosition = inject<Ref<string>>('position')
|
||||
const activePosition = inject<Ref<string>>('position')!
|
||||
const linkItemsFiltered = ref<LinkItem[]>([])
|
||||
const linkItemsBase: LinkItem[] = [
|
||||
{
|
||||
label: 'Nothing',
|
||||
value: 'nothing',
|
||||
icon: 'i-lucide-file',
|
||||
},
|
||||
]
|
||||
const linkItems: LinkItem[] = [
|
||||
{
|
||||
label: 'Detail',
|
||||
value: 'detail',
|
||||
onClick: () => {
|
||||
detail()
|
||||
},
|
||||
@@ -22,6 +30,7 @@ const linkItems: LinkItem[] = [
|
||||
},
|
||||
{
|
||||
label: 'Edit',
|
||||
value: 'edit',
|
||||
onClick: () => {
|
||||
edit()
|
||||
},
|
||||
@@ -29,6 +38,7 @@ const linkItems: LinkItem[] = [
|
||||
},
|
||||
{
|
||||
label: 'Print',
|
||||
value: 'print',
|
||||
onClick: () => {
|
||||
print()
|
||||
},
|
||||
@@ -36,6 +46,7 @@ const linkItems: LinkItem[] = [
|
||||
},
|
||||
{
|
||||
label: 'Batalkan',
|
||||
value: 'cancel',
|
||||
onClick: () => {
|
||||
cancel()
|
||||
},
|
||||
@@ -43,6 +54,7 @@ const linkItems: LinkItem[] = [
|
||||
},
|
||||
{
|
||||
label: 'Hapus',
|
||||
value: 'remove',
|
||||
onClick: () => {
|
||||
remove()
|
||||
},
|
||||
@@ -80,23 +92,29 @@ function remove() {
|
||||
recItem.value = props.rec
|
||||
}
|
||||
|
||||
linkItemsFiltered.value = [...linkItems]
|
||||
linkItemsFiltered.value = [...linkItemsBase]
|
||||
|
||||
if (activePosition) {
|
||||
switch (activePosition.value) {
|
||||
function getLinks(position: string) {
|
||||
switch (position) {
|
||||
case 'medical':
|
||||
linkItemsFiltered.value = [...linkItems]
|
||||
break
|
||||
case 'verificator':
|
||||
linkItemsFiltered.value = [
|
||||
...linkItems.filter((item) => ['Detail', 'Print'].includes(item.label)),
|
||||
...linkItems.filter((item) => ['detail', 'print'].includes(item.value || '')),
|
||||
]
|
||||
break
|
||||
default:
|
||||
linkItemsFiltered.value = [...linkItems]
|
||||
linkItemsFiltered.value = [...linkItemsBase]
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
getLinks(activePosition.value)
|
||||
|
||||
watch(activePosition, () => {
|
||||
getLinks(activePosition.value)
|
||||
})
|
||||
</script>
|
||||
|
||||
<template>
|
||||
@@ -119,7 +137,7 @@ if (activePosition) {
|
||||
>
|
||||
<DropdownMenuGroup>
|
||||
<DropdownMenuItem
|
||||
v-for="item in linkItems"
|
||||
v-for="item in linkItemsFiltered"
|
||||
:key="item.label"
|
||||
class="hover:bg-gray-100 dark:hover:bg-slate-700"
|
||||
@click="item.onClick"
|
||||
|
||||
Reference in New Issue
Block a user