handle filter selection when filters are collapsed on load, fixes #776

This commit is contained in:
rolux 2012-04-24 06:15:20 +00:00
parent 6b5cc45728
commit 1dfcd9698d
3 changed files with 31 additions and 15 deletions

View file

@ -41,8 +41,16 @@ pandora.ui.browser = function() {
pandora.UI.set({showFilters: !data.collapsed});
if (!data.collapsed) {
pandora.$ui.filters.forEach(function($filter) {
if ($filter.options('_reload')) {
$filter.options({_reload: false}).reloadList();
var selected = $filter.options('_selected');
if (selected) {
$filter.bindEventOnce({
load: function() {
$filter.options({
_selected: false,
selected: selected
});
}
}).reloadList();
}
});
}

View file

@ -7,7 +7,9 @@ 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,
_selected: !pandora.user.ui.showFilters
? pandora.user.ui._filterState[i].selected
: false,
columns: [
{
align: 'left',
@ -70,7 +72,9 @@ pandora.ui.filter = function(id) {
}
},
scrollbarVisible: true,
selected: pandora.user.ui._filterState[i].selected,
selected: pandora.user.ui.showFilters
? pandora.user.ui._filterState[i].selected
: [],
sort: [{
key: pandora.user.ui.filters[i].sort[0].key,
operator: pandora.user.ui.filters[i].sort[0].operator

View file

@ -37,20 +37,24 @@ 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)) {
if (pandora.user.ui.showFilters) {
pandora.$ui.filters[i].options({selected: data.selected});
} else {
pandora.$ui.filters[i].options({_reload: true, selected: []});
}
pandora.$ui.filters[i].options(
pandora.user.ui.showFilters ? {
selected: data.selected
} : {
_selected: data.selected,
selected: []
}
);
}
if (!Ox.isEqual(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();
if (!pandora.user.ui.showFilters) {
pandora.$ui.filters[i].options({
_selected: data.selected
});
}
// we can call reloadList here, since the items function
// handles the hidden filters case without making requests
pandora.$ui.filters[i].reloadList();
}
});
} else {