Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

update "setted" value on permission's setting #3

Merged
merged 1 commit into from
May 24, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading