UI: Fix incorrect add chip for autocomplete component
This commit is contained in:
parent
f325edef75
commit
53a919e046
@ -37,7 +37,6 @@
|
|||||||
[matAutocomplete]="labelAutocomplete"
|
[matAutocomplete]="labelAutocomplete"
|
||||||
[matChipInputFor]="chipList"
|
[matChipInputFor]="chipList"
|
||||||
[matChipInputSeparatorKeyCodes]="separatorKeysCodes"
|
[matChipInputSeparatorKeyCodes]="separatorKeysCodes"
|
||||||
matChipInputAddOnBlur
|
|
||||||
(matChipInputTokenEnd)="add($event)">
|
(matChipInputTokenEnd)="add($event)">
|
||||||
</mat-chip-list>
|
</mat-chip-list>
|
||||||
<mat-autocomplete #labelAutocomplete="matAutocomplete"
|
<mat-autocomplete #labelAutocomplete="matAutocomplete"
|
||||||
|
|||||||
@ -36,7 +36,6 @@
|
|||||||
[matAutocomplete]="entitySubtypeAutocomplete"
|
[matAutocomplete]="entitySubtypeAutocomplete"
|
||||||
[matChipInputFor]="chipList"
|
[matChipInputFor]="chipList"
|
||||||
[matChipInputSeparatorKeyCodes]="separatorKeysCodes"
|
[matChipInputSeparatorKeyCodes]="separatorKeysCodes"
|
||||||
matChipInputAddOnBlur
|
|
||||||
(matChipInputTokenEnd)="chipAdd($event)">
|
(matChipInputTokenEnd)="chipAdd($event)">
|
||||||
</mat-chip-list>
|
</mat-chip-list>
|
||||||
<mat-autocomplete #entitySubtypeAutocomplete="matAutocomplete"
|
<mat-autocomplete #entitySubtypeAutocomplete="matAutocomplete"
|
||||||
|
|||||||
@ -203,7 +203,7 @@ export class EntitySubTypeListComponent implements ControlValueAccessor, OnInit,
|
|||||||
this.dirty = true;
|
this.dirty = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
add(entitySubtype: string): void {
|
private add(entitySubtype: string): void {
|
||||||
if (!this.modelValue || this.modelValue.indexOf(entitySubtype) === -1) {
|
if (!this.modelValue || this.modelValue.indexOf(entitySubtype) === -1) {
|
||||||
if (!this.modelValue) {
|
if (!this.modelValue) {
|
||||||
this.modelValue = [];
|
this.modelValue = [];
|
||||||
@ -213,13 +213,12 @@ export class EntitySubTypeListComponent implements ControlValueAccessor, OnInit,
|
|||||||
this.entitySubtypeListFormGroup.get('entitySubtypeList').setValue(this.entitySubtypeList);
|
this.entitySubtypeListFormGroup.get('entitySubtypeList').setValue(this.entitySubtypeList);
|
||||||
}
|
}
|
||||||
this.propagateChange(this.modelValue);
|
this.propagateChange(this.modelValue);
|
||||||
this.clear();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
chipAdd(event: MatChipInputEvent): void {
|
chipAdd(event: MatChipInputEvent): void {
|
||||||
const value = event.value;
|
const value = (event.value || '').trim();
|
||||||
if ((value || '').trim()) {
|
if (value) {
|
||||||
this.add(value.trim());
|
this.add(value);
|
||||||
}
|
}
|
||||||
this.clear('');
|
this.clear('');
|
||||||
}
|
}
|
||||||
@ -234,7 +233,6 @@ export class EntitySubTypeListComponent implements ControlValueAccessor, OnInit,
|
|||||||
this.modelValue = null;
|
this.modelValue = null;
|
||||||
}
|
}
|
||||||
this.propagateChange(this.modelValue);
|
this.propagateChange(this.modelValue);
|
||||||
this.clear();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user