in public/src/js/widgets/autocomplete.js [13:56]
constructor(opts) {
super();
this.suggestions = ko.observableArray();
this.filterType = ko.observable();
this.filterTypes = ko.observableArray(_.values(CONST.filterTypes) || []);
this.alertMessage = ko.observable(false);
this.filter = ko.observable('');
this.subscribeOn(this.filter, () => {
if (!this[preventUpdate]) {
this.type();
}
});
this[setFilter] = (suggestion) => {
// Prevent types update
this[preventUpdate] = true;
this.filter(suggestion && suggestion.id ? suggestion.id : suggestion);
this[preventUpdate] = false;
};
this.placeholder = ko.pureComputed(() => {
return (this.filterType() || {}).placeholder;
});
this.open = ko.pureComputed(() => {
return this.alertMessage() || this.suggestions().length;
});
this.paginationInProgress = ko.observable(false);
this.currentPage = ko.observable(1);
this.totalPages = ko.observable(1);
this.hasMoreSuggestions = ko.pureComputed(() => {
return this.suggestions().length > 0 && (this.currentPage() < this.totalPages());
});
this[typeBounceSym] = debounce(() => {
return autocomplete(this.state());
}, CONST.searchDebounceMs);
if (opts.parent && opts.parent.registerChild) {
opts.parent.registerChild(this);
this.listenOn(opts.parent, 'clear', () => {
this.clear();
this.emit('change', this.state());
});
}
}