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 4 weeks 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(() =>
getSelectAllCheckboxState(this.selectedGroupPermissions(), this.providerName),
getSelectAllCheckboxState(this.selectedGroupPermissions()),
);
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.
@ -588,20 +588,18 @@ function isSelectAllDisabled(
);
}
function getSelectAllCheckboxState(
permissions: PermissionGrantInfoDto[],
providerName: string,
): SelectAllCheckboxState {
const selectablePermissions = permissions.filter(permission =>
(permission.grantedProviders ?? []).every(p => p.providerName === providerName),
);
const selectedPermissions = selectablePermissions.filter(permission => permission.isGranted);
function getSelectAllCheckboxState(permissions: PermissionGrantInfoDto[]): SelectAllCheckboxState {
if (!permissions.length) {
return { checked: false, indeterminate: false };
}
const grantedCount = permissions.filter(permission => permission.isGranted).length;
if (!selectablePermissions.length || selectedPermissions.length === 0) {
if (grantedCount === 0) {
return { checked: false, indeterminate: false };
}
if (selectedPermissions.length === selectablePermissions.length) {
if (grantedCount === permissions.length) {
return { checked: true, indeterminate: false };
}

Loading…
Cancel
Save