Commit ff5f8f12 authored by Ryan Herbert's avatar Ryan Herbert

autocomplete.js sample_set.py pass input value to controller

implement a new filter callback in order to pass the value of the input
to the controller while maintaining a datastructure that is compatible
with the existing js code base.
Cache is stored based on the query typed into the input.
parent 611e2533
......@@ -192,6 +192,18 @@ VidjilAutoComplete.prototype = {
});
};
callbacks.filter = function(query, data, searchKey) {
var fetchData = self.fetchData.bind(self);
var isLoaded = self.isLoaded.bind(self);
var keys = [this.$inputor.val()];
if (VidjilAutoComplete.isLoading(data) || !isLoaded(keys)) {
this.$inputor.atwho('load', this.at, VidjilAutoComplete.defaultLoadingData);
fetchData(this.$inputor, this.at, keys);
return data;
}
return $.fn.atwho.default.callbacks.filter(query, data, searchKey);
};
$input.atwho({
at: at,
alias: 'samples',
......
......@@ -804,10 +804,12 @@ def auto_complete():
if "keys" not in request.vars:
return error_message("missing group ids")
query = json.loads(request.vars['keys'])
query = json.loads(request.vars['keys'])[0]
sample_types = [defs.SET_TYPE_PATIENT, defs.SET_TYPE_RUN, defs.SET_TYPE_GENERIC]
result = []
for sample_type in sample_types:
result += get_sample_set_list(sample_type, query)
return json.dumps(result)
res = {}
res[query] = result
return json.dumps(res)
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment