From 2ae3edb4888aa494c8b7739a304eec35c4994197 Mon Sep 17 00:00:00 2001 From: rolux Date: Wed, 24 Aug 2011 16:42:55 +0000 Subject: [PATCH] fix an error on login, logout, or load with empty find string --- static/js/pandora/Query.js | 7 +++++-- static/js/pandora/pandora.js | 2 ++ static/js/pandora/ui/group.js | 14 ++++++++++++-- 3 files changed, 19 insertions(+), 4 deletions(-) diff --git a/static/js/pandora/Query.js b/static/js/pandora/Query.js index 986327058..be894d0fe 100644 --- a/static/js/pandora/Query.js +++ b/static/js/pandora/Query.js @@ -93,7 +93,7 @@ pandora.Query = (function() { index, indices, ret = { find: {index: -1, key: '', value: ''}, - groups: [], + groups: [], // {index, query, selected} list: '', query: {conditions: [], operator: ''} }, @@ -131,7 +131,6 @@ pandora.Query = (function() { ret.list = ret.query.conditions[index].value; } } - ret.groups = getGroupsData(ret.query); // find is populated if exactly one condition in an & query // has a findKey as key and "" as operator // (and all other conditions are either list or groups) @@ -145,11 +144,13 @@ pandora.Query = (function() { } }); } else { + // number of conditions that are not list or groups conditions = ret.query.conditions.length - (ret.list != '') - ret.groups.filter(function(group) { return group.index > -1; }).length; + // indices of non-advanced find queries indices = Ox.map(pandora.site.findKeys, function(findKey) { var key = findKey.id == 'all' ? '' : findKey.id, index = oneCondition(ret.query.conditions, key, ''); @@ -167,6 +168,7 @@ pandora.Query = (function() { } } } + ret.groups = getGroupsData(ret.query); return ret; } @@ -222,6 +224,7 @@ pandora.Query = (function() { pandora.UI.set({list: data.list}); pandora.user.ui.find = data.find; pandora.user.ui.groupsData = data.groups; + Ox.print("PUUGD", pandora.user.ui.groupsData); pandora.user.ui.query = data.query; } if ('sort' in query) { diff --git a/static/js/pandora/pandora.js b/static/js/pandora/pandora.js index e19f330ec..2e407e949 100644 --- a/static/js/pandora/pandora.js +++ b/static/js/pandora/pandora.js @@ -104,12 +104,14 @@ pandora.getVideoPartsAndPoints = function(durations, points) { pandora.login = function(data) { pandora.user = data.user; + pandora.Query.updateGroups(); Ox.Theme(pandora.user.ui.theme); pandora.$ui.appPanel.reload(); }; pandora.logout = function(data) { pandora.user = data.user; + pandora.Query.updateGroups(); Ox.Theme(pandora.site.user.ui.theme); pandora.$ui.appPanel.reload(); }; diff --git a/static/js/pandora/ui/group.js b/static/js/pandora/ui/group.js index cfb87eca1..b78f19eb8 100644 --- a/static/js/pandora/ui/group.js +++ b/static/js/pandora/ui/group.js @@ -58,15 +58,25 @@ pandora.ui.group = function(id) { }), index = pandora.user.ui.groupsData[i].index; if (Ox.isArray(index)) { + // this group had multiple selections and the | query + // was on the top level, i.e. not bracketed pandora.user.ui.query = { conditions: conditions, operator: conditions.length > 1 ? '|' : '' } } else { if (index == -1) { + // this group had no selection, i.e. no query index = pandora.user.ui.query.conditions.length; - pandora.user.ui.query.operator = index ? '&' : ''; - Ox.print('$$$$$$$$$$$$$$$$$$$', index, pandora.user.ui.query.operator) + if (pandora.user.ui.query.operator == '|') { + pandora.user.ui.query = { + conditions: [pandora.user.ui.query], + operator: '&' + }; + index = 1; + } else { + pandora.user.ui.query.operator = index ? '&' : ''; + } } if (conditions.length == 0) { pandora.user.ui.query.conditions.splice(index, 1);