diff --git a/apps/maarch_entreprise/Views/entities-administration.component.html b/apps/maarch_entreprise/Views/entities-administration.component.html index b37e946b290e6213856529b9dce93083159b4bba..11340143e9040487b194b4c4b3a891b61e55f06f 100644 --- a/apps/maarch_entreprise/Views/entities-administration.component.html +++ b/apps/maarch_entreprise/Views/entities-administration.component.html @@ -16,7 +16,7 @@ <mat-divider></mat-divider> <mat-nav-list> <h3 mat-subheader>{{lang.actions}}</h3> - <a mat-list-item (click)="prepareEntityAdd()" *ngIf="!creationMode"> + <a mat-list-item (click)="snav2.open();prepareEntityAdd()" *ngIf="!creationMode"> <mat-icon color="primary" mat-list-icon class="fa fa-plus"></mat-icon> <p mat-line> {{lang.add}} @@ -214,7 +214,7 @@ <div class="row" style="margin:0px;"> <div class="col-md-12"> <mat-form-field> - <input #autocompleteFilter type="text" placeholder="{{lang.addUserOrEntity}}" matInput [matAutocomplete]="auto" [formControl]="elementCtrl"> + <input class="autocompleteSearch" #autocompleteFilter type="text" placeholder="{{lang.addUserOrEntity}}" matInput [matAutocomplete]="auto" [formControl]="elementCtrl"> <mat-autocomplete #auto="matAutocomplete"> <mat-option *ngFor="let elem of filteredElements | async" [value]="elem.id" (click)="addElemListModel(elem)"> <p mat-line style="margin:0;"> @@ -262,7 +262,7 @@ <div class="row" style="margin:0px;" id="visaCircuitContent"> <div class="col-md-12"> <mat-form-field> - <input #autocompleteFilter type="text" placeholder="{{lang.addVisaSignUser}}" matInput [matAutocomplete]="auto" [formControl]="userCtrl"> + <input #autocompleteFilter class="autocompleteSearch" type="text" placeholder="{{lang.addVisaSignUser}}" matInput [matAutocomplete]="auto" [formControl]="userCtrl"> <mat-autocomplete #auto="matAutocomplete"> <mat-option *ngFor="let elem of filteredUsers | async" [value]="elem.id" (click)="addElemListModelVisa(elem);autocompleteFilter.isOpen=true"> <p mat-line *ngIf="elem.type == 'user'" style="margin:0;"> diff --git a/apps/maarch_entreprise/js/angular/app/administration/entities-administration.component.ts b/apps/maarch_entreprise/js/angular/app/administration/entities-administration.component.ts index bc28a631402355425c67a9c7e23c309af404a246..a2576756be0969bbed678d27a1abe4c955d3a8ea 100644 --- a/apps/maarch_entreprise/js/angular/app/administration/entities-administration.component.ts +++ b/apps/maarch_entreprise/js/angular/app/administration/entities-administration.component.ts @@ -33,6 +33,7 @@ export class EntitiesAdministrationComponent extends AutoCompletePlugin implemen entityTypeList : any[] = []; currentEntity : any = {}; isDraggable : boolean = true; + newEntity : boolean = false; creationMode : boolean = false; listDiffModified : boolean = false; idCircuitVisa : number; @@ -142,7 +143,12 @@ export class EntitiesAdministrationComponent extends AutoCompletePlugin implemen if (this.creationMode == true) { this.currentEntity.parent_entity_id = data.node.id; } else { - this.loadEntity(data.node.id); + if (this.newEntity == true) { + this.loadEntity(this.currentEntity.entity_id); + this.newEntity = false; + } else { + this.loadEntity(data.node.id); + } } }).on('deselect_node.jstree', (e: any, data: any) => { @@ -234,6 +240,7 @@ export class EntitiesAdministrationComponent extends AutoCompletePlugin implemen } } this.elementCtrl.setValue(''); + $j('.autocompleteSearch').blur(); } addElemListModelVisa(element: any) { @@ -253,6 +260,7 @@ export class EntitiesAdministrationComponent extends AutoCompletePlugin implemen this.currentEntity.visaTemplate[this.currentEntity.visaTemplate.length-2].item_mode = 'visa'; } this.userCtrl.setValue(''); + $j('.autocompleteSearch').blur(); } saveEntity() { @@ -266,8 +274,14 @@ export class EntitiesAdministrationComponent extends AutoCompletePlugin implemen this.currentEntity.listTemplate = []; this.entities = data['entities']; this.creationMode = false; + this.newEntity = true; $j('#jstree').jstree(true).settings.core.data = this.entities; - $j('#jstree').jstree("refresh"); + $j('#jstree').jstree(true).settings.select_node = this.currentEntity; + $j('#jstree').jstree(true).refresh(); + $j('#jstree').on("refresh.jstree", (e:any) => { + $j('#jstree').jstree('deselect_all'); + $j('#jstree').jstree('select_node', this.currentEntity.entity_id); + }); this.notify.success(this.lang.entityAdded); }, (err) => { this.notify.error(err.error.errors); @@ -337,6 +351,15 @@ export class EntitiesAdministrationComponent extends AutoCompletePlugin implemen this.notify.error(err.error.errors); }); } + + if (this.idCircuitVisa) { + this.http.delete(this.coreUrl + "rest/listTemplates/" + this.idCircuitVisa) + .subscribe(() => { + this.idCircuitVisa = null; + }, (err) => { + this.notify.error(err.error.errors); + }); + } this.http.put(this.coreUrl + "rest/entities/" + result.entity_id + "/reassign/" + result.redirectEntity, {}) .subscribe((data: any) => { @@ -370,6 +393,15 @@ export class EntitiesAdministrationComponent extends AutoCompletePlugin implemen this.notify.error(err.error.errors); }); } + + if (this.idCircuitVisa) { + this.http.delete(this.coreUrl + "rest/listTemplates/" + this.idCircuitVisa) + .subscribe(() => { + this.idCircuitVisa = null; + }, (err) => { + this.notify.error(err.error.errors); + }); + } this.http.delete(this.coreUrl + "rest/entities/" + this.currentEntity.entity_id) .subscribe((data: any) => { @@ -601,7 +633,6 @@ export class EntitiesAdministrationComponent extends AutoCompletePlugin implemen } toggleRole(role: any) { - console.log(role); if (role.usedIn.length > 0) { this.config = { data: { msg: this.lang.confirmAction, warn: this.lang.roleUsedInTemplateInfo + " : <b>" + role.usedIn.join(', ') + '</b><br/>' + this.lang.roleUsedInTemplateInfo2 } }; let dialogRef = this.dialog.open(ConfirmModalComponent, this.config);