|
|
|
@ -7,7 +7,7 @@ import { |
|
|
|
Output, |
|
|
|
Renderer2, |
|
|
|
SimpleChanges, |
|
|
|
TrackByFunction |
|
|
|
TrackByFunction, |
|
|
|
} from '@angular/core'; |
|
|
|
import { Select, Store } from '@ngxs/store'; |
|
|
|
import { from, Observable } from 'rxjs'; |
|
|
|
@ -22,7 +22,7 @@ type PermissionWithMargin = PermissionManagement.Permission & { |
|
|
|
|
|
|
|
@Component({ |
|
|
|
selector: 'abp-permission-management', |
|
|
|
templateUrl: './permission-management.component.html' |
|
|
|
templateUrl: './permission-management.component.html', |
|
|
|
}) |
|
|
|
export class PermissionManagementComponent implements OnInit, OnChanges { |
|
|
|
@Input() |
|
|
|
@ -54,7 +54,7 @@ export class PermissionManagementComponent implements OnInit, OnChanges { |
|
|
|
@Select(PermissionManagementState.getPermissionGroups) |
|
|
|
groups$: Observable<PermissionManagement.Group[]>; |
|
|
|
|
|
|
|
@Select(PermissionManagementState.getEntitiyDisplayName) |
|
|
|
@Select(PermissionManagementState.getEntityDisplayName) |
|
|
|
entityName$: Observable<string>; |
|
|
|
|
|
|
|
selectedGroup: PermissionManagement.Group; |
|
|
|
@ -72,7 +72,7 @@ export class PermissionManagementComponent implements OnInit, OnChanges { |
|
|
|
get selectedGroupPermissions$(): Observable<PermissionWithMargin[]> { |
|
|
|
return this.groups$.pipe( |
|
|
|
map(groups => |
|
|
|
this.selectedGroup ? groups.find(group => group.name === this.selectedGroup.name).permissions : [] |
|
|
|
this.selectedGroup ? groups.find(group => group.name === this.selectedGroup.name).permissions : [], |
|
|
|
), |
|
|
|
map<PermissionManagement.Permission[], PermissionWithMargin[]>(permissions => |
|
|
|
permissions.map( |
|
|
|
@ -80,10 +80,10 @@ export class PermissionManagementComponent implements OnInit, OnChanges { |
|
|
|
(({ |
|
|
|
...permission, |
|
|
|
margin: findMargin(permissions, permission), |
|
|
|
isGranted: this.permissions.find(per => per.name === permission.name).isGranted |
|
|
|
} as any) as PermissionWithMargin) |
|
|
|
) |
|
|
|
) |
|
|
|
isGranted: this.permissions.find(per => per.name === permission.name).isGranted, |
|
|
|
} as any) as PermissionWithMargin), |
|
|
|
), |
|
|
|
), |
|
|
|
); |
|
|
|
} |
|
|
|
|
|
|
|
@ -165,7 +165,7 @@ export class PermissionManagementComponent implements OnInit, OnChanges { |
|
|
|
this.permissions = [ |
|
|
|
...this.permissions.slice(0, index), |
|
|
|
{ ...this.permissions[index], isGranted: !this.selectThisTab }, |
|
|
|
...this.permissions.slice(index + 1) |
|
|
|
...this.permissions.slice(index + 1), |
|
|
|
]; |
|
|
|
}); |
|
|
|
}); |
|
|
|
@ -176,7 +176,7 @@ export class PermissionManagementComponent implements OnInit, OnChanges { |
|
|
|
onClickSelectAll() { |
|
|
|
this.permissions = this.permissions.map(permission => ({ |
|
|
|
...permission, |
|
|
|
isGranted: !this.selectAllTab |
|
|
|
isGranted: !this.selectAllTab, |
|
|
|
})); |
|
|
|
|
|
|
|
this.selectThisTab = !this.selectAllTab; |
|
|
|
@ -190,12 +190,12 @@ export class PermissionManagementComponent implements OnInit, OnChanges { |
|
|
|
submit() { |
|
|
|
this.modalBusy = true; |
|
|
|
const unchangedPermissions = getPermissions( |
|
|
|
this.store.selectSnapshot(PermissionManagementState.getPermissionGroups) |
|
|
|
this.store.selectSnapshot(PermissionManagementState.getPermissionGroups), |
|
|
|
); |
|
|
|
|
|
|
|
const changedPermissions: PermissionManagement.MinimumPermission[] = this.permissions |
|
|
|
.filter(per => |
|
|
|
unchangedPermissions.find(unchanged => unchanged.name === per.name).isGranted === per.isGranted ? false : true |
|
|
|
unchangedPermissions.find(unchanged => unchanged.name === per.name).isGranted === per.isGranted ? false : true, |
|
|
|
) |
|
|
|
.map(({ name, isGranted }) => ({ name, isGranted })); |
|
|
|
|
|
|
|
@ -205,8 +205,8 @@ export class PermissionManagementComponent implements OnInit, OnChanges { |
|
|
|
new UpdatePermissions({ |
|
|
|
providerKey: this.providerKey, |
|
|
|
providerName: this.providerName, |
|
|
|
permissions: changedPermissions |
|
|
|
}) |
|
|
|
permissions: changedPermissions, |
|
|
|
}), |
|
|
|
) |
|
|
|
.subscribe(() => { |
|
|
|
this.modalBusy = false; |
|
|
|
@ -227,8 +227,8 @@ export class PermissionManagementComponent implements OnInit, OnChanges { |
|
|
|
.dispatch( |
|
|
|
new GetPermissions({ |
|
|
|
providerKey: this.providerKey, |
|
|
|
providerName: this.providerName |
|
|
|
}) |
|
|
|
providerName: this.providerName, |
|
|
|
}), |
|
|
|
) |
|
|
|
.pipe(pluck('PermissionManagementState', 'permissionRes')) |
|
|
|
.subscribe((permissionRes: PermissionManagement.Response) => { |
|
|
|
|