Support autocomplete from a group of layers
The idea here is to have several layers which share a set of tags. This mirrors what we already have if several layers reference the same type of entity. You might have config like this: { "id": "keywords", "title": "Keywords", "canAddAnnotations": {"member": true, "staff": true, "admin": true}, "item": "Keyword", "overlap": true, "type": "string", "autocomplete": true, "autocompleteKeys": ["keywords", "minorkeywords"] }, { "id": "minorkeywords", "title": "Minor Keywords", "canAddAnnotations": {"member": true, "staff": true, "admin": true}, "item": "Keyword", "overlap": true, "type": "string", "autocomplete": true, "autocompleteKeys": ["keywords", "minorkeywords"] }, Now, adding new keywords in either bin will offer autocompletions from the union of the two layers. The other option would be to do this on the server side, but I thought this was a less invasive way to achieve this.
This commit is contained in:
parent
4f064fda76
commit
8f3b3036df
1 changed files with 19 additions and 7 deletions
|
@ -55,13 +55,25 @@ pandora.ui.editor = function(data) {
|
||||||
})
|
})
|
||||||
} : layer.autocomplete
|
} : layer.autocomplete
|
||||||
? function(key, value, callback) {
|
? function(key, value, callback) {
|
||||||
|
var keys = layer.autocompleteKeys && layer.autocompleteKeys.length
|
||||||
|
? layer.autocompleteKeys
|
||||||
|
: [key];
|
||||||
|
var n = keys.length;
|
||||||
|
var itemss = [];
|
||||||
|
|
||||||
|
keys.forEach(function(key) {
|
||||||
pandora.api.autocomplete({
|
pandora.api.autocomplete({
|
||||||
key: key,
|
key: key,
|
||||||
operator: '=',
|
operator: '=',
|
||||||
range: [0, 20],
|
range: [0, 20],
|
||||||
value: value
|
value: value
|
||||||
}, function(result) {
|
}, function(result) {
|
||||||
callback(result.data.items);
|
n--;
|
||||||
|
itemss.push(result.data.items);
|
||||||
|
if (n == 0) {
|
||||||
|
callback(Ox.unique(Ox.flatten(itemss)));
|
||||||
|
}
|
||||||
|
});
|
||||||
});
|
});
|
||||||
} : null
|
} : null
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in a new issue