0
0
Fork 0

feat: refs #4074 useAcl in vnSelectDialog

This commit is contained in:
Jorge Penadés 2024-08-02 09:37:48 +02:00
parent 53aec24790
commit 6c3c03722f
1 changed files with 8 additions and 8 deletions

View File

@ -27,17 +27,17 @@ const $props = defineProps({
});
const role = useRole();
const acl = useAcl()
const acl = useAcl();
const showForm = ref(false);
const isAllowedToCreate = computed(() => {
if ($props.acls.length) console.log(acl.hasAny($props.acls));
return role.hasAny($props.rolesAllowedToCreate);
const hasMissingAcl = $props.acls.some(
(x) => !acl.hasAny(x.model, x.props, x.accessType)
);
const hasRequiredRole = role.hasAny($props.rolesAllowedToCreate);
if ($props.acls.length) return !hasMissingAcl;
return hasRequiredRole;
});
const toggleForm = () => {
showForm.value = !showForm.value;
};
</script>
<template>
@ -48,7 +48,7 @@ const toggleForm = () => {
>
<template v-if="isAllowedToCreate" #append>
<QIcon
@click.stop.prevent="toggleForm()"
@click.stop.prevent="showForm = true"
:name="actionIcon"
:size="actionIcon === 'add' ? 'xs' : 'sm'"
:class="['default-icon', { '--add-icon': actionIcon === 'add' }]"