From 802e4610301b4df7d751d5e365235b25889e8f46 Mon Sep 17 00:00:00 2001 From: rolux Date: Fri, 11 Nov 2011 15:48:25 +0000 Subject: [PATCH] make 'save as list' work in advanced find --- static/js/pandora/filterDialog.js | 25 +++++++++++++++++++++++++ static/js/pandora/filterForm.js | 2 +- 2 files changed, 26 insertions(+), 1 deletion(-) diff --git a/static/js/pandora/filterDialog.js b/static/js/pandora/filterDialog.js index c68e229d..c7d5cd7f 100644 --- a/static/js/pandora/filterDialog.js +++ b/static/js/pandora/filterDialog.js @@ -9,7 +9,32 @@ pandora.ui.filterDialog = function(list) { }) .bindEvent({ click: function() { + var list = pandora.$ui.filterForm.$filter.getList(); that.close(); + if (list.save) { + pandora.api.addList({ + name: list.name, + query: list.query, + status: 'private', + type: 'smart' + }, function(result) { + var $list = pandora.$ui.folderList.personal, + id = result.data.id; + pandora.UI.set({ + find: { + conditions: [{key: 'list', value: id, operator: '=='}], + operator: '&' + } + }); + Ox.Request.clearCache(); // fixme: remove + $list.reloadList().bindEventOnce({ + load: function(data) { + $list.gainFocus() + .options({selected: [id]}); + } + }); + }); + } } }) ], diff --git a/static/js/pandora/filterForm.js b/static/js/pandora/filterForm.js index 208582d8..086d8f40 100644 --- a/static/js/pandora/filterForm.js +++ b/static/js/pandora/filterForm.js @@ -14,7 +14,7 @@ pandora.ui.filterForm = function(list) { sort: [{key: 'user', operator: '+'}, {key: 'name', operator: '+'}] }, function(result) { that.append( - Ox.Filter({ + that.$filter = Ox.Filter({ findKeys: Ox.merge(Ox.map(pandora.site.itemKeys, function(itemKey) { var key = Ox.clone(itemKey); key.type = key.type == 'layer'