Adds clear autocomplete when you select value functionality at External References. (Issue #155)

This commit is contained in:
gkolokythas 2019-09-19 18:05:20 +03:00
parent 860801bb89
commit e853c8c44a
3 changed files with 14 additions and 0 deletions

View File

@ -8,6 +8,8 @@ export interface SingleAutoCompleteConfiguration {
minFilteringChars?: number;
// Load and present items from start, without user query. Default: true.
loadDataOnStart?: boolean;
// Remove item after selection.
removeAfterSelection?: boolean;
// Static or initial items.
initialItems?: (data?: any) => Observable<any[]>;
// Data retrieval function

View File

@ -153,6 +153,13 @@ export class SingleAutoCompleteComponent implements OnInit, MatFormFieldControl<
//this._inputValue = " ";
this.stateChanges.next();
this.optionSelected.emit(event.option.value);
if (this.configuration.removeAfterSelection) {
this.clearAutocomplete()
}
}
private clearAutocomplete() {
this._setValue(null);
}
private _setValue(value: any) {

View File

@ -66,6 +66,7 @@ export class DatasetExternalReferencesEditorComponent extends BaseComponent impl
this.dataRepositoriesAutoCompleteConfiguration = {
filterFn: this.searchDatasetExternalDataRepositories.bind(this),
removeAfterSelection: true,
initialItems: (type) => this.searchDatasetExternalDataRepositories('', type),
displayFn: (item) => item ? item.name : null,
titleFn: (item) => item ? item.name : null,
@ -74,6 +75,7 @@ export class DatasetExternalReferencesEditorComponent extends BaseComponent impl
this.externalDatasetAutoCompleteConfiguration = {
filterFn: this.searchDatasetExternalDatasets.bind(this),
removeAfterSelection: true,
initialItems: (type) => this.searchDatasetExternalDatasets('', type),//.filter(resultItem => excludedItems.map(x => x.id).indexOf(resultItem.id) === -1),
displayFn: (item) => item ? item.label : null,
titleFn: (item) => item ? item.label : null,
@ -82,6 +84,7 @@ export class DatasetExternalReferencesEditorComponent extends BaseComponent impl
this.registriesAutoCompleteConfiguration = {
filterFn: this.searchDatasetExternalRegistries.bind(this),
removeAfterSelection: true,
initialItems: (type) => this.searchDatasetExternalRegistries('', type),
displayFn: (item) => item ? item.label : null,
titleFn: (item) => item ? item.label: null,
@ -90,6 +93,7 @@ export class DatasetExternalReferencesEditorComponent extends BaseComponent impl
this.servicesAutoCompleteConfiguration = {
filterFn: this.searchDatasetExternalServices.bind(this),
removeAfterSelection: true,
initialItems: (type) => this.searchDatasetExternalServices('', type),
displayFn: (item) => item ? item.label : null,
titleFn: (item) => item ? item.label : null,
@ -98,6 +102,7 @@ export class DatasetExternalReferencesEditorComponent extends BaseComponent impl
this.tagsAutoCompleteConfiguration = {
filterFn: this.searchDatasetTags.bind(this),
removeAfterSelection: true,
initialItems: (type) => this.searchDatasetTags('', type),
displayFn: (item) => item ? item.name : null,
titleFn: (item) => item ? item.name : null,