Adds clear autocomplete when you select value functionality at External References. (Issue #155)
This commit is contained in:
parent
860801bb89
commit
e853c8c44a
|
@ -8,6 +8,8 @@ export interface SingleAutoCompleteConfiguration {
|
||||||
minFilteringChars?: number;
|
minFilteringChars?: number;
|
||||||
// Load and present items from start, without user query. Default: true.
|
// Load and present items from start, without user query. Default: true.
|
||||||
loadDataOnStart?: boolean;
|
loadDataOnStart?: boolean;
|
||||||
|
// Remove item after selection.
|
||||||
|
removeAfterSelection?: boolean;
|
||||||
// Static or initial items.
|
// Static or initial items.
|
||||||
initialItems?: (data?: any) => Observable<any[]>;
|
initialItems?: (data?: any) => Observable<any[]>;
|
||||||
// Data retrieval function
|
// Data retrieval function
|
||||||
|
|
|
@ -153,6 +153,13 @@ export class SingleAutoCompleteComponent implements OnInit, MatFormFieldControl<
|
||||||
//this._inputValue = " ";
|
//this._inputValue = " ";
|
||||||
this.stateChanges.next();
|
this.stateChanges.next();
|
||||||
this.optionSelected.emit(event.option.value);
|
this.optionSelected.emit(event.option.value);
|
||||||
|
if (this.configuration.removeAfterSelection) {
|
||||||
|
this.clearAutocomplete()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private clearAutocomplete() {
|
||||||
|
this._setValue(null);
|
||||||
}
|
}
|
||||||
|
|
||||||
private _setValue(value: any) {
|
private _setValue(value: any) {
|
||||||
|
|
|
@ -66,6 +66,7 @@ export class DatasetExternalReferencesEditorComponent extends BaseComponent impl
|
||||||
|
|
||||||
this.dataRepositoriesAutoCompleteConfiguration = {
|
this.dataRepositoriesAutoCompleteConfiguration = {
|
||||||
filterFn: this.searchDatasetExternalDataRepositories.bind(this),
|
filterFn: this.searchDatasetExternalDataRepositories.bind(this),
|
||||||
|
removeAfterSelection: true,
|
||||||
initialItems: (type) => this.searchDatasetExternalDataRepositories('', type),
|
initialItems: (type) => this.searchDatasetExternalDataRepositories('', type),
|
||||||
displayFn: (item) => item ? item.name : null,
|
displayFn: (item) => item ? item.name : null,
|
||||||
titleFn: (item) => item ? item.name : null,
|
titleFn: (item) => item ? item.name : null,
|
||||||
|
@ -74,6 +75,7 @@ export class DatasetExternalReferencesEditorComponent extends BaseComponent impl
|
||||||
|
|
||||||
this.externalDatasetAutoCompleteConfiguration = {
|
this.externalDatasetAutoCompleteConfiguration = {
|
||||||
filterFn: this.searchDatasetExternalDatasets.bind(this),
|
filterFn: this.searchDatasetExternalDatasets.bind(this),
|
||||||
|
removeAfterSelection: true,
|
||||||
initialItems: (type) => this.searchDatasetExternalDatasets('', type),//.filter(resultItem => excludedItems.map(x => x.id).indexOf(resultItem.id) === -1),
|
initialItems: (type) => this.searchDatasetExternalDatasets('', type),//.filter(resultItem => excludedItems.map(x => x.id).indexOf(resultItem.id) === -1),
|
||||||
displayFn: (item) => item ? item.label : null,
|
displayFn: (item) => item ? item.label : null,
|
||||||
titleFn: (item) => item ? item.label : null,
|
titleFn: (item) => item ? item.label : null,
|
||||||
|
@ -82,6 +84,7 @@ export class DatasetExternalReferencesEditorComponent extends BaseComponent impl
|
||||||
|
|
||||||
this.registriesAutoCompleteConfiguration = {
|
this.registriesAutoCompleteConfiguration = {
|
||||||
filterFn: this.searchDatasetExternalRegistries.bind(this),
|
filterFn: this.searchDatasetExternalRegistries.bind(this),
|
||||||
|
removeAfterSelection: true,
|
||||||
initialItems: (type) => this.searchDatasetExternalRegistries('', type),
|
initialItems: (type) => this.searchDatasetExternalRegistries('', type),
|
||||||
displayFn: (item) => item ? item.label : null,
|
displayFn: (item) => item ? item.label : null,
|
||||||
titleFn: (item) => item ? item.label: null,
|
titleFn: (item) => item ? item.label: null,
|
||||||
|
@ -90,6 +93,7 @@ export class DatasetExternalReferencesEditorComponent extends BaseComponent impl
|
||||||
|
|
||||||
this.servicesAutoCompleteConfiguration = {
|
this.servicesAutoCompleteConfiguration = {
|
||||||
filterFn: this.searchDatasetExternalServices.bind(this),
|
filterFn: this.searchDatasetExternalServices.bind(this),
|
||||||
|
removeAfterSelection: true,
|
||||||
initialItems: (type) => this.searchDatasetExternalServices('', type),
|
initialItems: (type) => this.searchDatasetExternalServices('', type),
|
||||||
displayFn: (item) => item ? item.label : null,
|
displayFn: (item) => item ? item.label : null,
|
||||||
titleFn: (item) => item ? item.label : null,
|
titleFn: (item) => item ? item.label : null,
|
||||||
|
@ -98,6 +102,7 @@ export class DatasetExternalReferencesEditorComponent extends BaseComponent impl
|
||||||
|
|
||||||
this.tagsAutoCompleteConfiguration = {
|
this.tagsAutoCompleteConfiguration = {
|
||||||
filterFn: this.searchDatasetTags.bind(this),
|
filterFn: this.searchDatasetTags.bind(this),
|
||||||
|
removeAfterSelection: true,
|
||||||
initialItems: (type) => this.searchDatasetTags('', type),
|
initialItems: (type) => this.searchDatasetTags('', type),
|
||||||
displayFn: (item) => item ? item.name : null,
|
displayFn: (item) => item ? item.name : null,
|
||||||
titleFn: (item) => item ? item.name : null,
|
titleFn: (item) => item ? item.name : null,
|
||||||
|
|
Loading…
Reference in New Issue