From 3863c5e7d1b8a6b6ef16406c0e8e144692239873 Mon Sep 17 00:00:00 2001 From: Mahdi Date: Mon, 19 Oct 2026 12:20:52 +0330 Subject: [PATCH] fix: hide role permissions for modules disabled in super admin --- apps/web/src/views/TeamSettingsView.vue | 43 +++++++++++++++++++++---- 1 file changed, 37 insertions(+), 6 deletions(-) diff --git a/apps/web/src/views/TeamSettingsView.vue b/apps/web/src/views/TeamSettingsView.vue index 8a68aad..a6efcdf 100644 --- a/apps/web/src/views/TeamSettingsView.vue +++ b/apps/web/src/views/TeamSettingsView.vue @@ -13,6 +13,7 @@ import { ROLE_PERMISSION_ITEMS, type InviteUserRequest, type OrganizationDto, + type OrgModuleKey, type OrgRoleDto, type OrgUserDto, type RolePermissionKey, @@ -48,12 +49,40 @@ const auth = useAuthStore(); const route = useRoute(); const router = useRouter(); +/** مجوزی که ماژولش در سوپرادمین خاموش است در نقش‌ها نشان داده نمی‌شود. */ +const PERMISSION_MODULES: Partial> = { + customers: ['customers'], + sales: ['pipeline'], + billing: ['invoices', 'quotes'], + products: ['products'], + activities: ['activities'], + notes: ['notes'], + reports: ['reports'], + audit: ['audit_logs'], + conversations: ['conversations'], + conversations_groups: ['conversations'], + treasury: ['treasury'], + treasury_payroll: ['treasury'], + behavior: ['behavior'], +}; + const loading = ref(false); const error = ref(''); const ok = ref(''); const users = ref([]); const roles = ref([]); const org = ref(null); + +const visibleRolePermissions = computed(() => { + const enabled = org.value?.enabledModules ?? auth.user?.enabledModules; + if (!enabled) return ROLE_PERMISSION_ITEMS; + return ROLE_PERMISSION_ITEMS.filter((item) => { + const modules = PERMISSION_MODULES[item.key]; + if (!modules?.length) return true; + return modules.some((module) => enabled.includes(module)); + }); +}); + const orgName = ref(''); const businessField = ref(''); const orgSaving = ref(false); @@ -119,7 +148,9 @@ const accessFocusRole = computed( ); function permCountLabel(role: OrgRoleDto) { - return `${toFaDigits(role.permissions.length)} از ${toFaDigits(ROLE_PERMISSION_ITEMS.length)}`; + const visible = visibleRolePermissions.value; + const owned = visible.filter((item) => role.permissions.includes(item.key)).length; + return `${toFaDigits(owned)} از ${toFaDigits(visible.length)}`; } const stats = computed(() => { @@ -487,7 +518,7 @@ function openCreateRole(parentId?: string | null) { roleFormParentId.value = parent?.id ?? ''; roleFormPerms.value = parent ? [...parent.permissions] - : ROLE_PERMISSION_ITEMS.map((p) => p.key); + : visibleRolePermissions.value.map((p) => p.key); roleFormOpen.value = true; } @@ -725,7 +756,7 @@ onUnmounted(() => {
    -
  • +