From 9c3abc84c8a4bcb1301bd592c4aae1939623e37f Mon Sep 17 00:00:00 2001 From: j <0x006A@0x2620.org> Date: Tue, 7 Jan 2014 15:54:20 +0000 Subject: [PATCH] only show documents for current item --- static/js/documentsPanel.js | 49 ++++++++++++++++++++++++------------- 1 file changed, 32 insertions(+), 17 deletions(-) diff --git a/static/js/documentsPanel.js b/static/js/documentsPanel.js index 30a1fbe29..d3a5f58e2 100644 --- a/static/js/documentsPanel.js +++ b/static/js/documentsPanel.js @@ -386,8 +386,6 @@ pandora.ui.documentsPanel = function(options) { selectDocuments ); - selectDocuments(); - function addDocuments() { pandora.$ui.documentsDialog = pandora.ui.documentsDialog().open(); } @@ -407,6 +405,7 @@ pandora.ui.documentsPanel = function(options) { } function editDocuments() { + pandora.UI.set('documentSelection.', $list.options('selected')); pandora.$ui.documentsDialog = pandora.ui.documentsDialog().open(); } @@ -567,7 +566,10 @@ pandora.ui.documentsPanel = function(options) { var options = { items: pandora.api.findDocuments, keys: ['dimensions', 'extension', 'id', 'name', 'ratio', 'size'], - query: {conditions: [], operator: '&'}, + query: { + conditions: isItemView ? [{ key: 'item', value: ui.item }] : [], + operator: '&' + }, selected: ui.documentsSelection[isItemView ? ui.item : ''], sort: ui.documentsSort.concat([ {key: 'extension', operator: '+'}, @@ -622,6 +624,11 @@ pandora.ui.documentsPanel = function(options) { sort: function(data) { pandora.UI.set({documentsSort: [data]}); } + }) + .bindEventOnce({ + load: function() { + selectDocuments(); + } }); } @@ -690,20 +697,28 @@ pandora.ui.documentsPanel = function(options) { var key = $findSelect.value(), value = $findInput.value(), query = { - conditions: value - ? [].concat( - key != 'user' - ? [{key: 'name', value: value, operator: '='}] - : [], - key == 'all' - ? [{key: 'description', value: value, operator: '='}] - : [], - key != 'name' - ? [{key: 'user', value: value, operator: '='}] - : [] - ) + conditions: [].concat( + isItemView + ? [{ key: 'item', value: ui.item }] : [], - operator: '|' + value + ? { + conditions: [].concat( + key != 'user' + ? [{key: 'name', value: value, operator: '='}] + : [], + key == 'all' + ? [{key: 'description', value: value, operator: '='}] + : [], + key != 'name' + ? [{key: 'user', value: value, operator: '='}] + : [] + ), + operator: '|' + } + : [] + ), + operator: '&' }; $list.options({query: query}); } @@ -732,4 +747,4 @@ pandora.ui.documentsPanel = function(options) { return that; -} \ No newline at end of file +}