From 878352617f917f92c0472d18a11745c0cb80bf2f Mon Sep 17 00:00:00 2001 From: rolux Date: Mon, 19 Sep 2011 13:18:02 +0000 Subject: [PATCH] make smart list query editable --- static/js/pandora/ui/filter.js | 24 +++++++++++++++++++++++- static/js/pandora/ui/listDialog.js | 2 +- 2 files changed, 24 insertions(+), 2 deletions(-) diff --git a/static/js/pandora/ui/filter.js b/static/js/pandora/ui/filter.js index 03e62ee70..6bfb802ad 100644 --- a/static/js/pandora/ui/filter.js +++ b/static/js/pandora/ui/filter.js @@ -21,7 +21,29 @@ pandora.ui.filter = function(list) { sortKeys: pandora.site.sortKeys, viewKeys: pandora.site.listViews }) - .css({padding: '16px'}); + .css({padding: '16px'}) + .bindEvent({ + change: function(data) { + if (list) { + pandora.api.editList({ + id: list.id, + query: data.query + }, function(result) { + Ox.Request.clearCache(); // fixme: remove later + pandora.$ui.list + .bindEventOnce({ + init: function(data) { + Ox.print('NUMBER OF ITEMS:', data.items); + pandora.$ui.folderList[ + pandora.getListData().folder + ].value(list.id, 'items', data.items); + } + }) + .reloadList(); + }); + } + } + }); return that; }; diff --git a/static/js/pandora/ui/listDialog.js b/static/js/pandora/ui/listDialog.js index e42994e52..e556e8349 100644 --- a/static/js/pandora/ui/listDialog.js +++ b/static/js/pandora/ui/listDialog.js @@ -17,7 +17,7 @@ pandora.ui.listDialog = function(list, section) { } else if (id == 'icon') { return pandora.ui.listIconPanel(list); } else if (id == 'query') { - return pandora.$ui.filter = pandora.ui.filter(); + return pandora.$ui.filter = pandora.ui.filter(list); } }, tabs: tabs