From f6eb26fa807c3ad5f0c01f1271313daca98efc0f Mon Sep 17 00:00:00 2001 From: Galen Charlton Date: Tue, 8 Sep 2015 16:07:36 +0000 Subject: [PATCH] webstaff: implement saving default Z39.50 targets Also make the target password input field's type be "password". Signed-off-by: Galen Charlton Signed-off-by: Jason Stephenson --- Open-ILS/src/templates/staff/cat/z3950/t_list.tt2 | 7 +++++- .../src/templates/staff/cat/z3950/t_target.tt2 | 2 +- .../web/js/ui/default/staff/cat/services/z3950.js | 29 +++++++++++++++++++--- Open-ILS/web/js/ui/default/staff/cat/z3950/app.js | 4 +++ 4 files changed, 36 insertions(+), 6 deletions(-) diff --git a/Open-ILS/src/templates/staff/cat/z3950/t_list.tt2 b/Open-ILS/src/templates/staff/cat/z3950/t_list.tt2 index 86292c9784..5e2ab8beee 100644 --- a/Open-ILS/src/templates/staff/cat/z3950/t_list.tt2 +++ b/Open-ILS/src/templates/staff/cat/z3950/t_list.tt2 @@ -20,7 +20,12 @@
[% l('Service and Credentials') %] - + +
+ +
diff --git a/Open-ILS/src/templates/staff/cat/z3950/t_target.tt2 b/Open-ILS/src/templates/staff/cat/z3950/t_target.tt2 index 9365ec225b..17ca47588e 100644 --- a/Open-ILS/src/templates/staff/cat/z3950/t_target.tt2 +++ b/Open-ILS/src/templates/staff/cat/z3950/t_target.tt2 @@ -11,7 +11,7 @@
- +
diff --git a/Open-ILS/web/js/ui/default/staff/cat/services/z3950.js b/Open-ILS/web/js/ui/default/staff/cat/services/z3950.js index 45969be1c6..9e4b8ffcdd 100644 --- a/Open-ILS/web/js/ui/default/staff/cat/services/z3950.js +++ b/Open-ILS/web/js/ui/default/staff/cat/services/z3950.js @@ -10,6 +10,7 @@ function($q, egCore, egAuth) { }; service.loadTargets = function() { + var default_targets = egCore.hatch.getLocalItem('eg.cat.z3950.default_targets'); egCore.net.request( 'open-ils.search', 'open-ils.search.z3950.retrieve_services', @@ -21,13 +22,18 @@ function($q, egCore, egAuth) { var localTarget = res['native-evergreen-catalog']; delete res['native-evergreen-catalog']; angular.forEach(res, function(value, key) { - this.push({ + var tgt = { code: key, settings: value, - selected: false, + selected: (key in default_targets), username: '', password: '' - }); + }; + if (tgt.code in default_targets && tgt.settings.auth == 't') { + tgt['username'] = default_targets[tgt.code]['username'] || ''; + tgt['password'] = default_targets[tgt.code]['password'] || ''; + } + this.push(tgt); }, service.targets); service.targets.sort(function (a, b) { a = a.settings.label; @@ -37,7 +43,7 @@ function($q, egCore, egAuth) { service.targets.unshift({ code: 'native-evergreen-catalog', settings: localTarget, - selected: false, + selected: ('native-evergreen-catalog' in default_targets), username: '', password: '' }); @@ -119,6 +125,21 @@ function($q, egCore, egAuth) { service.raw_search = raw_search; } + // store selected targets + service.saveDefaultZ3950Targets = function() { + var saved_targets = {}; + angular.forEach(service.targets, function(target, idx) { + if (target.selected) { + saved_targets[target.code] = {}; + } + if (target.settings.auth == 't') { + saved_targets[target.code]['username'] = target.username; + saved_targets[target.code]['password'] = target.password; + } + }); + egCore.hatch.setLocalItem('eg.cat.z3950.default_targets', saved_targets); + } + return service; }]) .directive("egZ3950TargetList", function () { diff --git a/Open-ILS/web/js/ui/default/staff/cat/z3950/app.js b/Open-ILS/web/js/ui/default/staff/cat/z3950/app.js index 5476c71339..3d8d9d13f3 100644 --- a/Open-ILS/web/js/ui/default/staff/cat/z3950/app.js +++ b/Open-ILS/web/js/ui/default/staff/cat/z3950/app.js @@ -131,6 +131,10 @@ function($scope , $q , $location , $timeout , $window, egCore , egGridDataProvi egZ3950TargetSvc.clearSearchFields(); }; + $scope.saveDefaultZ3950Targets = function() { + egZ3950TargetSvc.saveDefaultZ3950Targets(); + } + var display_form = true; $scope.show_search_form = function() { return display_form; -- 2.11.0