fix a bug where when replacing a group with one or more selected items, the other groups would not be reloaded

This commit is contained in:
rolux 2011-11-05 21:13:54 +00:00
parent fa7263fb56
commit 916606ef51
3 changed files with 16 additions and 16 deletions

View file

@ -382,7 +382,7 @@ pandora.ui.folderList = function(id) {
}); });
}, },
submit: function(data) { submit: function(data) {
data_ = {id: data.id}; var data_ = {id: data.id};
data_[data.key] = data.value; data_[data.key] = data.value;
pandora.api.editList(data_, function(result) { pandora.api.editList(data_, function(result) {
if (result.data.id != data.id) { if (result.data.id != data.id) {

View file

@ -145,13 +145,7 @@ pandora.ui.group = function(id) {
} }
} }
} }
/*
pandora.Query.updateGroups();
pandora.URL.push(pandora.Query.toString());
pandora.reloadGroups(i);
*/
pandora.UI.set('find', find); pandora.UI.set('find', find);
//pandora.URL.push();
}, },
sort: function(data) { sort: function(data) {
Ox.Log('', 'SORT', data) Ox.Log('', 'SORT', data)
@ -175,20 +169,23 @@ pandora.ui.group = function(id) {
type: 'image' type: 'image'
}) })
.bindEvent('change', function(data) { .bindEvent('change', function(data) {
var groups = Ox.clone(pandora.user.ui.groups), var find,
groups = Ox.clone(pandora.user.ui.groups),
id_ = data.selected[0].id, id_ = data.selected[0].id,
i_ = Ox.getPositionById(pandora.user.ui.groups, id_); i_ = Ox.getPositionById(pandora.user.ui.groups, id_);
if (i_ == -1) { if (i_ == -1) {
// new group was not part of old group set // new group was not part of old group set
if (pandora.user.ui._groupsState[i].selected.length) { if (pandora.user.ui._groupsState[i].selected.length) {
// if group with selection gets replaced, reload // if group with selection gets replaced, update find
pandora.user.ui.find.conditions.splice(pandora.user.ui._groupsState[i].index, 1); find = Ox.clone(pandora.user.ui.find, true);
pandora.Query.updateGroups(); find.conditions.splice(pandora.user.ui._groupsState[i].index, 1);
pandora.URL.push(pandora.Query.toString());
pandora.reloadGroups(i);
} }
groups[i] = makeGroup(id_); groups[i] = makeGroup(id_);
pandora.UI.set({groups: groups}); pandora.UI.set(Ox.extend({
groups: groups
}, find ? {
find: find
} : {}));
replaceGroup(i, id_); replaceGroup(i, id_);
// fixme: there is an obscure special case not yet covered: // fixme: there is an obscure special case not yet covered:
// switching to a new group may change find from advanced to not advanced // switching to a new group may change find from advanced to not advanced
@ -204,9 +201,8 @@ pandora.ui.group = function(id) {
replaceGroup(i, id_); replaceGroup(i, id_);
replaceGroup(i_, id); replaceGroup(i_, id);
} }
//pandora.$ui.mainMenu.replaceMenu('sortMenu', pandora.getSortMenu());
function makeGroup(id, sort) { function makeGroup(id, sort) {
// makes user.ui.groups object from site.groups object // makes user.ui._groups object from site.groups object
var group = Ox.getObjectById(pandora.site.groups, id); var group = Ox.getObjectById(pandora.site.groups, id);
return { return {
id: group.id, id: group.id,

View file

@ -29,12 +29,16 @@ pandora.ui.mainPanel = function() {
} else { } else {
pandora.$ui.list.reloadList(); pandora.$ui.list.reloadList();
} }
// FIXME: why is this being handled _here_?
pandora.user.ui._groupsState.forEach(function(data, i) { pandora.user.ui._groupsState.forEach(function(data, i) {
if (!Ox.isEqual(data.selected, previousUI._groupsState[i].selected)) { if (!Ox.isEqual(data.selected, previousUI._groupsState[i].selected)) {
pandora.$ui.groups[i].options({selected: data.selected}); pandora.$ui.groups[i].options({selected: data.selected});
} }
if (!Ox.isEqual(data.find, previousUI._groupsState[i].find)) { if (!Ox.isEqual(data.find, previousUI._groupsState[i].find)) {
Ox.print(i, 'NOT EQUAL', data.find, previousUI._groupsState[i].find)
pandora.$ui.groups[i].reloadList(); pandora.$ui.groups[i].reloadList();
} else {
Ox.print(i, 'EQUAL', data.find, previousUI._groupsState[i].find)
} }
}); });
} else { } else {