diff --git a/app/components/app/encounter/dropdown-action.vue b/app/components/app/encounter/dropdown-action.vue index 0cd85204..0815e6a7 100644 --- a/app/components/app/encounter/dropdown-action.vue +++ b/app/components/app/encounter/dropdown-action.vue @@ -13,32 +13,39 @@ 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: 'Edit', + value: 'edit', + groups: ['registration'], + onClick: () => { + proceedItem(ActionEvents.showEdit) + }, + icon: 'i-lucide-pencil', + }, { label: 'Process', value: 'process', + groups: ['medical'], onClick: () => { proceedItem(ActionEvents.showProcess) }, icon: 'i-lucide-shuffle', }, -] - -const regLinkItems: LinkItem[] = [ { label: 'Print', value: 'print', + groups: ['registration'], onClick: () => { proceedItem(ActionEvents.showPrint) }, @@ -47,6 +54,7 @@ const regLinkItems: LinkItem[] = [ { label: 'Batalkan', value: 'cancel', + groups: ['registration'], onClick: () => { proceedItem(ActionEvents.showCancel) }, @@ -55,6 +63,7 @@ const regLinkItems: LinkItem[] = [ { label: 'Hapus', value: 'remove', + groups: ['registration'], onClick: () => { proceedItem(ActionEvents.showConfirmDelete) }, @@ -62,7 +71,7 @@ const regLinkItems: LinkItem[] = [ }, ] -const voidLinkItems: LinkItem[] = [ +const noneLinkItems: LinkItem[] = [ { label: 'Nothing', value: 'nothing', @@ -72,12 +81,6 @@ const voidLinkItems: LinkItem[] = [ linkItemsFiltered.value = [...baseLinkItems] -getLinks() - -watch(activeServicePosition, () => { - getLinks() -}) - function proceedItem(action: string) { recId.value = props.rec.id || 0 recItem.value = props.rec @@ -87,18 +90,24 @@ 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] + linkItemsFiltered.value = baseLinkItems.filter((item) => item.groups?.includes('registration')) break default: - linkItemsFiltered.value = voidLinkItems + linkItemsFiltered.value = noneLinkItems break } } + +watch(activeServicePosition, () => { + getLinks() +}) + +onMounted(() => { + getLinks() +})