From 84796adb98afc926a6c2c8ac2b96ee4ca47a2b64 Mon Sep 17 00:00:00 2001 From: Ivan Gubanov Date: Mon, 7 Oct 2024 16:56:37 +0300 Subject: [PATCH 1/2] remove/edit by index, not empty id --- .../grant-rights-dialog.component.html | 6 +- .../grant-rights-dialog.service.ts | 70 ++++++++++--------- 2 files changed, 41 insertions(+), 35 deletions(-) diff --git a/src/Framework.Configurator/configurator-ui/src/app/rights/components/principals/components/grant-rights-dialog/grant-rights-dialog.component.html b/src/Framework.Configurator/configurator-ui/src/app/rights/components/principals/components/grant-rights-dialog/grant-rights-dialog.component.html index 0658a3e71..3289c4b2a 100644 --- a/src/Framework.Configurator/configurator-ui/src/app/rights/components/principals/components/grant-rights-dialog/grant-rights-dialog.component.html +++ b/src/Framework.Configurator/configurator-ui/src/app/rights/components/principals/components/grant-rights-dialog/grant-rights-dialog.component.html @@ -43,7 +43,7 @@

{{ data.Name }}

+ *ngFor="let element of obj.filter | rightsFilter : obj.rights ?? []; index as index"> diff --git a/src/Framework.Configurator/configurator-ui/src/app/rights/components/principals/components/grant-rights-dialog/grant-rights-dialog.service.ts b/src/Framework.Configurator/configurator-ui/src/app/rights/components/principals/components/grant-rights-dialog/grant-rights-dialog.service.ts index fe6087afa..ac4115b15 100644 --- a/src/Framework.Configurator/configurator-ui/src/app/rights/components/principals/components/grant-rights-dialog/grant-rights-dialog.service.ts +++ b/src/Framework.Configurator/configurator-ui/src/app/rights/components/principals/components/grant-rights-dialog/grant-rights-dialog.service.ts @@ -51,7 +51,7 @@ export class GrantRightsDialogService { }); } - public remove(permission: IPermissionDto): void { + public remove(elementIndex: number): void { this.dialog .open(ConfirmDialogComponent, { data: { title: 'Are you sure you want to delete this role?', button: 'Yes, delete' }, @@ -65,7 +65,7 @@ export class GrantRightsDialogService { return; } const rights = this.rightsInternalSubject.value; - rights.Permissions = rights.Permissions.filter((x) => x.Id != permission.Id); + rights.Permissions.splice(elementIndex, 1); this.rightsInternalSubject.next(rights); }), takeUntil(this.destroy$) @@ -73,36 +73,11 @@ export class GrantRightsDialogService { .subscribe(); } - public edit(permissionDto: IPermissionDto, units: IRoleContext[]): void { - const permission = this.mapPermission(permissionDto, this.rolesSubject.value, this.allContextsSubject.value); + public edit(permissionDto: IPermissionDto, elementIndex: number): void { + const allContexts = this.allContextsSubject.value; + const permission = this.mapPermission(permissionDto, this.rolesSubject.value, allContexts); - this.dialog - .open(PermissionEditDialogComponent, { - maxHeight: '90vh', - maxWidth: '90vw', - data: { permission, units }, - }) - .afterClosed() - .pipe( - tap((result) => { - if (result) { - const rights = this.rightsInternalSubject.value; - const findIndex = rights.Permissions.findIndex((x) => x.Id === result.Id); - if (findIndex > -1) { - rights.Permissions[findIndex] = result; - } else { - rights.Permissions.unshift(result); - } - this.rightsInternalSubject.next(rights); - } - // TODO: fix next three lines - const filterValue = this.filter.value; - this.filter.next({ ...filterValue, comment: '' }); - this.filter.next({ ...filterValue }); - }), - takeUntil(this.destroy$) - ) - .subscribe(); + this.openPermissionEditDialog(permission, (permissions, permission) => (permissions[elementIndex] = permission)); } public addPermission(): void { @@ -123,7 +98,38 @@ export class GrantRightsDialogService { Comment: '', Contexts: [], }; - this.edit(permission, this.allContextsSubject.value); + this.openPermissionEditDialog(permission, (permissions, permission) => permissions.push(permission)); + }), + takeUntil(this.destroy$) + ) + .subscribe(); + } + + private openPermissionEditDialog( + permissionDto: IPermissionDto, + updPermissionsAction: (existingPermissions: IPermissionDto[], newPermission: TPermission) => void + ): void { + const allContexts = this.allContextsSubject.value; + const permission = this.mapPermission(permissionDto, this.rolesSubject.value, allContexts); + + this.dialog + .open(PermissionEditDialogComponent, { + maxHeight: '90vh', + maxWidth: '90vw', + data: { permission, allContexts }, + }) + .afterClosed() + .pipe( + tap((result) => { + if (result) { + const rights = this.rightsInternalSubject.value; + updPermissionsAction(rights.Permissions, result); + this.rightsInternalSubject.next(rights); + } + // TODO: fix next three lines + const filterValue = this.filter.value; + this.filter.next({ ...filterValue, comment: '' }); + this.filter.next({ ...filterValue }); }), takeUntil(this.destroy$) ) From 94a6b49f288b78fa42f2e2e6323cea47e6476975 Mon Sep 17 00:00:00 2001 From: Ivan Gubanov Date: Mon, 7 Oct 2024 16:57:15 +0300 Subject: [PATCH 2/2] up version --- src/__SolutionItems/CommonAssemblyInfo.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/__SolutionItems/CommonAssemblyInfo.cs b/src/__SolutionItems/CommonAssemblyInfo.cs index ad176b851..15e7739c9 100644 --- a/src/__SolutionItems/CommonAssemblyInfo.cs +++ b/src/__SolutionItems/CommonAssemblyInfo.cs @@ -4,9 +4,9 @@ [assembly: AssemblyCompany("Luxoft")] [assembly: AssemblyCopyright("Copyright © Luxoft 2009-2024")] -[assembly: AssemblyVersion("22.3.16.0")] -[assembly: AssemblyFileVersion("22.3.16.0")] -[assembly: AssemblyInformationalVersion("22.3.16.0")] +[assembly: AssemblyVersion("22.3.17.0")] +[assembly: AssemblyFileVersion("22.3.17.0")] +[assembly: AssemblyInformationalVersion("22.3.17.0")] #if DEBUG [assembly: AssemblyConfiguration("Debug")]