diff --git a/dmp-frontend/src/app/library/auto-complete/multiple/multiple-auto-complete.component.html b/dmp-frontend/src/app/library/auto-complete/multiple/multiple-auto-complete.component.html index ccaa21360..8b035d27c 100644 --- a/dmp-frontend/src/app/library/auto-complete/multiple/multiple-auto-complete.component.html +++ b/dmp-frontend/src/app/library/auto-complete/multiple/multiple-auto-complete.component.html @@ -1,10 +1,10 @@
- + {{this._displayFn(selectedItem)}} cancel - + diff --git a/dmp-frontend/src/app/library/auto-complete/single/single-auto-complete.component.html b/dmp-frontend/src/app/library/auto-complete/single/single-auto-complete.component.html index 894fb3a9a..a2c9cf312 100644 --- a/dmp-frontend/src/app/library/auto-complete/single/single-auto-complete.component.html +++ b/dmp-frontend/src/app/library/auto-complete/single/single-auto-complete.component.html @@ -1,5 +1,14 @@
- + + + {{_displayFn(value)}} + cancel + + + + + + diff --git a/dmp-frontend/src/app/library/auto-complete/single/single-auto-complete.component.ts b/dmp-frontend/src/app/library/auto-complete/single/single-auto-complete.component.ts index 503aa31dc..3620903cd 100644 --- a/dmp-frontend/src/app/library/auto-complete/single/single-auto-complete.component.ts +++ b/dmp-frontend/src/app/library/auto-complete/single/single-auto-complete.component.ts @@ -1,4 +1,5 @@ import { FocusMonitor } from '@angular/cdk/a11y'; +import { COMMA, ENTER } from '@angular/cdk/keycodes'; import { Component, ElementRef, EventEmitter, Input, OnDestroy, OnInit, Optional, Output, Self } from '@angular/core'; import { ControlValueAccessor, NgControl } from '@angular/forms'; import { MatAutocompleteSelectedEvent, MatFormFieldControl } from '@angular/material'; @@ -36,6 +37,7 @@ export class SingleAutoCompleteComponent implements OnInit, MatFormFieldControl< private requestDelay = 200; //ms private minFilteringChars = 1; private loadDataOnStart = true; + separatorKeysCodes: number[] = [ENTER, COMMA]; get empty() { return !this._inputValue || this._inputValue.length === 0; @@ -73,7 +75,7 @@ export class SingleAutoCompleteComponent implements OnInit, MatFormFieldControl< } set value(value: any | null) { this._selectedValue = value; - this._inputValue = value; + this._inputValue = " "; this.stateChanges.next(); } private _selectedValue; @@ -147,6 +149,7 @@ export class SingleAutoCompleteComponent implements OnInit, MatFormFieldControl< _optionSelected(event: MatAutocompleteSelectedEvent) { this._setValue(this.configuration.valueAssign ? this.configuration.valueAssign(event.option.value) : event.option.value); + this._inputValue = " ";; this.stateChanges.next(); this.optionSelected.emit(event.option.value); } @@ -212,6 +215,10 @@ export class SingleAutoCompleteComponent implements OnInit, MatFormFieldControl< } } + chipRemove(): void { + this.value = null; + } + ngOnDestroy() { this.stateChanges.complete(); this.fm.stopMonitoring(this.elRef.nativeElement);