From d378b130f07bda5a33ddf6701e49d0f16e6fc2dc Mon Sep 17 00:00:00 2001 From: rolux Date: Mon, 7 Nov 2011 19:09:20 +0000 Subject: [PATCH] honor capabilities when constructing find select (no filename if not staff or admin); fix a bug where after app panel reload, a non-existing menu would still be bound to all keyboard events --- static/js/pandora/findElement.js | 8 +++++--- static/js/pandora/siteDialog.js | 4 ++-- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/static/js/pandora/findElement.js b/static/js/pandora/findElement.js index ec58b97c..4986c57f 100644 --- a/static/js/pandora/findElement.js +++ b/static/js/pandora/findElement.js @@ -26,12 +26,14 @@ pandora.ui.findElement = function() { pandora.$ui.findSelect = Ox.Select({ id: 'select', items: Ox.merge( - pandora.site.findKeys.map(function(key, i) { - return { + Ox.map(pandora.site.findKeys, function(key, i) { + return !key.capability + || pandora.site.capabilities[key.capability][pandora.user.level] + ? { id: key.id, title: 'Find: ' + key.title, checked: findKey == key.id - }; + } : null; }), [{}, { id: 'advanced', diff --git a/static/js/pandora/siteDialog.js b/static/js/pandora/siteDialog.js index 018c2de4..af0db18b 100644 --- a/static/js/pandora/siteDialog.js +++ b/static/js/pandora/siteDialog.js @@ -64,10 +64,10 @@ pandora.ui.siteDialog = function(section) { $dialog.options({ title: Ox.getObjectById(tabs, data.selected).title }); - pandora.URL.replace('/' + data.selected); + //pandora.URL.replace('/' + data.selected); //fixme: this should be using URL.push / UI.set //but that currenlty causes another dialog to be opened - //history.pushState({}, '', '/' + data.selected); + history.pushState({}, '', '/' + data.selected); } }); var $dialog = Ox.Dialog({