@@ -12,13 +12,12 @@ import { DeleteEntryRequest } from '@models/api/entry/delete-request';
1212import { UpdateEntryResponse } from '@models/api/entry/update-response' ;
1313import { LdapEntryType } from '@models/core/ldap/ldap-entry-type' ;
1414import { NavigationNode } from '@models/core/navigation/navigation-node' ;
15- import { AppNavigationService } from '@services/app-navigation.service' ;
1615import { AppSettingsService } from '@services/app-settings.service' ;
1716import { BulkService } from '@services/bulk.service' ;
1817import { LdapTreeviewService } from '@services/ldap/ldap-treeview.service' ;
1918import { MultidirectoryApiService } from '@services/multidirectory-api.service' ;
2019import { MultidirectoryUiKitModule } from 'multidirectory-ui-kit' ;
21- import { concat , EMPTY , of , switchMap , take , tap } from 'rxjs' ;
20+ import { concat , EMPTY , filter , of , switchMap , take , tap } from 'rxjs' ;
2221import { ChangePasswordDialogData , ChangePasswordDialogReturnData } from '../../../interfaces/change-password-dialog.interface' ;
2322import { ConfirmDeleteDialogData , ConfirmDeleteDialogReturnData } from '../../../interfaces/confirm-delete-dialog.interface' ;
2423import { ConfirmDialogData , ConfirmDialogReturnData } from '../../../interfaces/confirm-dialog.interface' ;
@@ -30,9 +29,16 @@ import { DialogService } from '../../../services/dialog.service';
3029import { ChangePasswordDialogComponent } from '../../dialogs/change-password-dialog/change-password-dialog.component' ;
3130import { ConfirmDeleteDialogComponent } from '../../dialogs/confirm-delete-dialog/confirm-delete-dialog.component' ;
3231import { ConfirmDialogComponent } from '../../dialogs/confirm-dialog/confirm-dialog.component' ;
33- import { EntityPropertiesDialogComponent } from '../../dialogs/entity-properties-dialog/entity-properties-dialog.component' ;
3432import { MoveEntityDialogComponent } from '../../dialogs/move-entity-dialog/move-entity-dialog.component' ;
3533import { ToastrService } from 'ngx-toastr' ;
34+ import { RenameUserDialogComponent } from '@components/modals/components/dialogs/rename-user-dialog/rename-user-dialog.component' ;
35+ import { RenameGroupDialogComponent } from '@components/modals/components/dialogs/rename-group-dialog/rename-group-dialog.component' ;
36+ import { LdapRenameRequest } from '@core/ldap/ldap-rename.request' ;
37+ import { Group } from '@core/groups/group' ;
38+ import { DataBusService } from '@services/data-bus.service' ;
39+ import {
40+ EntityPropertiesDialogComponent
41+ } from '@components/modals/components/dialogs/entity-properties-dialog/entity-properties-dialog.component' ;
3642
3743@Component ( {
3844 selector : 'app-context-menu' ,
@@ -53,9 +59,9 @@ export class ContextMenuComponent implements OnInit {
5359 private api : MultidirectoryApiService = inject ( MultidirectoryApiService ) ;
5460 private appSettings : AppSettingsService = inject ( AppSettingsService ) ;
5561 private ldapTreeview = inject ( LdapTreeviewService ) ;
56- private navigation = inject ( AppNavigationService ) ;
5762 private bulk : BulkService < NavigationNode > = inject ( BulkService < NavigationNode > ) ;
5863 private toastr = inject ( ToastrService ) ;
64+ private dataBus = inject ( DataBusService ) ;
5965 private getAccessorStrategy : GetAccessorStrategy = inject ( GetAccessorStrategy ) ;
6066 private completeUpdateEntiresStrategy : CompleteUpdateEntiresStrategies = inject ( CompleteUpdateEntiresStrategies ) ;
6167 private contextMenuData : ContextMenuData = inject ( DIALOG_DATA ) ;
@@ -141,7 +147,7 @@ export class ContextMenuComponent implements OnInit {
141147 } ,
142148 } ) . closed ;
143149 } ) ,
144- tap ( ( ) => this . navigation . reload ( ) ) ,
150+ tap ( ( ) => this . dataBus . emitUpdateGridContent ( ) ) ,
145151 ) ,
146152 ) ;
147153 }
@@ -157,8 +163,8 @@ export class ContextMenuComponent implements OnInit {
157163 } ,
158164 } )
159165 . closed . pipe ( switchMap ( ( x ) => ( x ? this . api . updateManyDn ( x ) : EMPTY ) ) )
160- . subscribe ( ( x ) => {
161- this . navigation . reload ( ) ;
166+ . subscribe ( ( ) => {
167+ this . dataBus . emitUpdateGridContent ( ) ;
162168 } ) ;
163169 }
164170
@@ -174,24 +180,24 @@ export class ContextMenuComponent implements OnInit {
174180 } ,
175181 } )
176182 . closed . pipe (
177- switchMap ( ( isConfirmed ) => {
178- return isConfirmed
179- ? concat (
180- ...this . entries . map ( ( x ) =>
181- // TODO: Будет deleteMany
182- this . api . delete (
183- new DeleteEntryRequest ( {
184- entry : x . id ,
185- } ) ,
186- ) ,
187- ) ,
188- )
189- : of ( null ) ;
190- } ) ,
191- )
183+ switchMap ( ( isConfirmed ) => {
184+ return isConfirmed
185+ ? concat (
186+ ...this . entries . map ( ( x ) =>
187+ // TODO: Будет deleteMany
188+ this . api . delete (
189+ new DeleteEntryRequest ( {
190+ entry : x . id ,
191+ } ) ,
192+ ) ,
193+ ) ,
194+ )
195+ : of ( null ) ;
196+ } ) ,
197+ )
192198 . subscribe ( ( result ) => {
193199 this . ldapTreeview . invalidate ( toDeleteDNs ) ;
194- this . navigation . reload ( ) ;
200+ this . dataBus . emitUpdateGridContent ( ) ;
195201 } ) ;
196202 }
197203
@@ -228,4 +234,48 @@ export class ContextMenuComponent implements OnInit {
228234
229235 dropdownEl . style . transform = `translate(${ offsetX < 0 ? offsetX : 0 } px, ${ offsetY < 0 ? offsetY : 0 } px)` ;
230236 }
237+
238+ protected openRenameUserDialog ( ) {
239+ this . contextMenuService . close ( null ) ;
240+ const id = this . entries [ 0 ] . id ;
241+
242+ this . dialogService
243+ . open < LdapRenameRequest , string , RenameUserDialogComponent > ( {
244+ component : RenameUserDialogComponent ,
245+ dialogConfig : {
246+ minHeight : '230px' ,
247+ data : id ,
248+ } ,
249+ } )
250+ . closed . pipe (
251+ filter ( Boolean ) ,
252+ switchMap ( ( request ) => this . api . rename ( request ) ) ,
253+ )
254+ . subscribe ( ( ) => {
255+ this . toastr . success ( translate ( 'rename-user-dialog.success' ) ) ;
256+ this . dataBus . emitUpdateGridContent ( ) ;
257+ } ) ;
258+ }
259+
260+ protected openRenameGroupDialog ( ) {
261+ this . contextMenuService . close ( null ) ;
262+ const group = this . entries [ 0 ] as Group ;
263+
264+ this . dialogService
265+ . open < LdapRenameRequest , Group , RenameGroupDialogComponent > ( {
266+ component : RenameGroupDialogComponent ,
267+ dialogConfig : {
268+ minHeight : '230px' ,
269+ data : group ,
270+ } ,
271+ } )
272+ . closed . pipe (
273+ filter ( Boolean ) ,
274+ switchMap ( ( request ) => this . api . rename ( request ) ) ,
275+ )
276+ . subscribe ( ( ) => {
277+ this . toastr . success ( translate ( 'rename-group-dialog.success' ) ) ;
278+ this . dataBus . emitUpdateGridContent ( ) ;
279+ } ) ;
280+ }
231281}
0 commit comments