Skip to content
Snippets Groups Projects
Verified Commit 4d6052c5 authored by Alex ORLUC's avatar Alex ORLUC
Browse files

fix autocomplete manageDatas in adminMode

parent b5477b90
No related branches found
No related tags found
No related merge requests found
......@@ -110,7 +110,7 @@
<plugin-autocomplete [labelPlaceholder]="lang.searchValue"
[routeDatas]="[field.values[0]]" [targetSearchKey]="'idToDisplay'"
[size]="'small'" [control]="arrFormControl[field.identifier]"
[manageDatas]="field.values[1]" style="width:100%;"></plugin-autocomplete>
[manageDatas]="!adminMode ? field.values[1] : undefined" style="width:100%;"></plugin-autocomplete>
</ng-container>
</div>
<div class="fieldState">
......
This diff is collapsed.
......@@ -91,7 +91,7 @@ export class PluginAutocomplete implements OnInit {
valuesToDisplay: any = {};
dialogRef: MatDialogRef<any>;
constructor(
public http: HttpClient,
private notify: NotificationService,
......@@ -198,7 +198,7 @@ export class PluginAutocomplete implements OnInit {
}
})
).subscribe();
});
});
}
setFormValue(item: any) {
......@@ -245,26 +245,28 @@ export class PluginAutocomplete implements OnInit {
}
addItem() {
const newElem = {};
newElem[this.key] = this.myControl.value;
this.dialogRef = this.dialog.open(ConfirmComponent, { autoFocus: false, disableClose: true, data: { title: this.lang.confirm, msg: 'Voulez-vous créer cet élément <b>' + newElem[this.key] + '</b>&nbsp;?' } });
this.dialogRef.afterClosed().pipe(
filter((data: string) => data === 'ok'),
exhaustMap(() => this.http.post('../..' + this.manageDatas, {label : newElem[this.key]})),
tap((data: any) => {
for (var key in data) {
newElem['id'] = data[key];
}
this.setFormValue(newElem);
this.notify.success(this.lang.elementAdded);
}),
catchError((err: any) => {
this.notify.handleErrors(err);
return of(false);
})
).subscribe();
if (this.manageDatas !== undefined) {
const newElem = {};
newElem[this.key] = this.myControl.value;
this.dialogRef = this.dialog.open(ConfirmComponent, { autoFocus: false, disableClose: true, data: { title: this.lang.confirm, msg: 'Voulez-vous créer cet élément <b>' + newElem[this.key] + '</b>&nbsp;?' } });
this.dialogRef.afterClosed().pipe(
filter((data: string) => data === 'ok'),
exhaustMap(() => this.http.post('../..' + this.manageDatas, { label: newElem[this.key] })),
tap((data: any) => {
for (var key in data) {
newElem['id'] = data[key];
}
this.setFormValue(newElem);
this.notify.success(this.lang.elementAdded);
}),
catchError((err: any) => {
this.notify.handleErrors(err);
return of(false);
})
).subscribe();
}
}
}
\ No newline at end of file
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