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

FEAT #13271 TIME 1 fix tag input

parent 34ff584b
Branches
Tags
No related merge requests found
......@@ -16,7 +16,7 @@ import { ThesaurusModalComponent } from './thesaurus/thesaurus-modal.component';
@Component({
selector: 'app-tag-input',
templateUrl: "tag-input.component.html",
templateUrl: 'tag-input.component.html',
styleUrls: [
'tag-input.component.scss',
'../../indexation/indexing-form/indexing-form.component.scss'
......@@ -42,6 +42,7 @@ export class TagInputComponent implements OnInit {
tags: any[] = [];
tmpObject: any = null;
/**
* FormControl used when autocomplete is used in form and must be catched in a form control.
......@@ -67,9 +68,30 @@ export class TagInputComponent implements OnInit {
}
ngOnInit() {
this.controlAutocomplete.valueChanges
.pipe(
tap((data: any) => {
console.log('change!', this.returnValue, this.tmpObject, this.functionsService.empty(this.tmpObject));
if (this.returnValue === 'object') {
this.valuesToDisplay = {};
data.forEach((item: any) => {
this.valuesToDisplay[item.id] = item.label;
});
} else {
if (!this.functionsService.empty(this.tmpObject)) {
this.valuesToDisplay[this.tmpObject['id']] = this.tmpObject[this.key];
this.tmpObject = null;
} else {
console.log('initFormValue');
this.initFormValue();
}
}
})
).subscribe();
this.controlAutocomplete.setValue(this.controlAutocomplete.value === null || this.controlAutocomplete.value === '' ? [] : this.controlAutocomplete.value);
this.canAdd = this.privilegeService.hasCurrentUserPrivilege('manage_tags_application');
this.initFormValue();
this.initAutocompleteRoute();
}
......@@ -78,7 +100,6 @@ export class TagInputComponent implements OnInit {
this.options = [];
this.myControl.valueChanges
.pipe(
//tap((value) => this.canAdd = value.length === 0 ? false : true),
debounceTime(300),
filter(value => value.length > 2),
distinctUntilChanged(),
......@@ -98,7 +119,7 @@ export class TagInputComponent implements OnInit {
}
getDatas(data: string) {
return this.http.get('../rest/autocomplete/tags', { params: { "search": data } });
return this.http.get('../rest/autocomplete/tags', { params: { 'search': data } });
}
selectOpt(ev: any) {
......@@ -132,7 +153,6 @@ export class TagInputComponent implements OnInit {
label: item['idToDisplay']
});
}
this.valuesToDisplay[item['id']] = item[this.key];
this.controlAutocomplete.setValue(arrvalue);
}
}
......@@ -199,25 +219,26 @@ export class TagInputComponent implements OnInit {
).subscribe();
}
openThesaurus(tagId: number = null) {
openThesaurus(tag: any = null) {
tag = this.returnValue === 'id' ? tag : tag.id;
const dialogRef = this.dialog.open(ThesaurusModalComponent, {
panelClass: 'maarch-modal',
width: '600px',
data: {
id : tagId
id: tag
}
});
dialogRef.afterClosed().pipe(
filter((data: any) => !this.functionsService.empty(data)),
map((data: any) => {
return {
id : data.id,
idToDisplay : data.label
id: data.id,
idToDisplay: data.label
};
}),
tap((tagItem: any) => {
console.log(tagItem);
this.tmpObject = tagItem;
this.setFormValue(tagItem);
}),
catchError((err: any) => {
......
......@@ -1253,7 +1253,7 @@
"qmail": "Serveur mail local (Qmail)",
"qrcode": "QR code",
"quickSearchInfo": "Cible de la recherche",
"quickSearchTarget": "Recherche sur le sujet (courrier / pièce jointe), numéro chrono (courrier / pièce jointe), contenu d'annotations, code à barre, numéro GED (courrier)",
"quickSearchTarget": "Recherche sur le sujet (courrier / pièce jointe), numéro chrono (courrier / pièce jointe), code à barre, numéro GED (courrier)",
"quota": "Quota",
"quotaExceeded": "Quota dépassé",
"radioInput": "Liste à choix unique",
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment