Skip to content
Snippets Groups Projects
Commit 599dccb9 authored by Alex ORLUC's avatar Alex ORLUC
Browse files

FEAT #258 hide panel if no parent_entity when cancel

parent ccdd5cd3
No related branches found
No related tags found
No related merge requests found
......@@ -15,7 +15,7 @@
<mat-divider></mat-divider>
<mat-nav-list>
<h3 mat-subheader>{{lang.actions}}</h3>
<a mat-list-item (click)="prepareEntityAdd()">
<a mat-list-item (click)="prepareEntityAdd()" *ngIf="!creationMode">
<mat-icon color="primary" mat-list-icon class="fa fa-plus"></mat-icon>
<p mat-line>
{{lang.add}}
......@@ -57,26 +57,20 @@
<mat-nav-list>
<mat-tab-group>
<mat-tab label="{{lang.informations}}">
<mat-tab [label]="creationMode ? 'Créer une nouvelle entité' : lang.informations">
<form class="form-horizontal" #entityForm="ngForm" style="overflow:hidden;">
<div class="form-group">
<div class="col-sm-12">
<mat-form-field>
<mat-select id="parent_entity_id" name="parent_entity_id" title="{{lang.isLinkedTo}}" placeholder="{{lang.isLinkedTo}}" [(ngModel)]="currentEntity.parent_entity_id"
(change)="selectParentEntity(currentEntity.parent_entity_id)" *ngIf="creationMode">
<mat-option value="">
</mat-option>
<mat-option *ngFor="let entity of entities | sortBy : 'entity_label'" [value]="entity.entity_id">
{{entity.entity_label}}
</mat-option>
</mat-select>
<mat-select id="parent_entity_id" name="parent_entity_id" title="{{lang.isLinkedTo}}" placeholder="{{lang.isLinkedTo}}" [(ngModel)]="currentEntity.parent_entity_id"
*ngIf="!creationMode">
<mat-option value="">
</mat-option>
<mat-option *ngFor="let entity of entities | sortBy : 'entity_label'" [value]="entity.entity_id">
{{entity.entity_label}}
(change)="selectParentEntity(currentEntity.parent_entity_id)" required>
<mat-option *ngIf="entities.length == 0" value="">
</mat-option>
<ng-container *ngFor="let entity of entities | sortBy : 'entity_label'">
<mat-option [value]="entity.entity_id" *ngIf="(!entity.state.disabled && entity.entity_id != currentEntity.entity_id) || currentEntity.parent_entity_id == entity.entity_id">
{{entity.entity_label}}
</mat-option>
</ng-container>
</mat-select>
</mat-form-field>
<mat-form-field>
......@@ -220,10 +214,10 @@
<mat-autocomplete #auto="matAutocomplete">
<mat-option *ngFor="let elem of filteredElements | async" [value]="elem.id" (click)="addElemListModel(elem)">
<p mat-line>
<span class="col-sm-1">
<span class="col-xm-1">
<mat-icon color="primary" [class]="elem.type == 'entity' ? 'fa fa-sitemap fa-2x' : 'fa fa-user fa-2x'" style="margin-right:0px;"></mat-icon>
</span>
<span class="col-sm-11">
<span class="col-xm-11">
{{ elem.idToDisplay }}
<small>{{ elem.otherInfo }}</small>
</span>
......
......@@ -373,17 +373,23 @@ export class EntitiesAdministrationComponent extends AutoCompletePlugin implemen
this.creationMode = false;
this.isDraggable = true;
$j('#jstree').jstree('deselect_all');
for (let i = 0; i < this.entities.length; i++) {
if (this.entities[i].entity_id == this.currentEntity.parent_entity_id) {
$j('#jstree').jstree('select_node', this.entities[i]);
break;
if(this.currentEntity.parent_entity_id) {
for (let i = 0; i < this.entities.length; i++) {
if (this.entities[i].entity_id == this.currentEntity.parent_entity_id) {
$j('#jstree').jstree('select_node', this.entities[i]);
break;
}
}
} else {
this.sidenav.close();
}
}
selectParentEntity(entity_id:any) {
$j('#jstree').jstree('deselect_all');
$j('#jstree').jstree('select_node', entity_id);
if (this.creationMode) {
$j('#jstree').jstree('deselect_all');
$j('#jstree').jstree('select_node', entity_id);
}
}
removeEntity() {
......@@ -398,13 +404,9 @@ export class EntitiesAdministrationComponent extends AutoCompletePlugin implemen
this.entities = data['entities'];
$j('#jstree').jstree(true).settings.core.data = this.entities;
$j('#jstree').jstree("refresh");
this.sidenav.close();
this.notify.success(this.lang.entityDeleted);
for (let i = 0; i < this.entities.length; i++) {
if (this.entities[i].allowed == true) {
$j('#jstree').jstree('select_node', this.entities[i]);
break;
}
}
}, (err) => {
this.notify.error(err.error.errors);
});
......@@ -420,13 +422,8 @@ export class EntitiesAdministrationComponent extends AutoCompletePlugin implemen
this.entities = data['entities'];
$j('#jstree').jstree(true).settings.core.data = this.entities;
$j('#jstree').jstree("refresh");
this.sidenav.close();
this.notify.success(this.lang.entityDeleted);
for (let i = 0; i < this.entities.length; i++) {
if (this.entities[i].allowed == true) {
$j('#jstree').jstree('select_node', this.entities[i]);
break;
}
}
}, (err) => {
this.notify.error(err.error.errors);
});
......@@ -449,12 +446,13 @@ export class EntitiesAdministrationComponent extends AutoCompletePlugin implemen
} else {
this.currentEntity = { "entity_type": this.entityTypeList[0].id };
$j('#jstree').jstree('deselect_all');
for (let i = 0; i < this.entities.length; i++) {
this.sidenav.open();
/*for (let i = 0; i < this.entities.length; i++) {
if (this.entities[i].allowed == true) {
$j('#jstree').jstree('select_node', this.entities[i]);
break;
}
}
}*/
}
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment