From de0fae53c23c5f083d3cf0f1c1b6fe8ef094f5df Mon Sep 17 00:00:00 2001 From: rolux Date: Mon, 7 Nov 2011 18:17:46 +0000 Subject: [PATCH] fix bugs with selection of lists in featured lists browser --- static/js/pandora/folderList.js | 5 +++++ static/js/pandora/utils.js | 30 ++++++++++++++++++++---------- 2 files changed, 25 insertions(+), 10 deletions(-) diff --git a/static/js/pandora/folderList.js b/static/js/pandora/folderList.js index 738212e5c..ea941b3fd 100644 --- a/static/js/pandora/folderList.js +++ b/static/js/pandora/folderList.js @@ -364,6 +364,11 @@ pandora.ui.folderList = function(id) { }, select: function(data) { var list = data.ids.length ? data.ids[0] : ''; + if (list) { + Ox.forEach(pandora.$ui.folderList, function($list, id_) { + id != id_ && $list.options('selected', []); + }); + } pandora.UI.set({ find: { conditions: list ? [ diff --git a/static/js/pandora/utils.js b/static/js/pandora/utils.js index 64302079e..106e13f87 100644 --- a/static/js/pandora/utils.js +++ b/static/js/pandora/utils.js @@ -573,20 +573,30 @@ pandora.getItemByIdOrTitle = function(str, callback) { } pandora.getListData = function(list) { - var data = {}; + var data = {}, folder; list = Ox.isUndefined(list) ? pandora.user.ui._list : list; if (list) { Ox.forEach(pandora.$ui.folderList, function($list, id) { - var values = $list.value(list); - if (!Ox.isEmpty(values)) { - data = Ox.extend({ - editable: values.user == pandora.user.username - && values.type == 'static', - folder: id - }, values); - return false; - } + var ret = true; + // for the current list, we have to check in which + // folder it is selected, since for example, a personal + // list may appear again in the featured lists browser + if ( + list == pandora.user.ui._list + && $list.options('selected').length + ) { + folder = id; + ret = false; + } else if (!Ox.isEmpty($list.value(list))) { + folder = id + ret = false; + } }); + if (folder) { + data = pandora.$ui.folderList[folder].value(pandora.user.ui._list); + data.editable = data.user == pandora.user.username && data.type == 'static'; + data.folder = folder; + } } return data; };