|
|
@@ -60,6 +60,7 @@
|
|
|
<q-tooltip>Editar permissões</q-tooltip>
|
|
|
<PermissionLevelMenu
|
|
|
:bits="bitsFor(item.scope)"
|
|
|
+ :available-bits="availableBitsFor(item.scope)"
|
|
|
@update:bits="(value) => setBits(item.scope, value)"
|
|
|
/>
|
|
|
</q-btn>
|
|
|
@@ -121,6 +122,7 @@
|
|
|
<q-tooltip>Editar permissões</q-tooltip>
|
|
|
<PermissionLevelMenu
|
|
|
:bits="bitsFor(child.scope)"
|
|
|
+ :available-bits="availableBitsFor(child.scope)"
|
|
|
@update:bits="(value) => setBits(child.scope, value)"
|
|
|
/>
|
|
|
</q-btn>
|
|
|
@@ -186,6 +188,7 @@ const selectedScope = ref(null);
|
|
|
// permission_id e bits atuais do grupo, indexados pelo scope do menu.
|
|
|
const permissionIdByScope = ref({});
|
|
|
const bitsByScope = ref({});
|
|
|
+const availableBitsByScope = ref({});
|
|
|
|
|
|
const menus = computed(() =>
|
|
|
FRANCHISOR_PERMISSION_MENUS.filter(
|
|
|
@@ -204,6 +207,7 @@ const children = computed(() =>
|
|
|
);
|
|
|
|
|
|
const bitsFor = (scope) => bitsByScope.value[scope] ?? 0;
|
|
|
+const availableBitsFor = (scope) => availableBitsByScope.value[scope] ?? 0;
|
|
|
|
|
|
const setBits = (scope, value) => {
|
|
|
bitsByScope.value[scope] = value;
|
|
|
@@ -225,12 +229,14 @@ const fetchPermissions = async () => {
|
|
|
|
|
|
permissionIdByScope.value = {};
|
|
|
bitsByScope.value = {};
|
|
|
+ availableBitsByScope.value = {};
|
|
|
|
|
|
for (const scope of scopesInMenu()) {
|
|
|
const permission = byScope[scope];
|
|
|
if (!permission) continue;
|
|
|
|
|
|
permissionIdByScope.value[scope] = permission.id;
|
|
|
+ availableBitsByScope.value[scope] = permission.available_bits;
|
|
|
// Normaliza dados anteriores à regra (ex.: Visualizar gravado sem Menu).
|
|
|
bitsByScope.value[scope] = applyComputedLevels(permission.bits);
|
|
|
}
|