diff --git a/src/frontend/app/indexation/indexing-form/indexing-form.component.html b/src/frontend/app/indexation/indexing-form/indexing-form.component.html index d34bfe03ebfcf9e612215e602ee88d108415a1be..f3ebaf3ba182b812841beb3fcd62cbd03a7d5b0a 100644 --- a/src/frontend/app/indexation/indexing-form/indexing-form.component.html +++ b/src/frontend/app/indexation/indexing-form/indexing-form.component.html @@ -102,6 +102,12 @@ </mat-chip> </mat-chip-list> </ng-container> + <ng-container *ngIf="field.type === 'autocomplete'"> + <plugin-autocomplete [labelPlaceholder]="lang.chooseValue" + [routeDatas]="[field.values[0]]" [targetSearchKey]="'idToDisplay'" [size]="'small'" + [control]="arrFormControl[field.identifier]" + style="width:100%;"></plugin-autocomplete> + </ng-container> </div> <div class="fieldState"> <i class="fas fa-asterisk" diff --git a/src/frontend/app/indexation/indexing-form/indexing-form.component.ts b/src/frontend/app/indexation/indexing-form/indexing-form.component.ts index 62854f2965aaf3e8bf388cba19f14683860ea83d..049fa741da385fb72a085a818277ab3a4fdc7c9f 100644 --- a/src/frontend/app/indexation/indexing-form/indexing-form.component.ts +++ b/src/frontend/app/indexation/indexing-form/indexing-form.component.ts @@ -80,10 +80,10 @@ export class IndexingFormComponent implements OnInit { identifier: 'contact', label: this.lang.getSenders, unit: 'contact', - type: 'string', + type: 'autocomplete', system: true, mandatory: true, - values: [] + values: ['/rest/autocomplete/contacts'] }, { identifier: 'destination', @@ -98,10 +98,10 @@ export class IndexingFormComponent implements OnInit { identifier: 'folder', label: this.lang.folder, unit: 'classement', - type: 'string', + type: 'autocomplete', system: true, mandatory: true, - values: [] + values: ['/rest/autocomplete/folders'] } ]; @@ -192,7 +192,7 @@ export class IndexingFormComponent implements OnInit { }); }); }), - //finalize(() => this.loading = false), + finalize(() => this.loading = false), catchError((err: any) => { this.notify.handleErrors(err); return of(false); @@ -297,7 +297,6 @@ export class IndexingFormComponent implements OnInit { this.fieldCategories.forEach(element => { this['indexingModels_' + element].forEach((elem: any) => { - if (elem.identifier === 'docDate') { elem.startDate = ''; elem.endDate = '_TODAY'; @@ -401,12 +400,14 @@ export class IndexingFormComponent implements OnInit { if (elem.identifier === 'doctype') { this.http.get("../../rest/doctypes").pipe( tap((data: any) => { + let title = ''; let arrValues: any[] = []; data.structure.forEach((doctype: any) => { if (doctype['doctypes_second_level_id'] === undefined) { arrValues.push({ id: doctype.doctypes_first_level_id, label: doctype.doctypes_first_level_label, + title: doctype.doctypes_first_level_label, disabled: true, isTitle: true, color: doctype.css_style @@ -415,6 +416,7 @@ export class IndexingFormComponent implements OnInit { arrValues.push({ id: doctype.doctypes_second_level_id, label: ' ' + doctype.doctypes_second_level_label, + title: doctype.doctypes_second_level_label, disabled: true, isTitle: true, color: doctype.css_style @@ -424,6 +426,7 @@ export class IndexingFormComponent implements OnInit { return { id: info.type_id, label: ' ' + info.description, + title: info.description, disabled: false, isTitle: false, } @@ -470,6 +473,9 @@ export class IndexingFormComponent implements OnInit { if (data.indexingModel.fields.length === 0) { this.fieldCategories.forEach(element => { this['indexingModels_' + element] = this.indexingModelsCore.filter((x: any, i: any, a: any) => x.unit === element); + this.indexingModelsCore.forEach(field => { + this.arrFormControl[field.identifier] = new FormControl({ value: field.default_value, disabled: (field.today && this.adminMode) ? true : false }, (field.mandatory && !this.adminMode) ? [Validators.required] : []); + }); }); this.notify.error("Champs introuvables! les données de base ont été chargés"); } else { @@ -498,7 +504,13 @@ export class IndexingFormComponent implements OnInit { this.availableCustomFields.splice(indexFound, 1); fieldExist = true; } - if (this.indexingModelsCore.map(info => info.identifier).indexOf(field.identifier) > -1) { + + indexFound = this.indexingModelsCore.map(info => info.identifier).indexOf(field.identifier); + + if (indexFound > -1) { + field.label = this.indexingModelsCore[indexFound].label; + field.values = this.indexingModelsCore[indexFound].values; + field.type = this.indexingModelsCore[indexFound].type; fieldExist = true; field.system = true; } diff --git a/src/frontend/lang/lang-en.ts b/src/frontend/lang/lang-en.ts index 0dfbafe2cb38ba7ee2cf78377896f589824f403a..14520372acb8dbbea310fb786ec00e859508fcf5 100755 --- a/src/frontend/lang/lang-en.ts +++ b/src/frontend/lang/lang-en.ts @@ -1117,4 +1117,5 @@ export const LANG_EN = { "indexingModelUpdated" : "Indexing model updated", "indexingModelCreation" : "Indexing model creation", "integerInput" : "Input number", + "noSelectedValue" : "No selected value", }; diff --git a/src/frontend/lang/lang-fr.ts b/src/frontend/lang/lang-fr.ts index 7662c575f19bcb5dafce46e6be9b7ea3f5681c98..0f80ef8cb609255ea777cb341da31ff54035dcfb 100755 --- a/src/frontend/lang/lang-fr.ts +++ b/src/frontend/lang/lang-fr.ts @@ -1154,4 +1154,5 @@ export const LANG_FR = { "indexingModelUpdated" : "Modèle d'enregistrement modifié", "indexingModelCreation" : "Création d'un modèle d'enregistrement", "integerInput" : "Champ numérique", + "noSelectedValue" : "Aucun élément sélectionné", }; diff --git a/src/frontend/lang/lang-nl.ts b/src/frontend/lang/lang-nl.ts index bfc52fd31202cf56afa1d0fc00e7feda4de247ce..b4ae7ed8a1e8b922b835ace93b1e9d6238377bd3 100755 --- a/src/frontend/lang/lang-nl.ts +++ b/src/frontend/lang/lang-nl.ts @@ -1143,4 +1143,5 @@ export const LANG_NL = { "indexingModelUpdated" : "Indexing model updated", //_TO_TRANSLATE "indexingModelCreation" : "Indexing model creation", //_TO_TRANSLATE "integerInput" : "Input number", //_TO_TRANSLATE + "noSelectedValue" : "No selected value", //_TO_TRANSLATE }; diff --git a/src/frontend/plugins/autocomplete/autocomplete.component.html b/src/frontend/plugins/autocomplete/autocomplete.component.html index 3c1781b26a61439602aced41d8be9241c6a5ae40..ed1cbc7951533fa3d183e7959fefb71286dac499 100644 --- a/src/frontend/plugins/autocomplete/autocomplete.component.html +++ b/src/frontend/plugins/autocomplete/autocomplete.component.html @@ -1,11 +1,16 @@ <form> + <input *ngIf="controlAutocomplete !== undefined" type="hidden" [formControl]="controlAutocomplete"> <mat-form-field [class.smallInput]="size === 'small'" - [appearance]="singleMode !== undefined ? 'standard' : 'outline'"> + [appearance]="singleMode !== undefined && controlAutocomplete === undefined ? 'legacy' : 'outline'" + floatLabel="never"> <mat-label *ngIf="singleMode !== undefined">{{placeholder}}</mat-label> - <mat-icon *ngIf="size === 'default'" color="primary" class="fa fa-search" matPrefix></mat-icon> + <mat-icon *ngIf="size !== 'small' && myControl.enabled" color="primary" class="fa fa-search" matPrefix></mat-icon> <input type="text" #autoCompleteInput [placeholder]="singleMode !== undefined ? '' : placeholder" aria-label="Number" matInput [formControl]="myControl" [matAutocomplete]="auto" (click)="$event.stopPropagation()" (focus)="resetAutocomplete()" [required]="required"> + <button type="button" *ngIf="myControl.disabled" matSuffix mat-icon-button color="warn" (click)="unsetValue()"> + <mat-icon class="fa fa-times" color="warn" [title]="lang.delete"></mat-icon> + </button> <mat-autocomplete #auto="matAutocomplete" (optionSelected)="selectOpt($event)"> <ng-container *ngIf="options.length > 0 && !loading"> <mat-option *ngFor="let option of filteredOptions | async | sortBy: key" [value]="option"> @@ -21,4 +26,16 @@ </mat-option> </mat-autocomplete> </mat-form-field> + <ng-container *ngIf="controlAutocomplete !== undefined"> + <mat-chip-list class="mat-chip-list-stacked" color="default"> + <mat-chip *ngFor="let item of controlAutocomplete.value;let i=index" class="activeListAutocomplete" + color="default" [removable]="true" (removed)="removeItem(i)"> + <span style="display: flex;flex: 1;" [innerHTML]="item"></span> + <mat-icon matChipRemove class="fa fa-times"></mat-icon> + </mat-chip> + </mat-chip-list> + <div class="noResult" *ngIf="controlAutocomplete.value.length === 0"> + {{lang.noSelectedValue}} + </div> + </ng-container> </form> \ No newline at end of file diff --git a/src/frontend/plugins/autocomplete/autocomplete.component.scss b/src/frontend/plugins/autocomplete/autocomplete.component.scss index a9049e770bac7633ac35d015cc4dff12c0b70b64..314094d962d8dd1fd2b78fec2d0ee83cc055a7dc 100644 --- a/src/frontend/plugins/autocomplete/autocomplete.component.scss +++ b/src/frontend/plugins/autocomplete/autocomplete.component.scss @@ -3,6 +3,7 @@ .mat-form-field-appearance-outline { font-size: 11px; } + ::ng-deep.mat-form-field-appearance-outline .mat-form-field-outline-thick { color: $primary; } @@ -10,10 +11,12 @@ ::ng-deep.mat-form-field-prefix { top: 0px !important; } + .mat-option { ::ng-deep.mat-option-text { display: flex; } + span { font-size: 110%; font-weight: bold; @@ -29,8 +32,9 @@ .smallInput { padding-left: 20px; padding-right: 20px; + ::ng-deep.mat-form-field-infix { - padding : 0px; + padding: 0px; padding-bottom: 5px; } } @@ -41,4 +45,21 @@ line-height: 13px; display: table-cell; vertical-align: middle; +} + +.input-form { + ::ng-deep.mat-form-field-prefix { + left: 15px; + } +} + +.activeListAutocomplete { + font-size: 13px; + height: auto; +} + +.noResult { + text-align: center; + font-style: italic; + opacity: 0.5; } \ No newline at end of file diff --git a/src/frontend/plugins/autocomplete/autocomplete.component.ts b/src/frontend/plugins/autocomplete/autocomplete.component.ts index 429ad5f706f9512d589b7a335f48dcdb1e566bf9..47c0800cbca08ef7ca0c9825b8cf1164bf3b2fa2 100644 --- a/src/frontend/plugins/autocomplete/autocomplete.component.ts +++ b/src/frontend/plugins/autocomplete/autocomplete.component.ts @@ -10,7 +10,7 @@ import { HttpClient } from '@angular/common/http'; @Component({ selector: 'plugin-autocomplete', templateUrl: 'autocomplete.component.html', - styleUrls: ['autocomplete.component.scss'], + styleUrls: ['autocomplete.component.scss', '../../app/indexation/indexing-form/indexing-form.component.scss'], }) export class PluginAutocomplete implements OnInit { lang: any = LANG; @@ -20,8 +20,8 @@ export class PluginAutocomplete implements OnInit { listInfo: string; type = { - user : 'fa-user', - entity : 'fa-sitemap' + user: 'fa-user', + entity: 'fa-sitemap' } @Input('size') size: string; @@ -33,8 +33,13 @@ export class PluginAutocomplete implements OnInit { @Input('labelList') optGroupLabel: string; @Input('targetSearchKey') key: string; @Input('subInfoKey') subInfoKey: string; + + @Input('control') controlAutocomplete: FormControl; + + @Output('triggerEvent') selectedOpt = new EventEmitter(); + @ViewChild('autoCompleteInput', { static: true }) autoCompleteInput: ElementRef; filteredOptions: Observable<string[]>; @@ -47,7 +52,12 @@ export class PluginAutocomplete implements OnInit { ngOnInit() { this.optGroupLabel = this.optGroupLabel === undefined ? this.lang.availableValues : this.optGroupLabel; this.placeholder = this.placeholder === undefined ? this.lang.chooseValue : this.placeholder; - this.size = this.size === undefined ? 'default' : 'small'; + + if (this.controlAutocomplete !== undefined) { + this.controlAutocomplete.setValue(this.controlAutocomplete.value === null ? [] : this.controlAutocomplete.value); + } + + this.size = this.size === undefined ? 'default' : this.size; if (this.routeDatas !== undefined) { this.initAutocompleteRoute(); @@ -85,7 +95,7 @@ export class PluginAutocomplete implements OnInit { } getDatas(data: string) { - let arrayObs:any = []; + let arrayObs: any = []; let test: any = []; this.routeDatas.forEach(element => { arrayObs.push(this.http.get('../..' + element, { params: { "search": data } })); @@ -104,17 +114,25 @@ export class PluginAutocomplete implements OnInit { } selectOpt(ev: any) { - if (this.singleMode !== undefined) { - this.myControl.setValue(ev.option.value[this.key]); + if (this.controlAutocomplete !== undefined) { + let arrvalue = []; + if (this.controlAutocomplete.value !== null) { + arrvalue = this.controlAutocomplete.value; + } + arrvalue.push(ev.option.value[this.key]); + this.controlAutocomplete.setValue(arrvalue); + } + + if (this.selectedOpt !== undefined) { + this.resetAutocomplete(); + this.autoCompleteInput.nativeElement.blur(); + this.selectedOpt.emit(ev.option.value); } - this.resetAutocomplete(); - this.autoCompleteInput.nativeElement.blur(); - this.selectedOpt.emit(ev.option.value); } resetAutocomplete() { if (this.singleMode === undefined) { - this.myControl.setValue(''); + this.myControl.setValue(''); } if (this.routeDatas !== undefined) { this.options = []; @@ -130,4 +148,16 @@ export class PluginAutocomplete implements OnInit { return this.options; } } + + unsetValue() { + this.controlAutocomplete.setValue(''); + this.myControl.setValue(''); + this.myControl.enable(); + } + + removeItem(index: number) { + let arrValue = this.controlAutocomplete.value; + arrValue.splice(index, 1); + this.controlAutocomplete.setValue(arrValue); + } } \ No newline at end of file diff --git a/src/frontend/plugins/select-search/select-search.component.html b/src/frontend/plugins/select-search/select-search.component.html index 272558b309c3ada463b11d1fbef59922f32da874..8f5030464c6b6c66a3d7d9a7a1799b2dbfeffdd0 100644 --- a/src/frontend/plugins/select-search/select-search.component.html +++ b/src/frontend/plugins/select-search/select-search.component.html @@ -12,7 +12,7 @@ </button> </div> - <div *ngIf="noEntriesFoundLabel && value && _options?.length === 0 && datas.length > 5" class="mat-select-search-no-entries-found"> + <div *ngIf="value && _options?.length === 0 && datas.length > 5" class="mat-select-search-no-entries-found"> {{lang.noResult}} </div> <mat-option *ngIf="showResetOption"></mat-option>