diff --git a/app/components/app/encounter/dropdown-action.vue b/app/components/app/encounter/dropdown-action.vue index bd7a4974..0cd85204 100644 --- a/app/components/app/encounter/dropdown-action.vue +++ b/app/components/app/encounter/dropdown-action.vue @@ -9,38 +9,38 @@ const props = defineProps<{ const recId = inject>('rec_id')! const recAction = inject>('rec_action')! const recItem = inject>('rec_item')! +const activeServicePosition = inject>('activeServicePosition')! // previously: activePosition + const activeKey = ref(null) -const activePosition = inject>('position')! const linkItemsFiltered = ref([]) -const linkItemsBase: LinkItem[] = [ - { - label: 'Nothing', - value: 'nothing', - icon: 'i-lucide-file', - }, -] -const linkItems: LinkItem[] = [ +const baseLinkItems: LinkItem[] = [ { label: 'Detail', value: 'detail', onClick: () => { - detail() + proceedItem(ActionEvents.showDetail) }, icon: 'i-lucide-eye', }, +] + +const medicalLinkItems: LinkItem[] = [ { label: 'Process', - value: 'edit', + value: 'process', onClick: () => { - edit() + proceedItem(ActionEvents.showProcess) }, - icon: 'i-lucide-pencil', + icon: 'i-lucide-shuffle', }, +] + +const regLinkItems: LinkItem[] = [ { label: 'Print', value: 'print', onClick: () => { - print() + proceedItem(ActionEvents.showPrint) }, icon: 'i-lucide-printer', }, @@ -48,7 +48,7 @@ const linkItems: LinkItem[] = [ label: 'Batalkan', value: 'cancel', onClick: () => { - cancel() + proceedItem(ActionEvents.showCancel) }, icon: 'i-lucide-circle-x', }, @@ -56,65 +56,49 @@ const linkItems: LinkItem[] = [ label: 'Hapus', value: 'remove', onClick: () => { - remove() + proceedItem(ActionEvents.showConfirmDelete) }, icon: 'i-lucide-trash', }, ] -function detail() { +const voidLinkItems: LinkItem[] = [ + { + label: 'Nothing', + value: 'nothing', + icon: 'i-lucide-file', + }, +] + +linkItemsFiltered.value = [...baseLinkItems] + +getLinks() + +watch(activeServicePosition, () => { + getLinks() +}) + +function proceedItem(action: string) { recId.value = props.rec.id || 0 - recAction.value = ActionEvents.showDetail recItem.value = props.rec + recAction.value = action } -function edit() { - recId.value = props.rec.id || 0 - recAction.value = ActionEvents.showEdit - recItem.value = props.rec -} - -function print() { - recId.value = props.rec.id || 0 - recAction.value = ActionEvents.showPrint - recItem.value = props.rec -} - -function cancel() { - recId.value = props.rec.id || 0 - recAction.value = ActionEvents.showCancel - recItem.value = props.rec -} - -function remove() { - recId.value = props.rec.id || 0 - recAction.value = ActionEvents.showConfirmDelete - recItem.value = props.rec -} - -linkItemsFiltered.value = [...linkItemsBase] - -function getLinks(position: string) { - switch (position) { +function getLinks() { + switch (activeServicePosition.value) { case 'medical': - linkItemsFiltered.value = [...linkItems] + linkItemsFiltered.value = [...baseLinkItems, ...medicalLinkItems] break - case 'verificator': - linkItemsFiltered.value = [ - ...linkItems.filter((item) => ['detail', 'print'].includes(item.value || '')), - ] + case 'registration': + linkItemsFiltered.value = [...baseLinkItems, ...regLinkItems] + case 'unit|resp': + linkItemsFiltered.value = [...baseLinkItems] break default: - linkItemsFiltered.value = [...linkItemsBase] + linkItemsFiltered.value = voidLinkItems break } } - -getLinks(activePosition.value) - -watch(activePosition, () => { - getLinks(activePosition.value) -})