|
|
|
|
@ -130,8 +130,8 @@ export class UserPermissionsComponent {
|
|
|
|
|
const params = new HttpParams().set('userId', this.permission.get('userCode')?.value);
|
|
|
|
|
this.httpService.requestGET(URIKey.USER_GET_PERMISSIONS, params).subscribe((response: any) => {
|
|
|
|
|
if (!(response instanceof HttpErrorResponse)) {
|
|
|
|
|
if (response.permission) {
|
|
|
|
|
this.updatePermissions(JSON.parse(response.permission), this.permissions);
|
|
|
|
|
if (response.permissions) {
|
|
|
|
|
this.updatePermissions(JSON.parse(response.permissions), this.permissions);
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
this.defaultPermissions().subscribe((data: PermissionNode[]) => {
|
|
|
|
|
@ -144,17 +144,18 @@ export class UserPermissionsComponent {
|
|
|
|
|
|
|
|
|
|
savePermissions() {
|
|
|
|
|
let payload = {
|
|
|
|
|
porOrgacode: this.credentialService.getPorOrgacode(),
|
|
|
|
|
// porOrgacode: this.credentialService.getPorOrgacode(),
|
|
|
|
|
userId: this.permission.get('userCode')?.value,
|
|
|
|
|
permission: JSON.stringify(this.permissions)
|
|
|
|
|
}
|
|
|
|
|
// this.httpService.requestPATCH(URIKey.USER_SAVE_PERMISSION, payload).subscribe((response: any) => {
|
|
|
|
|
// if (!(response instanceof HttpErrorResponse)) {
|
|
|
|
|
// this.i18nService.success(SuccessMessages.SAVED_SUCESSFULLY, []);
|
|
|
|
|
// this.permission.reset();
|
|
|
|
|
// this.showPermissions = false;
|
|
|
|
|
// }
|
|
|
|
|
// })
|
|
|
|
|
permissions: JSON.stringify(this.permissions)
|
|
|
|
|
}
|
|
|
|
|
this.httpService.requestPUT(URIKey.USER_SAVE_PERMISSION, payload).subscribe((response: any) => {
|
|
|
|
|
if (!(response instanceof HttpErrorResponse)) {
|
|
|
|
|
this.i18nService.success(SuccessMessages.SAVED_SUCESSFULLY, []);
|
|
|
|
|
this.permission.reset();
|
|
|
|
|
this.permission.get('userCode')?.setValue("");
|
|
|
|
|
this.showPermissions = false;
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
updatePermissions(savedPermissions: PermissionNode[], existingPermissions: PermissionNode[]): void {
|
|
|
|
|
|