From 6d4fb74a0d5d13bbbf24406f80295447eaf62ca5 Mon Sep 17 00:00:00 2001 From: rolux Date: Wed, 27 Feb 2013 17:06:54 +0530 Subject: [PATCH] placesDialog: fix getMatches function --- static/js/pandora/placesDialog.js | 23 +++++++++++++---------- 1 file changed, 13 insertions(+), 10 deletions(-) diff --git a/static/js/pandora/placesDialog.js b/static/js/pandora/placesDialog.js index 3faff657..29b1586a 100644 --- a/static/js/pandora/placesDialog.js +++ b/static/js/pandora/placesDialog.js @@ -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], - operator = Ox.getObjectById( - pandora.site.layers, key - ).type == 'place' ? '==' : '='; + }); + 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);