feat: add create permission handling in TreeComponent and MainPage
Some checks failed
Spell Check / Spell Check with Typos (push) Failing after 5s
Some checks failed
Spell Check / Spell Check with Typos (push) Failing after 5s
This commit is contained in:
parent
5e155cfb0c
commit
4a195494d6
3 changed files with 26 additions and 19 deletions
|
|
@ -16,6 +16,7 @@ withDefaults(
|
|||
labelKey?: string;
|
||||
childrenKey: string;
|
||||
action?: boolean;
|
||||
hideCreate?: boolean;
|
||||
}>(),
|
||||
{
|
||||
color: 'transparent',
|
||||
|
|
@ -119,7 +120,7 @@ defineEmits<{
|
|||
/>
|
||||
|
||||
<q-btn
|
||||
v-if="node.isHeadOffice && typeTree === 'branch'"
|
||||
v-if="node.isHeadOffice && typeTree === 'branch' && !hideCreate"
|
||||
:id="`create-sub-branch-btn-${node.name}`"
|
||||
@click.stop="$emit('create', node)"
|
||||
icon="mdi-file-plus-outline"
|
||||
|
|
|
|||
|
|
@ -1074,6 +1074,7 @@ watch(currentHq, () => {
|
|||
<div class="col full-width scroll">
|
||||
<div class="q-pa-md">
|
||||
<TreeComponent
|
||||
:hide-create="!canAccess('branch', 'create')"
|
||||
v-model:nodes="treeData"
|
||||
v-model:expanded-tree="expandedTree"
|
||||
node-key="id"
|
||||
|
|
@ -1562,17 +1563,17 @@ watch(currentHq, () => {
|
|||
<q-td>
|
||||
<KebabAction
|
||||
v-if="
|
||||
isRoleInclude([
|
||||
'system',
|
||||
'head_of_admin',
|
||||
'admin',
|
||||
'executive',
|
||||
'accountant',
|
||||
]) ||
|
||||
(canAccess('branch') && currentHq.id)
|
||||
!currentHq.id
|
||||
? canAccess('branch', 'create')
|
||||
: true
|
||||
"
|
||||
:status="props.row.status"
|
||||
:idName="props.row.name"
|
||||
:hide-delete="
|
||||
!currentHq.id
|
||||
? !isRoleInclude(['system'])
|
||||
: !canAccess('branch', 'create')
|
||||
"
|
||||
@view="
|
||||
if (props.row.isHeadOffice) {
|
||||
triggerEdit(
|
||||
|
|
@ -1713,17 +1714,17 @@ watch(currentHq, () => {
|
|||
<template v-slot:action>
|
||||
<KebabAction
|
||||
v-if="
|
||||
isRoleInclude([
|
||||
'system',
|
||||
'head_of_admin',
|
||||
'admin',
|
||||
'executive',
|
||||
'accountant',
|
||||
]) ||
|
||||
(canAccess('branch') && currentHq.id)
|
||||
!currentHq.id
|
||||
? canAccess('branch', 'create')
|
||||
: true
|
||||
"
|
||||
:status="props.row.status"
|
||||
:idName="props.row.name"
|
||||
:hide-delete="
|
||||
!currentHq.id
|
||||
? !isRoleInclude(['system'])
|
||||
: !canAccess('branch', 'create')
|
||||
"
|
||||
@view="
|
||||
if (props.row.isHeadOffice) {
|
||||
triggerEdit(
|
||||
|
|
@ -2272,7 +2273,11 @@ watch(currentHq, () => {
|
|||
type="button"
|
||||
/>
|
||||
<DeleteButton
|
||||
v-if="formType !== 'edit'"
|
||||
v-if="
|
||||
formType !== 'edit' && formTypeBranch === 'headOffice'
|
||||
? isRoleInclude(['system'])
|
||||
: canAccess('branch', 'create')
|
||||
"
|
||||
id="btn-info-basic-delete"
|
||||
icon-only
|
||||
@click="triggerDelete(currentEdit.id)"
|
||||
|
|
|
|||
|
|
@ -251,6 +251,7 @@ const allRoles = [
|
|||
|
||||
const permissions = {
|
||||
branch: {
|
||||
create: allRoles.slice(0, 4),
|
||||
edit: allRoles.slice(0, 7),
|
||||
view: allRoles.slice(0, 7),
|
||||
},
|
||||
|
|
@ -303,7 +304,7 @@ const permissions = {
|
|||
|
||||
export function canAccess(
|
||||
menu: keyof typeof permissions,
|
||||
action: 'edit' | 'view' = 'view',
|
||||
action: 'edit' | 'create' | 'view' = 'view',
|
||||
): boolean {
|
||||
// uma_authorization = all roles
|
||||
const roles = getRole() ?? [];
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue