feat: update role permissions and clean up access checks in encounter edit and add pages
This commit is contained in:
No files matched your search
@@ -1,43 +1,40 @@
|
|||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import type { PagePermission } from '~/models/role'
|
import type { Permission } from '~/models/role'
|
||||||
|
import { permissions } from '~/const/page-permission/emergency'
|
||||||
import Error from '~/components/pub/my-ui/error/error.vue'
|
import Error from '~/components/pub/my-ui/error/error.vue'
|
||||||
import { PAGE_PERMISSIONS } from '~/lib/page-permission'
|
|
||||||
import Content from '~/components/content/encounter/entry.vue'
|
import Content from '~/components/content/encounter/entry.vue'
|
||||||
|
|
||||||
definePageMeta({
|
definePageMeta({
|
||||||
middleware: ['rbac'],
|
middleware: ['rbac'],
|
||||||
roles: ['doctor', 'nurse', 'admisi', 'pharmacy', 'billing', 'management'],
|
roles: ['emp|reg'],
|
||||||
title: 'Edit Kunjungan',
|
title: 'Edit Kunjungan',
|
||||||
contentFrame: 'cf-full-width',
|
contentFrame: 'cf-full-width',
|
||||||
})
|
})
|
||||||
|
|
||||||
const route = useRoute()
|
// Preps role checking
|
||||||
|
const roleAccess: Record<string, Permission[]> = permissions['/emergency/encounter'] || {}
|
||||||
useHead({
|
|
||||||
title: () => `${route.meta.title}`,
|
|
||||||
})
|
|
||||||
|
|
||||||
const roleAccess: PagePermission = PAGE_PERMISSIONS['/emergency/encounter']
|
|
||||||
|
|
||||||
const { checkRole, hasUpdateAccess } = useRBAC()
|
const { checkRole, hasUpdateAccess } = useRBAC()
|
||||||
|
|
||||||
// Check if user has access to this page
|
// Check if user has access to this page
|
||||||
const hasAccess = checkRole(roleAccess)
|
const hasAccess = checkRole(roleAccess)
|
||||||
if (!hasAccess) {
|
if (!hasAccess) {
|
||||||
throw createError({
|
navigateTo('/403')
|
||||||
statusCode: 403,
|
|
||||||
statusMessage: 'Access denied',
|
|
||||||
})
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Define permission-based computed properties
|
// Page needs
|
||||||
const canUpdate = hasUpdateAccess(roleAccess)
|
const route = useRoute()
|
||||||
|
useHead({
|
||||||
|
title: () => route.meta.title as string,
|
||||||
|
})
|
||||||
|
|
||||||
// Get encounter ID from route params
|
// Get encounter ID from route params
|
||||||
const encounterId = computed(() => {
|
const encounterId = computed(() => {
|
||||||
const id = route.params.id
|
const id = route.params.id
|
||||||
return typeof id === 'string' ? parseInt(id) : 0
|
return typeof id === 'string' ? parseInt(id) : 0
|
||||||
})
|
})
|
||||||
|
|
||||||
|
// Define permission-based computed properties
|
||||||
|
const canUpdate = hasUpdateAccess(roleAccess)
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
|
|||||||
@@ -2,7 +2,6 @@
|
|||||||
import type { Permission } from '~/models/role'
|
import type { Permission } from '~/models/role'
|
||||||
import { permissions } from '~/const/page-permission/outpatient'
|
import { permissions } from '~/const/page-permission/outpatient'
|
||||||
import Error from '~/components/pub/my-ui/error/error.vue'
|
import Error from '~/components/pub/my-ui/error/error.vue'
|
||||||
|
|
||||||
import Content from '~/components/content/encounter/entry.vue'
|
import Content from '~/components/content/encounter/entry.vue'
|
||||||
|
|
||||||
definePageMeta({
|
definePageMeta({
|
||||||
@@ -14,7 +13,7 @@ definePageMeta({
|
|||||||
|
|
||||||
// Preps role checking
|
// Preps role checking
|
||||||
const roleAccess: Record<string, Permission[]> = permissions['/outpatient/encounter'] || {}
|
const roleAccess: Record<string, Permission[]> = permissions['/outpatient/encounter'] || {}
|
||||||
const { checkRole, hasReadAccess, hasCreateAccess } = useRBAC()
|
const { checkRole, hasCreateAccess } = useRBAC()
|
||||||
|
|
||||||
// Check if user has access to this page
|
// Check if user has access to this page
|
||||||
const hasAccess = checkRole(roleAccess)
|
const hasAccess = checkRole(roleAccess)
|
||||||
@@ -22,9 +21,6 @@ if (!hasAccess) {
|
|||||||
navigateTo('/403')
|
navigateTo('/403')
|
||||||
}
|
}
|
||||||
|
|
||||||
// Define permission-based computed properties
|
|
||||||
const canRead = hasReadAccess(roleAccess)
|
|
||||||
|
|
||||||
// Page needs
|
// Page needs
|
||||||
const route = useRoute()
|
const route = useRoute()
|
||||||
useHead({
|
useHead({
|
||||||
|
|||||||
@@ -1,43 +1,40 @@
|
|||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import type { PagePermission } from '~/models/role'
|
import type { Permission } from '~/models/role'
|
||||||
|
import { permissions } from '~/const/page-permission/inpatient'
|
||||||
import Error from '~/components/pub/my-ui/error/error.vue'
|
import Error from '~/components/pub/my-ui/error/error.vue'
|
||||||
import { PAGE_PERMISSIONS } from '~/lib/page-permission'
|
|
||||||
import Content from '~/components/content/encounter/entry.vue'
|
import Content from '~/components/content/encounter/entry.vue'
|
||||||
|
|
||||||
definePageMeta({
|
definePageMeta({
|
||||||
middleware: ['rbac'],
|
middleware: ['rbac'],
|
||||||
roles: ['doctor', 'nurse', 'admisi', 'pharmacy', 'billing', 'management'],
|
roles: ['emp|reg'],
|
||||||
title: 'Edit Kunjungan',
|
title: 'Edit Kunjungan',
|
||||||
contentFrame: 'cf-full-width',
|
contentFrame: 'cf-full-width',
|
||||||
})
|
})
|
||||||
|
|
||||||
const route = useRoute()
|
// Preps role checking
|
||||||
|
const roleAccess: Record<string, Permission[]> = permissions['/inpatient/encounter'] || {}
|
||||||
useHead({
|
|
||||||
title: () => `${route.meta.title}`,
|
|
||||||
})
|
|
||||||
|
|
||||||
const roleAccess: PagePermission = PAGE_PERMISSIONS['/inpatient/encounter']
|
|
||||||
|
|
||||||
const { checkRole, hasUpdateAccess } = useRBAC()
|
const { checkRole, hasUpdateAccess } = useRBAC()
|
||||||
|
|
||||||
// Check if user has access to this page
|
// Check if user has access to this page
|
||||||
const hasAccess = checkRole(roleAccess)
|
const hasAccess = checkRole(roleAccess)
|
||||||
if (!hasAccess) {
|
if (!hasAccess) {
|
||||||
throw createError({
|
navigateTo('/403')
|
||||||
statusCode: 403,
|
|
||||||
statusMessage: 'Access denied',
|
|
||||||
})
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Define permission-based computed properties
|
// Page needs
|
||||||
const canUpdate = hasUpdateAccess(roleAccess)
|
const route = useRoute()
|
||||||
|
useHead({
|
||||||
|
title: () => route.meta.title as string,
|
||||||
|
})
|
||||||
|
|
||||||
// Get encounter ID from route params
|
// Get encounter ID from route params
|
||||||
const encounterId = computed(() => {
|
const encounterId = computed(() => {
|
||||||
const id = route.params.id
|
const id = route.params.id
|
||||||
return typeof id === 'string' ? parseInt(id) : 0
|
return typeof id === 'string' ? parseInt(id) : 0
|
||||||
})
|
})
|
||||||
|
|
||||||
|
// Define permission-based computed properties
|
||||||
|
const canUpdate = hasUpdateAccess(roleAccess)
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
|
|||||||
@@ -2,7 +2,6 @@
|
|||||||
import type { Permission } from '~/models/role'
|
import type { Permission } from '~/models/role'
|
||||||
import { permissions } from '~/const/page-permission/outpatient'
|
import { permissions } from '~/const/page-permission/outpatient'
|
||||||
import Error from '~/components/pub/my-ui/error/error.vue'
|
import Error from '~/components/pub/my-ui/error/error.vue'
|
||||||
|
|
||||||
import Content from '~/components/content/encounter/entry.vue'
|
import Content from '~/components/content/encounter/entry.vue'
|
||||||
|
|
||||||
definePageMeta({
|
definePageMeta({
|
||||||
@@ -14,7 +13,7 @@ definePageMeta({
|
|||||||
|
|
||||||
// Preps role checking
|
// Preps role checking
|
||||||
const roleAccess: Record<string, Permission[]> = permissions['/outpatient/encounter'] || {}
|
const roleAccess: Record<string, Permission[]> = permissions['/outpatient/encounter'] || {}
|
||||||
const { checkRole, hasReadAccess, hasCreateAccess } = useRBAC()
|
const { checkRole, hasCreateAccess } = useRBAC()
|
||||||
|
|
||||||
// Check if user has access to this page
|
// Check if user has access to this page
|
||||||
const hasAccess = checkRole(roleAccess)
|
const hasAccess = checkRole(roleAccess)
|
||||||
@@ -22,9 +21,6 @@ if (!hasAccess) {
|
|||||||
navigateTo('/403')
|
navigateTo('/403')
|
||||||
}
|
}
|
||||||
|
|
||||||
// Define permission-based computed properties
|
|
||||||
const canRead = hasReadAccess(roleAccess)
|
|
||||||
|
|
||||||
// Page needs
|
// Page needs
|
||||||
const route = useRoute()
|
const route = useRoute()
|
||||||
useHead({
|
useHead({
|
||||||
|
|||||||
@@ -1,43 +1,40 @@
|
|||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import type { PagePermission } from '~/models/role'
|
import type { Permission } from '~/models/role'
|
||||||
|
import { permissions } from '~/const/page-permission/outpatient'
|
||||||
import Error from '~/components/pub/my-ui/error/error.vue'
|
import Error from '~/components/pub/my-ui/error/error.vue'
|
||||||
import { PAGE_PERMISSIONS } from '~/lib/page-permission'
|
|
||||||
import Content from '~/components/content/encounter/entry.vue'
|
import Content from '~/components/content/encounter/entry.vue'
|
||||||
|
|
||||||
definePageMeta({
|
definePageMeta({
|
||||||
middleware: ['rbac'],
|
middleware: ['rbac'],
|
||||||
roles: ['doctor', 'nurse', 'admisi', 'pharmacy', 'billing', 'management'],
|
roles: ['emp|reg'],
|
||||||
title: 'Edit Kunjungan',
|
title: 'Edit Kunjungan',
|
||||||
contentFrame: 'cf-full-width',
|
contentFrame: 'cf-full-width',
|
||||||
})
|
})
|
||||||
|
|
||||||
const route = useRoute()
|
// Preps role checking
|
||||||
|
const roleAccess: Record<string, Permission[]> = permissions['/outpatient/encounter'] || {}
|
||||||
useHead({
|
|
||||||
title: () => `${route.meta.title}`,
|
|
||||||
})
|
|
||||||
|
|
||||||
const roleAccess: PagePermission = PAGE_PERMISSIONS['/outpatient/encounter']
|
|
||||||
|
|
||||||
const { checkRole, hasUpdateAccess } = useRBAC()
|
const { checkRole, hasUpdateAccess } = useRBAC()
|
||||||
|
|
||||||
// Check if user has access to this page
|
// Check if user has access to this page
|
||||||
const hasAccess = checkRole(roleAccess)
|
const hasAccess = checkRole(roleAccess)
|
||||||
if (!hasAccess) {
|
if (!hasAccess) {
|
||||||
throw createError({
|
navigateTo('/403')
|
||||||
statusCode: 403,
|
|
||||||
statusMessage: 'Access denied',
|
|
||||||
})
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Define permission-based computed properties
|
// Page needs
|
||||||
const canUpdate = hasUpdateAccess(roleAccess)
|
const route = useRoute()
|
||||||
|
useHead({
|
||||||
|
title: () => route.meta.title as string,
|
||||||
|
})
|
||||||
|
|
||||||
// Get encounter ID from route params
|
// Get encounter ID from route params
|
||||||
const encounterId = computed(() => {
|
const encounterId = computed(() => {
|
||||||
const id = route.params.id
|
const id = route.params.id
|
||||||
return typeof id === 'string' ? parseInt(id) : 0
|
return typeof id === 'string' ? parseInt(id) : 0
|
||||||
})
|
})
|
||||||
|
|
||||||
|
// Define permission-based computed properties
|
||||||
|
const canUpdate = hasUpdateAccess(roleAccess)
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
|
|||||||
@@ -13,7 +13,7 @@ definePageMeta({
|
|||||||
|
|
||||||
// Preps role checking
|
// Preps role checking
|
||||||
const roleAccess: Record<string, Permission[]> = permissions['/outpatient/encounter'] || {}
|
const roleAccess: Record<string, Permission[]> = permissions['/outpatient/encounter'] || {}
|
||||||
const { checkRole, hasReadAccess, hasCreateAccess } = useRBAC()
|
const { checkRole, hasCreateAccess } = useRBAC()
|
||||||
|
|
||||||
// Check if user has access to this page
|
// Check if user has access to this page
|
||||||
const hasAccess = checkRole(roleAccess)
|
const hasAccess = checkRole(roleAccess)
|
||||||
@@ -21,9 +21,6 @@ if (!hasAccess) {
|
|||||||
navigateTo('/403')
|
navigateTo('/403')
|
||||||
}
|
}
|
||||||
|
|
||||||
// Define permission-based computed properties
|
|
||||||
const canRead = hasReadAccess(roleAccess)
|
|
||||||
|
|
||||||
// Page needs
|
// Page needs
|
||||||
const route = useRoute()
|
const route = useRoute()
|
||||||
useHead({
|
useHead({
|
||||||
|
|||||||
Reference in New Issue
Block a user