From 916606ef51f0837ee87852958203ce869d3c5959 Mon Sep 17 00:00:00 2001 From: rolux Date: Sat, 5 Nov 2011 21:13:54 +0000 Subject: [PATCH] fix a bug where when replacing a group with one or more selected items, the other groups would not be reloaded --- static/js/pandora/folderList.js | 2 +- static/js/pandora/group.js | 26 +++++++++++--------------- static/js/pandora/mainPanel.js | 4 ++++ 3 files changed, 16 insertions(+), 16 deletions(-) diff --git a/static/js/pandora/folderList.js b/static/js/pandora/folderList.js index ab134aa5..5da6ebed 100644 --- a/static/js/pandora/folderList.js +++ b/static/js/pandora/folderList.js @@ -382,7 +382,7 @@ pandora.ui.folderList = function(id) { }); }, submit: function(data) { - data_ = {id: data.id}; + var data_ = {id: data.id}; data_[data.key] = data.value; pandora.api.editList(data_, function(result) { if (result.data.id != data.id) { diff --git a/static/js/pandora/group.js b/static/js/pandora/group.js index 831dd40c..ff800d80 100644 --- a/static/js/pandora/group.js +++ b/static/js/pandora/group.js @@ -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.URL.push(); }, sort: function(data) { Ox.Log('', 'SORT', data) @@ -175,20 +169,23 @@ pandora.ui.group = function(id) { type: 'image' }) .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, i_ = Ox.getPositionById(pandora.user.ui.groups, id_); if (i_ == -1) { // new group was not part of old group set if (pandora.user.ui._groupsState[i].selected.length) { - // if group with selection gets replaced, reload - pandora.user.ui.find.conditions.splice(pandora.user.ui._groupsState[i].index, 1); - pandora.Query.updateGroups(); - pandora.URL.push(pandora.Query.toString()); - pandora.reloadGroups(i); + // if group with selection gets replaced, update find + find = Ox.clone(pandora.user.ui.find, true); + find.conditions.splice(pandora.user.ui._groupsState[i].index, 1); } groups[i] = makeGroup(id_); - pandora.UI.set({groups: groups}); + pandora.UI.set(Ox.extend({ + groups: groups + }, find ? { + find: find + } : {})); replaceGroup(i, id_); // fixme: there is an obscure special case not yet covered: // 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); } - //pandora.$ui.mainMenu.replaceMenu('sortMenu', pandora.getSortMenu()); 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); return { id: group.id, diff --git a/static/js/pandora/mainPanel.js b/static/js/pandora/mainPanel.js index 0a415b6b..dee62f27 100644 --- a/static/js/pandora/mainPanel.js +++ b/static/js/pandora/mainPanel.js @@ -29,12 +29,16 @@ pandora.ui.mainPanel = function() { } else { pandora.$ui.list.reloadList(); } + // FIXME: why is this being handled _here_? pandora.user.ui._groupsState.forEach(function(data, i) { if (!Ox.isEqual(data.selected, previousUI._groupsState[i].selected)) { pandora.$ui.groups[i].options({selected: data.selected}); } 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(); + } else { + Ox.print(i, 'EQUAL', data.find, previousUI._groupsState[i].find) } }); } else {