fix(encounter): add guard for encounter home
This commit is contained in:
No files matched your search
@@ -10,11 +10,19 @@ const recId = inject<Ref<number>>('rec_id')!
|
|||||||
const recAction = inject<Ref<string>>('rec_action')!
|
const recAction = inject<Ref<string>>('rec_action')!
|
||||||
const recItem = inject<Ref<any>>('rec_item')!
|
const recItem = inject<Ref<any>>('rec_item')!
|
||||||
const activeKey = ref<string | null>(null)
|
const activeKey = ref<string | null>(null)
|
||||||
const activePosition = inject<Ref<string>>('position')
|
const activePosition = inject<Ref<string>>('position')!
|
||||||
const linkItemsFiltered = ref<LinkItem[]>([])
|
const linkItemsFiltered = ref<LinkItem[]>([])
|
||||||
|
const linkItemsBase: LinkItem[] = [
|
||||||
|
{
|
||||||
|
label: 'Nothing',
|
||||||
|
value: 'nothing',
|
||||||
|
icon: 'i-lucide-file',
|
||||||
|
},
|
||||||
|
]
|
||||||
const linkItems: LinkItem[] = [
|
const linkItems: LinkItem[] = [
|
||||||
{
|
{
|
||||||
label: 'Detail',
|
label: 'Detail',
|
||||||
|
value: 'detail',
|
||||||
onClick: () => {
|
onClick: () => {
|
||||||
detail()
|
detail()
|
||||||
},
|
},
|
||||||
@@ -22,6 +30,7 @@ const linkItems: LinkItem[] = [
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
label: 'Edit',
|
label: 'Edit',
|
||||||
|
value: 'edit',
|
||||||
onClick: () => {
|
onClick: () => {
|
||||||
edit()
|
edit()
|
||||||
},
|
},
|
||||||
@@ -29,6 +38,7 @@ const linkItems: LinkItem[] = [
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
label: 'Print',
|
label: 'Print',
|
||||||
|
value: 'print',
|
||||||
onClick: () => {
|
onClick: () => {
|
||||||
print()
|
print()
|
||||||
},
|
},
|
||||||
@@ -36,6 +46,7 @@ const linkItems: LinkItem[] = [
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
label: 'Batalkan',
|
label: 'Batalkan',
|
||||||
|
value: 'cancel',
|
||||||
onClick: () => {
|
onClick: () => {
|
||||||
cancel()
|
cancel()
|
||||||
},
|
},
|
||||||
@@ -43,6 +54,7 @@ const linkItems: LinkItem[] = [
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
label: 'Hapus',
|
label: 'Hapus',
|
||||||
|
value: 'remove',
|
||||||
onClick: () => {
|
onClick: () => {
|
||||||
remove()
|
remove()
|
||||||
},
|
},
|
||||||
@@ -80,23 +92,29 @@ function remove() {
|
|||||||
recItem.value = props.rec
|
recItem.value = props.rec
|
||||||
}
|
}
|
||||||
|
|
||||||
linkItemsFiltered.value = [...linkItems]
|
linkItemsFiltered.value = [...linkItemsBase]
|
||||||
|
|
||||||
if (activePosition) {
|
function getLinks(position: string) {
|
||||||
switch (activePosition.value) {
|
switch (position) {
|
||||||
case 'medical':
|
case 'medical':
|
||||||
linkItemsFiltered.value = [...linkItems]
|
linkItemsFiltered.value = [...linkItems]
|
||||||
break
|
break
|
||||||
case 'verificator':
|
case 'verificator':
|
||||||
linkItemsFiltered.value = [
|
linkItemsFiltered.value = [
|
||||||
...linkItems.filter((item) => ['Detail', 'Print'].includes(item.label)),
|
...linkItems.filter((item) => ['detail', 'print'].includes(item.value || '')),
|
||||||
]
|
]
|
||||||
break
|
break
|
||||||
default:
|
default:
|
||||||
linkItemsFiltered.value = [...linkItems]
|
linkItemsFiltered.value = [...linkItemsBase]
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
getLinks(activePosition.value)
|
||||||
|
|
||||||
|
watch(activePosition, () => {
|
||||||
|
getLinks(activePosition.value)
|
||||||
|
})
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
@@ -119,7 +137,7 @@ if (activePosition) {
|
|||||||
>
|
>
|
||||||
<DropdownMenuGroup>
|
<DropdownMenuGroup>
|
||||||
<DropdownMenuItem
|
<DropdownMenuItem
|
||||||
v-for="item in linkItems"
|
v-for="item in linkItemsFiltered"
|
||||||
:key="item.label"
|
:key="item.label"
|
||||||
class="hover:bg-gray-100 dark:hover:bg-slate-700"
|
class="hover:bg-gray-100 dark:hover:bg-slate-700"
|
||||||
@click="item.onClick"
|
@click="item.onClick"
|
||||||
|
|||||||
@@ -44,9 +44,12 @@ const activeTab = computed({
|
|||||||
})
|
})
|
||||||
|
|
||||||
const id = typeof route.params.id == 'string' ? parseInt(route.params.id) : 0
|
const id = typeof route.params.id == 'string' ? parseInt(route.params.id) : 0
|
||||||
|
|
||||||
const data = ref<any>(null)
|
const data = ref<any>(null)
|
||||||
|
|
||||||
|
if (activePosition.value === 'none') { // if user position is none, redirect to home page
|
||||||
|
router.push('/')
|
||||||
|
}
|
||||||
|
|
||||||
// Function to check if date is invalid (like "0001-01-01T00:00:00Z")
|
// Function to check if date is invalid (like "0001-01-01T00:00:00Z")
|
||||||
function isValidDate(dateString: string | null | undefined): boolean {
|
function isValidDate(dateString: string | null | undefined): boolean {
|
||||||
if (!dateString) return false
|
if (!dateString) return false
|
||||||
|
|||||||
@@ -64,6 +64,7 @@ export interface KeyNames {
|
|||||||
|
|
||||||
export interface LinkItem {
|
export interface LinkItem {
|
||||||
label: string
|
label: string
|
||||||
|
value?: string
|
||||||
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
|
||||||
|
|||||||
Reference in New Issue
Block a user