diff --git a/static/js/pandora/filterDialog.js b/static/js/pandora/filterDialog.js index c68e229d9..c7d5cd7fc 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 208582d87..086d8f403 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'