From 3d63b2bd22316ee720c116f67439aa8fc0079645 Mon Sep 17 00:00:00 2001 From: Bill Erickson Date: Fri, 25 Apr 2014 10:52:35 -0400 Subject: [PATCH] browser staff : prefs page shows local and remote prefs Signed-off-by: Bill Erickson --- .../staff/admin/workstation/t_stored_prefs.tt2 | 54 ++++++++++++-------- .../js/ui/default/staff/admin/workstation/app.js | 58 +++++++++++++--------- 2 files changed, 67 insertions(+), 45 deletions(-) diff --git a/Open-ILS/src/templates/staff/admin/workstation/t_stored_prefs.tt2 b/Open-ILS/src/templates/staff/admin/workstation/t_stored_prefs.tt2 index 0efa9cff3b..dc031b44bb 100644 --- a/Open-ILS/src/templates/staff/admin/workstation/t_stored_prefs.tt2 +++ b/Open-ILS/src/templates/staff/admin/workstation/t_stored_prefs.tt2 @@ -22,32 +22,44 @@ Click on the delete (X) button to remove a preference's value.
- -
-
-
{{$index + 1}}.
-
- {{key}} -
-
- -
-
- -
-
+ + +
+
+ +
+
{{$index + 1}}.
+
+ {{key}} +
+
+ +
+
+ +
+
+ +
+
-
{{getCurrentKeyContent()}}
-
+
diff --git a/Open-ILS/web/js/ui/default/staff/admin/workstation/app.js b/Open-ILS/web/js/ui/default/staff/admin/workstation/app.js index 54c4821d65..743c9af803 100644 --- a/Open-ILS/web/js/ui/default/staff/admin/workstation/app.js +++ b/Open-ILS/web/js/ui/default/staff/admin/workstation/app.js @@ -168,38 +168,49 @@ function($scope , egPrintStore) { }]) .controller('StoredPrefsCtrl', - ['$scope','egUser','egPrintStore','egConfirmDialog','egAppStrings', -function($scope , egUser , egPrintStore , egConfirmDialog , egAppStrings) { + ['$scope','egUser','egPrintStore','egConfirmDialog','egAppStrings','$q', +function($scope , egUser , egPrintStore , egConfirmDialog , egAppStrings , $q) { console.log('StoredPrefsCtrl'); + $scope.setContext = function(ctx) { + $scope.context = ctx; + } + $scope.setContext('local'); + + // grab the edit perm $scope.userHasDeletePerm = false; egUser.hasPermHere('DELETE_WORKSTATION_PREFS') .then(function(bool) { $scope.userHasDeletePerm = bool }); + // fetch the keys + function refreshKeys() { - egPrintStore.getKeys() - .then(function(keys) { $scope.keys = keys.sort() }) + $scope.keys = {local : [], remote : []}; + + egPrintStore.getRemoteKeys().then( + function(keys) { $scope.keys.remote = keys.sort() }) + + // local calls are non-async + $scope.keys.local = egPrintStore.getLocalKeys(); } refreshKeys(); $scope.selectKey = function(key) { $scope.currentKey = key; $scope.currentKeyContent = null; - egPrintStore.getItem(key) - .then(function(content) { - $scope.currentKeyContent = content - }); + + if ($scope.context == 'local') { + $scope.currentKeyContent = egPrintStore.getLocalItem(key); + } else { + egPrintStore.getRemoteItem(key) + .then(function(content) { + $scope.currentKeyContent = content + }); + } } $scope.getCurrentKeyContent = function() { - try { - // if the content is JSON-encoded (most), re-stringify - // with the pretty printer. - return JSON.stringify($scope.currentKeyContent, null, 2); - } catch(E) { - // otherwise, return the bare value - return $scope.currentKeyContent; - } + return JSON.stringify($scope.currentKeyContent, null, 2); } $scope.removeKey = function(key) { @@ -207,17 +218,16 @@ function($scope , egUser , egPrintStore , egConfirmDialog , egAppStrings) { egAppStrings.PREFS_REMOVE_KEY_CONFIRM, '', { deleteKey : key, ok : function() { - egPrintStore.removeItem(key) - .then(function() { - // delete succeeded, remove item from list - $scope.keys = $scope.keys.filter( - function(k) { return k != key } - ); - }); + if ($scope.context == 'local') { + egPrintStore.removeLocalItem(key); + refreshKeys(); + } else { + egPrintStore.removeItem(key) + .then(function() { refreshKeys() }); + } }, cancel : function() {} // user canceled, nothing to do } ); } }]) - -- 2.11.0