-import {onChildEvent} from '../services/dom';
+import {onChildEvent} from '../services/dom.ts';
import {Component} from './component';
/**
* @property entityTypes string
* @property entityPermission string
* @property searchEndpoint string
+ * @property initialValue string
*/
/**
entityTypes: this.$opts.entityTypes || 'page,book,chapter',
entityPermission: this.$opts.entityPermission || 'view',
searchEndpoint: this.$opts.searchEndpoint || '',
+ initialValue: this.searchInput.value || '',
};
this.search = '';
configureSearchOptions(options) {
Object.assign(this.searchOptions, options);
this.reset();
+ this.searchInput.value = this.searchOptions.initialValue;
}
setupListeners() {
this.searchInput.focus();
}
- searchText(queryText) {
- this.searchInput.value = queryText;
- this.searchEntities(queryText);
- }
-
showLoading() {
this.loading.style.display = 'block';
this.resultsContainer.style.display = 'none';
throw new Error('Search endpoint not set for entity-selector load');
}
+ if (this.searchOptions.initialValue) {
+ this.searchEntities(this.searchOptions.initialValue);
+ return;
+ }
+
window.$http.get(this.searchUrl()).then(resp => {
this.resultsContainer.innerHTML = resp.data;
this.hideLoading();