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;
|
labelKey?: string;
|
||||||
childrenKey: string;
|
childrenKey: string;
|
||||||
action?: boolean;
|
action?: boolean;
|
||||||
|
hideCreate?: boolean;
|
||||||
}>(),
|
}>(),
|
||||||
{
|
{
|
||||||
color: 'transparent',
|
color: 'transparent',
|
||||||
|
|
@ -119,7 +120,7 @@ defineEmits<{
|
||||||
/>
|
/>
|
||||||
|
|
||||||
<q-btn
|
<q-btn
|
||||||
v-if="node.isHeadOffice && typeTree === 'branch'"
|
v-if="node.isHeadOffice && typeTree === 'branch' && !hideCreate"
|
||||||
:id="`create-sub-branch-btn-${node.name}`"
|
:id="`create-sub-branch-btn-${node.name}`"
|
||||||
@click.stop="$emit('create', node)"
|
@click.stop="$emit('create', node)"
|
||||||
icon="mdi-file-plus-outline"
|
icon="mdi-file-plus-outline"
|
||||||
|
|
|
||||||
|
|
@ -1074,6 +1074,7 @@ watch(currentHq, () => {
|
||||||
<div class="col full-width scroll">
|
<div class="col full-width scroll">
|
||||||
<div class="q-pa-md">
|
<div class="q-pa-md">
|
||||||
<TreeComponent
|
<TreeComponent
|
||||||
|
:hide-create="!canAccess('branch', 'create')"
|
||||||
v-model:nodes="treeData"
|
v-model:nodes="treeData"
|
||||||
v-model:expanded-tree="expandedTree"
|
v-model:expanded-tree="expandedTree"
|
||||||
node-key="id"
|
node-key="id"
|
||||||
|
|
@ -1562,17 +1563,17 @@ watch(currentHq, () => {
|
||||||
<q-td>
|
<q-td>
|
||||||
<KebabAction
|
<KebabAction
|
||||||
v-if="
|
v-if="
|
||||||
isRoleInclude([
|
!currentHq.id
|
||||||
'system',
|
? canAccess('branch', 'create')
|
||||||
'head_of_admin',
|
: true
|
||||||
'admin',
|
|
||||||
'executive',
|
|
||||||
'accountant',
|
|
||||||
]) ||
|
|
||||||
(canAccess('branch') && currentHq.id)
|
|
||||||
"
|
"
|
||||||
:status="props.row.status"
|
:status="props.row.status"
|
||||||
:idName="props.row.name"
|
:idName="props.row.name"
|
||||||
|
:hide-delete="
|
||||||
|
!currentHq.id
|
||||||
|
? !isRoleInclude(['system'])
|
||||||
|
: !canAccess('branch', 'create')
|
||||||
|
"
|
||||||
@view="
|
@view="
|
||||||
if (props.row.isHeadOffice) {
|
if (props.row.isHeadOffice) {
|
||||||
triggerEdit(
|
triggerEdit(
|
||||||
|
|
@ -1713,17 +1714,17 @@ watch(currentHq, () => {
|
||||||
<template v-slot:action>
|
<template v-slot:action>
|
||||||
<KebabAction
|
<KebabAction
|
||||||
v-if="
|
v-if="
|
||||||
isRoleInclude([
|
!currentHq.id
|
||||||
'system',
|
? canAccess('branch', 'create')
|
||||||
'head_of_admin',
|
: true
|
||||||
'admin',
|
|
||||||
'executive',
|
|
||||||
'accountant',
|
|
||||||
]) ||
|
|
||||||
(canAccess('branch') && currentHq.id)
|
|
||||||
"
|
"
|
||||||
:status="props.row.status"
|
:status="props.row.status"
|
||||||
:idName="props.row.name"
|
:idName="props.row.name"
|
||||||
|
:hide-delete="
|
||||||
|
!currentHq.id
|
||||||
|
? !isRoleInclude(['system'])
|
||||||
|
: !canAccess('branch', 'create')
|
||||||
|
"
|
||||||
@view="
|
@view="
|
||||||
if (props.row.isHeadOffice) {
|
if (props.row.isHeadOffice) {
|
||||||
triggerEdit(
|
triggerEdit(
|
||||||
|
|
@ -2272,7 +2273,11 @@ watch(currentHq, () => {
|
||||||
type="button"
|
type="button"
|
||||||
/>
|
/>
|
||||||
<DeleteButton
|
<DeleteButton
|
||||||
v-if="formType !== 'edit'"
|
v-if="
|
||||||
|
formType !== 'edit' && formTypeBranch === 'headOffice'
|
||||||
|
? isRoleInclude(['system'])
|
||||||
|
: canAccess('branch', 'create')
|
||||||
|
"
|
||||||
id="btn-info-basic-delete"
|
id="btn-info-basic-delete"
|
||||||
icon-only
|
icon-only
|
||||||
@click="triggerDelete(currentEdit.id)"
|
@click="triggerDelete(currentEdit.id)"
|
||||||
|
|
|
||||||
|
|
@ -251,6 +251,7 @@ const allRoles = [
|
||||||
|
|
||||||
const permissions = {
|
const permissions = {
|
||||||
branch: {
|
branch: {
|
||||||
|
create: allRoles.slice(0, 4),
|
||||||
edit: allRoles.slice(0, 7),
|
edit: allRoles.slice(0, 7),
|
||||||
view: allRoles.slice(0, 7),
|
view: allRoles.slice(0, 7),
|
||||||
},
|
},
|
||||||
|
|
@ -303,7 +304,7 @@ const permissions = {
|
||||||
|
|
||||||
export function canAccess(
|
export function canAccess(
|
||||||
menu: keyof typeof permissions,
|
menu: keyof typeof permissions,
|
||||||
action: 'edit' | 'view' = 'view',
|
action: 'edit' | 'create' | 'view' = 'view',
|
||||||
): boolean {
|
): boolean {
|
||||||
// uma_authorization = all roles
|
// uma_authorization = all roles
|
||||||
const roles = getRole() ?? [];
|
const roles = getRole() ?? [];
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue