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