From 5a0e410ddeca44603bfff02fdbb00e70a826dffe Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Philippe=20Lafreni=C3=A8re?= <53181414+PhilippeLafreniere18@users.noreply.github.com> Date: Wed, 21 Sep 2022 16:32:20 -0400 Subject: [PATCH] fix(entity-table): fix edition autocomplete (#1098) --- .../entity-table/entity-table.component.html | 18 ++++++----- .../entity-table/entity-table.component.ts | 32 ++++++++++--------- 2 files changed, 27 insertions(+), 23 deletions(-) diff --git a/packages/common/src/lib/entity/entity-table/entity-table.component.html b/packages/common/src/lib/entity/entity-table/entity-table.component.html index ce5720486f..703afbbf84 100644 --- a/packages/common/src/lib/entity/entity-table/entity-table.component.html +++ b/packages/common/src/lib/entity/entity-table/entity-table.component.html @@ -93,14 +93,16 @@ {{ option.value }} - - - - {{ option.value }} - - + + + + {{ option.value }} + + ; + public filteredOptions = {}; /** * Reference to the column renderer types @@ -256,9 +256,9 @@ export class EntityTableComponent implements OnInit, OnChanges, OnDestroy { /** * Process autocomplete value change (edition) */ - onAutocompleteValueChange(column: string, record: EntityRecord, event) { - this.formGroup.controls[column].setValue(event.option.viewValue); - const key = this.getColumnKeyWithoutPropertiesTag(column); + onAutocompleteValueChange(column: EntityTableColumn, record: EntityRecord, event) { + this.formGroup.controls[column.name].setValue(event.option.viewValue); + const key = this.getColumnKeyWithoutPropertiesTag(column.name); record.entity.properties[key] = event.option.value; } @@ -310,17 +310,19 @@ export class EntityTableComponent implements OnInit, OnChanges, OnDestroy { item[key] )); - this.filteredOptions = this.formGroup.controls[column.name].valueChanges.pipe( - map(value => { - if (value.length) { - return column.domainValues.filter((option) => { - const filterNormalized = value ? value.toLowerCase().normalize('NFD').replace(/[\u0300-\u036f]/g, '') : ''; - const featureNameNormalized = option.value.toLowerCase().normalize('NFD').replace(/[\u0300-\u036f]/g, ''); - return featureNameNormalized.includes(filterNormalized); - }); - } - }) - ); + this.filteredOptions[column.name] = new Observable(); + this.filteredOptions[column.name] = + this.formGroup.controls[column.name].valueChanges.pipe( + map(value => { + if (value?.length) { + return column.domainValues?.filter((option) => { + const filterNormalized = value ? value.toLowerCase().normalize('NFD').replace(/[\u0300-\u036f]/g, '') : ''; + const featureNameNormalized = option.value.toLowerCase().normalize('NFD').replace(/[\u0300-\u036f]/g, ''); + return featureNameNormalized.includes(filterNormalized); + }); + } + }) + ); let formControlValue = item[key]; column.domainValues.forEach(option => {