forked from 0x2620/pandora
placesDialog: fix getMatches function
This commit is contained in:
parent
8a6235b2b5
commit
6d4fb74a0d
1 changed files with 13 additions and 10 deletions
|
@ -22,24 +22,27 @@ pandora.ui.placesDialog = function(options) {
|
|||
getMatches: function(names, callback) {
|
||||
// fixme: the results of this are of course
|
||||
// not identical to actual place matches
|
||||
var key, operator;
|
||||
var conditions = [], keys, operator;
|
||||
if (names.length == 0) {
|
||||
callback(0);
|
||||
} else {
|
||||
key = pandora.site.layers.filter(function(layer) {
|
||||
keys = pandora.site.layers.filter(function(layer) {
|
||||
return layer.type == 'place' || layer.hasPlaces;
|
||||
}).map(function(layer) {
|
||||
return layer.id;
|
||||
})[0],
|
||||
});
|
||||
keys.forEach(function(key) {
|
||||
operator = Ox.getObjectById(
|
||||
pandora.site.layers, key
|
||||
).type == 'place' ? '==' : '=';
|
||||
names.forEach(function(name) {
|
||||
conditions.push({key: key, value: name, operator: operator});
|
||||
});
|
||||
});
|
||||
pandora.api.findClips({
|
||||
query: {
|
||||
conditions: names.map(function(name) {
|
||||
return {key: key, value: name, operator: operator};
|
||||
}),
|
||||
operator: names.length == 1 ? '&' : '|'
|
||||
conditions: conditions,
|
||||
operator: conditions.length == 1 ? '&' : '|'
|
||||
}
|
||||
}, function(result) {
|
||||
callback(result.data.items);
|
||||
|
|
Loading…
Reference in a new issue