forked from verdnatura/salix-front
feat: refs #4074 useAcl in vnSelectDialog
This commit is contained in:
parent
53aec24790
commit
6c3c03722f
|
@ -27,17 +27,17 @@ const $props = defineProps({
|
||||||
});
|
});
|
||||||
|
|
||||||
const role = useRole();
|
const role = useRole();
|
||||||
const acl = useAcl()
|
const acl = useAcl();
|
||||||
const showForm = ref(false);
|
const showForm = ref(false);
|
||||||
|
|
||||||
const isAllowedToCreate = computed(() => {
|
const isAllowedToCreate = computed(() => {
|
||||||
if ($props.acls.length) console.log(acl.hasAny($props.acls));
|
const hasMissingAcl = $props.acls.some(
|
||||||
return role.hasAny($props.rolesAllowedToCreate);
|
(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>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
|
@ -48,7 +48,7 @@ const toggleForm = () => {
|
||||||
>
|
>
|
||||||
<template v-if="isAllowedToCreate" #append>
|
<template v-if="isAllowedToCreate" #append>
|
||||||
<QIcon
|
<QIcon
|
||||||
@click.stop.prevent="toggleForm()"
|
@click.stop.prevent="showForm = true"
|
||||||
:name="actionIcon"
|
:name="actionIcon"
|
||||||
:size="actionIcon === 'add' ? 'xs' : 'sm'"
|
:size="actionIcon === 'add' ? 'xs' : 'sm'"
|
||||||
:class="['default-icon', { '--add-icon': actionIcon === 'add' }]"
|
:class="['default-icon', { '--add-icon': actionIcon === 'add' }]"
|
||||||
|
|
Loading…
Reference in New Issue