Browse Source

Merge pull request #25852 from abpframework/task/1386

Angular - Fixing the grant all button state in permissions modal
pull/25853/head
Yağmur Çelik 3 months ago
committed by GitHub
parent
commit
f815ee5a00
No known key found for this signature in database GPG Key ID: B5690EEEBB952194
  1. 22
      npm/ng-packs/packages/permission-management/src/lib/components/permission-management.component.ts

22
npm/ng-packs/packages/permission-management/src/lib/components/permission-management.component.ts

@ -187,11 +187,11 @@ export class PermissionManagementComponent {
}); });
protected readonly selectThisTabState = computed(() => protected readonly selectThisTabState = computed(() =>
getSelectAllCheckboxState(this.selectedGroupPermissions(), this.providerName), getSelectAllCheckboxState(this.selectedGroupPermissions()),
); );
protected readonly selectAllTabState = computed(() => protected readonly selectAllTabState = computed(() =>
getSelectAllCheckboxState(this.permissionsState(), this.providerName), getSelectAllCheckboxState(this.permissionsState()),
); );
// Disabled state is based on the API snapshot (not live edits) so select-all stays toggleable. // Disabled state is based on the API snapshot (not live edits) so select-all stays toggleable.
@ -588,20 +588,18 @@ function isSelectAllDisabled(
); );
} }
function getSelectAllCheckboxState( function getSelectAllCheckboxState(permissions: PermissionGrantInfoDto[]): SelectAllCheckboxState {
permissions: PermissionGrantInfoDto[], if (!permissions.length) {
providerName: string, return { checked: false, indeterminate: false };
): SelectAllCheckboxState { }
const selectablePermissions = permissions.filter(permission =>
(permission.grantedProviders ?? []).every(p => p.providerName === providerName), const grantedCount = permissions.filter(permission => permission.isGranted).length;
);
const selectedPermissions = selectablePermissions.filter(permission => permission.isGranted);
if (!selectablePermissions.length || selectedPermissions.length === 0) { if (grantedCount === 0) {
return { checked: false, indeterminate: false }; return { checked: false, indeterminate: false };
} }
if (selectedPermissions.length === selectablePermissions.length) { if (grantedCount === permissions.length) {
return { checked: true, indeterminate: false }; return { checked: true, indeterminate: false };
} }

Loading…
Cancel
Save