From 475a784da55200eba89dd48aaf256c85a1676942 Mon Sep 17 00:00:00 2001 From: j Date: Tue, 13 Nov 2018 15:29:15 +0000 Subject: [PATCH] use autocomplete in filter form --- static/js/filterForm.js | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/static/js/filterForm.js b/static/js/filterForm.js index 7d145473..483b82c8 100644 --- a/static/js/filterForm.js +++ b/static/js/filterForm.js @@ -29,6 +29,7 @@ pandora.ui.filterForm = function(options) { if (key.format && key.format.type == 'ColorPercent') { key.format.type = 'percent'; } + key.autocomplete = autocompleteFunction(key) return key; }).concat([{ id: 'list', @@ -70,6 +71,24 @@ pandora.ui.filterForm = function(options) { that.getList = that.$filter.getList; that.value = that.$filter.value; }); + function autocompleteFunction(key) { + return key.autocomplete ? function(value, callback) { + pandora.api.autocomplete({ + key: key.id, + query: { + conditions: [], + operator: '&' + }, + range: [0, 100], + sort: key.autocompleteSort, + value: value + }, function(result) { + callback(result.data.items.map(function(item) { + return Ox.decodeHTMLEntities(item); + })); + }); + } : null; + } that.updateResults = function() { if (mode == 'list') { Ox.Request.clearCache(list.id);