forked from 0x2620/pandora
don't make filter requests (a total of 15) when filters are collapsed
This commit is contained in:
parent
778c98625a
commit
ad7b21fbef
3 changed files with 24 additions and 9 deletions
|
@ -39,6 +39,13 @@ pandora.ui.browser = function() {
|
|||
toggle: function(data) {
|
||||
data.collapsed && pandora.$ui.list.gainFocus();
|
||||
pandora.UI.set({showFilters: !data.collapsed});
|
||||
if (!data.collapsed) {
|
||||
pandora.$ui.filters.forEach(function($filter) {
|
||||
if ($filter.options('_reload')) {
|
||||
$filter.options({_reload: false}).reloadList();
|
||||
}
|
||||
});
|
||||
}
|
||||
if (pandora.user.ui.listView == 'map') {
|
||||
pandora.$ui.map.resizeMap();
|
||||
} else if (pandora.user.ui.listView == 'calendar') {
|
||||
|
|
|
@ -7,6 +7,7 @@ pandora.ui.filter = function(id) {
|
|||
title = Ox.getObjectById(pandora.site.filters, id).title,
|
||||
//width = pandora.getFilterWidth(i, panelWidth),
|
||||
that = Ox.TextList({
|
||||
_reload: !pandora.user.ui.showFilters,
|
||||
columns: [
|
||||
{
|
||||
align: 'left',
|
||||
|
@ -58,15 +59,15 @@ pandora.ui.filter = function(id) {
|
|||
columnsVisible: true,
|
||||
id: 'filter_' + id,
|
||||
items: function(data, callback) {
|
||||
//if (pandora.user.ui.showFilters) {
|
||||
if (pandora.user.ui.showFilters) {
|
||||
delete data.keys;
|
||||
return pandora.api.find(Ox.extend(data, {
|
||||
group: id,
|
||||
query: pandora.user.ui._filterState[i].find
|
||||
}), callback);
|
||||
//} else {
|
||||
// callback({data: {items: data.keys ? [] : 0}});
|
||||
//}
|
||||
} else {
|
||||
callback({data: {items: data.keys ? [] : 0}});
|
||||
}
|
||||
},
|
||||
scrollbarVisible: true,
|
||||
selected: pandora.user.ui._filterState[i].selected,
|
||||
|
|
|
@ -36,13 +36,20 @@ pandora.ui.mainPanel = function() {
|
|||
// FIXME: why is this being handled _here_?
|
||||
pandora.user.ui._filterState.forEach(function(data, i) {
|
||||
if (!Ox.isEqual(data.selected, previousUI._filterState[i].selected)) {
|
||||
pandora.$ui.filters[i].options({selected: data.selected});
|
||||
if (pandora.user.ui.showFilters) {
|
||||
pandora.$ui.filters[i].options({selected: data.selected});
|
||||
} else {
|
||||
pandora.$ui.filters[i].options({_reload: true, selected: []});
|
||||
}
|
||||
}
|
||||
if (!Ox.isEqual(data.find, previousUI._filterState[i].find)) {
|
||||
Ox.Log('FIND', 'NOT EQUAL', data.find, previousUI._filterState[i].find)
|
||||
pandora.$ui.filters[i].reloadList();
|
||||
} else {
|
||||
Ox.Log('FIND', 'EQUAL', data.find, previousUI._filterState[i].find)
|
||||
if (pandora.user.ui.showFilters) {
|
||||
pandora.$ui.filters[i].reloadList();
|
||||
} else {
|
||||
// we can call reloadList here, since the items function
|
||||
// handles the hidden filters case without making requests
|
||||
pandora.$ui.filters[i].options({_reload: true}).reloadList();
|
||||
}
|
||||
}
|
||||
});
|
||||
} else {
|
||||
|
|
Loading…
Reference in a new issue