feat (rbac): implement role-based access control

This commit is contained in:
Abizrh
2025-08-12 11:32:36 +07:00
parent 59db7a8479
commit 125d7857ce
16 changed files with 394 additions and 22 deletions
+34 -5
View File
@@ -1,9 +1,38 @@
<script setup lang="ts"></script>
<script setup lang="ts">
import Block from '~/components/pub/form/block.vue'
import FieldGroup from '~/components/pub/form/field-group.vue'
import Field from '~/components/pub/form/field.vue'
import Label from '~/components/pub/form/label.vue'
</script>
<template>
<div>entry form</div>
<form id="entry-form">
<div class="mb-5 border-b border-b-slate-300 pb-3 text-lg xl:text-xl">
<!-- <i class="bi bi-file-earmark-person"></i> -->
<Icon name="i-lucide-user" />
<span class="font-semibold">Tambah</span> Pasien
</div>
<div>
<PubNavFooterCs />
</div>
<div class="mb-5 border-b border-b-slate-300 pb-3 text-lg xl:text-xl">
<div>
<Block>
<FieldGroup :column="2">
<Label>Nama</Label>
<Field name="name">
<Input type="text" name="name" />
</Field>
</FieldGroup>
<FieldGroup :column="2">
<Label>Nomor RM</Label>
<Field name="name">
<Input type="text" name="name" />
</Field>
</FieldGroup>
</Block>
</div>
</div>
<div class="my-2 flex justify-end py-2">
<PubNavFooterCs />
</div>
</form>
</template>
+1 -1
View File
@@ -37,7 +37,7 @@ watch(
if (val) {
links.value = setLinks()
}
}
},
)
</script>
+1 -1
View File
@@ -5,7 +5,7 @@ defineProps<{
</script>
<template>
<div :class="`mb-5 flex-wrap md:flex ${classValExt || ''}`">
<div :class="`m-3 mb-5 flex-wrap md:flex ${classValExt || ''}`">
<slot />
</div>
</template>
+9 -1
View File
@@ -34,7 +34,15 @@ const classVal = computed(() => {
</script>
<template>
<div :class="classVal">
<div
:class="[
column === 1 ? 'w-full' : column === 2 ? 'pe-4 md:w-1/2' : 'pe-4 md:w-1/3',
density === 'dense' ? '' : 'mb-2 md:mb-2.5 xl:mb-3',
side !== 'break' ? 'md:flex' : '',
position === 'dynamic' ? 'ps-4' : '',
props.class,
]"
>
<slot />
</div>
</template>
+72
View File
@@ -0,0 +1,72 @@
<script setup lang="ts">
const props = withDefaults(
defineProps<{
size?: 'default' | 'narrow' | 'wide'
height?: 'default' | 'compact'
position?: 'default' | 'dynamic'
class?: string
}>(),
{
size: 'default',
height: 'default',
position: 'default',
class: '',
},
)
const classVal = computed(() => {
let val = ''
if (props.size === 'narrow') val += 'size-narrow '
else if (props.size === 'wide') val += 'size-wide '
else val += 'size-default '
if (props.height === 'compact') val += 'height-compact '
else val += 'height-default '
if (props.position === 'dynamic') val += 'position-dynamic '
else val += 'position-default '
return (val + (props.class || '')).trim()
})
</script>
<template>
<div class="label" :class="classVal">
<label>
<slot />
</label>
</div>
</template>
<style scoped>
.label {
@apply block flex-shrink-0 shrink-0;
}
.size-default {
@apply w-28 2xl:w-36;
}
.size-narrow {
@apply w-24 2xl:w-28;
}
.size-wide {
@apply w-44 2xl:w-48;
}
.height-default {
@apply pt-2 2xl:pt-2.5;
}
.height-compact {
line-height: 14pt;
}
.position-default {
@apply pe-2 text-start;
}
.position-dynamic > * {
@apply block pe-2.5 md:text-end;
}
</style>
+2 -2
View File
@@ -1,9 +1,9 @@
<script setup lang="ts"></script>
<template>
<div class="flex justify-between">
<div class="flex justify-between px-2">
<div>
<Button variant="outline" size="sm">
<Button variant="outline">
<Icon name="i-lucide-pencil" class="mr-1" />
Edit
</Button>
+9 -1
View File
@@ -20,5 +20,13 @@ const modelValue = useVModel(props, 'modelValue', emits, {
</script>
<template>
<input v-model="modelValue" :class="cn('flex h-10 w-full rounded-md border border-input bg-background px-3 py-2 text-sm ring-offset-background file:border-0 file:bg-transparent file:text-sm file:font-medium placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50', props.class)">
<input
v-model="modelValue"
:class="
cn(
'border-input ring-offset-background placeholder:text-muted-foreground flex h-10 w-full rounded-md border px-3 py-2 text-sm file:border-0 file:bg-transparent file:text-sm file:font-medium disabled:cursor-not-allowed disabled:opacity-50',
props.class,
)
"
/>
</template>