Skip to content

Commit

Permalink
Merge pull request #3 from Dative-GPI/fixes/permissions
Browse files Browse the repository at this point in the history
update "setted" value on permission's setting
  • Loading branch information
gballigand authored May 24, 2024
2 parents d284053 + 5c88c3a commit 7290c07
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions src/Bones.UI/composables/usePermissions.ts
Original file line number Diff line number Diff line change
@@ -1,33 +1,34 @@
import { ref } from 'vue'

const _permissions = ref<string[]>([]);
const _setted = false;
const _setted = ref(false);

export function usePermissions() {

const some = (...permissionCodes: string[]) => {
if (!_setted) {
if (!_setted.value) {
console.warn("Permissions not setted yet");
}
return _permissions.value.some(p => permissionCodes.includes(p));
}

const every = (...permissionCodes: string[]) => {
if (!_setted) {
if (!_setted.value) {
console.warn("Permissions not setted yet");
}
return permissionCodes.every(p => _permissions.value.includes(p));
}

const has = (permissionCode: string) => {
if (!_setted) {
if (!_setted.value) {
console.warn("Permissions not setted yet");
}
return _permissions.value.includes(permissionCode);
}

const set = (permissions: string[]) => {
_permissions.value = permissions;
_setted.value = true;
}

return {
Expand Down

0 comments on commit 7290c07

Please sign in to comment.