fix an error on login, logout, or load with empty find string
This commit is contained in:
parent
ba209d082e
commit
2ae3edb488
3 changed files with 19 additions and 4 deletions
|
@ -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) {
|
||||
|
|
|
@ -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();
|
||||
};
|
||||
|
|
|
@ -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);
|
||||
|
|
Loading…
Reference in a new issue