From b552d92b37829095cd16342b2de3cb7e2800c190 Mon Sep 17 00:00:00 2001 From: Galen Charlton Date: Mon, 17 Oct 2016 17:34:30 -0400 Subject: [PATCH] webstaff: implement some workstation preferences - Default search library - Preferred library - Advanced search pane Because AngularJS has no way of adding HTTP request headers to user interactions with the contents of an iframe, the search library and preferred library are passed to TPAC via two new session cookies, eg_pref_lib and eg_search_lib. Signed-off-by: Galen Charlton Signed-off-by: Kathy Lussier --- .../perlmods/lib/OpenILS/WWW/EGCatLoader/Util.pm | 6 ++++ .../templates/staff/admin/workstation/t_splash.tt2 | 40 ++++++++++++++++++++++ .../js/ui/default/staff/admin/workstation/app.js | 24 +++++++++++++ .../web/js/ui/default/staff/cat/catalog/app.js | 23 ++++++++++++- 4 files changed, 92 insertions(+), 1 deletion(-) diff --git a/Open-ILS/src/perlmods/lib/OpenILS/WWW/EGCatLoader/Util.pm b/Open-ILS/src/perlmods/lib/OpenILS/WWW/EGCatLoader/Util.pm index 69bb8986be..fdf51f74cd 100644 --- a/Open-ILS/src/perlmods/lib/OpenILS/WWW/EGCatLoader/Util.pm +++ b/Open-ILS/src/perlmods/lib/OpenILS/WWW/EGCatLoader/Util.pm @@ -548,6 +548,9 @@ sub _get_search_lib { if ($self->apache->headers_in->get('OILS-Search-Lib')) { return $self->apache->headers_in->get('OILS-Search-Lib'); } + if ($self->cgi->cookie('eg_search_lib')) { + return $self->cgi->cookie('eg_search_lib'); + } my $pref_lib = $self->_get_pref_lib(); return $pref_lib if $pref_lib; @@ -566,6 +569,9 @@ sub _get_pref_lib { if ($self->apache->headers_in->get('OILS-Pref-Lib')) { return $self->apache->headers_in->get('OILS-Pref-Lib'); } + if ($self->cgi->cookie('eg_pref_lib')) { + return $self->cgi->cookie('eg_pref_lib'); + } if ($ctx->{user}) { # See if the user has a search library preference diff --git a/Open-ILS/src/templates/staff/admin/workstation/t_splash.tt2 b/Open-ILS/src/templates/staff/admin/workstation/t_splash.tt2 index 8c8da45314..4e60199dc3 100644 --- a/Open-ILS/src/templates/staff/admin/workstation/t_splash.tt2 +++ b/Open-ILS/src/templates/staff/admin/workstation/t_splash.tt2 @@ -48,6 +48,46 @@
+
+ +

[% l('The default search library setting determines what library is searched from the advanced search screen and portal page by default. Manual selection of a search library will override it. One recommendation is to set the search library to the highest point you would normally want to search.') %]

+
+
+ + +
+
+ +
+
+ +

[% l('The preferred library is used to show copies and URIs regardless of the library searched. One recommendation is to set this to your workstation library so that local copies show up first in search results.') %]

+
+
+ + +
+
+ +
+
+ +

[% l('Advanced search has secondary panes for Numeric and MARC Expert searching. You can change which one is loaded by default when opening a new catalog window here.') %]

+
+
+ +
+
+ +
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 78b6d03836..750ed17fc9 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 @@ -178,6 +178,30 @@ function($scope , $window , $location , egCore , egConfirmDialog) { $scope.disable_sound = val; }); + egCore.hatch.getItem('eg.search.search_lib').then(function(val) { + $scope.search_lib = egCore.org.get(val); + }); + $scope.handle_search_lib_changed = function(org) { + egCore.hatch.setItem('eg.search.search_lib', org.id()); + }; + + egCore.hatch.getItem('eg.search.pref_lib').then(function(val) { + $scope.pref_lib = egCore.org.get(val); + }); + $scope.handle_pref_lib_changed = function(org) { + egCore.hatch.setItem('eg.search.pref_lib', org.id()); + }; + + $scope.adv_pane = 'advanced'; // default value if not explicitly set + egCore.hatch.getItem('eg.search.adv_pane').then(function(val) { + $scope.adv_pane = val; + }); + $scope.$watch('adv_pane', function(newVal, oldVal) { + if (newVal != oldVal) { + egCore.hatch.setItem('eg.search.adv_pane', newVal); + } + }); + $scope.apply_sound = function() { if ($scope.disable_sound) { egCore.hatch.setItem('eg.audio.disable', true); diff --git a/Open-ILS/web/js/ui/default/staff/cat/catalog/app.js b/Open-ILS/web/js/ui/default/staff/cat/catalog/app.js index 2272ae7c98..9423e5059f 100644 --- a/Open-ILS/web/js/ui/default/staff/cat/catalog/app.js +++ b/Open-ILS/web/js/ui/default/staff/cat/catalog/app.js @@ -247,8 +247,11 @@ function($scope , $routeParams , $location , $window , $q , egCore) { .controller('CatalogCtrl', ['$scope','$routeParams','$location','$window','$q','egCore','egHolds','egCirc','egConfirmDialog','ngToast', 'egGridDataProvider','egHoldGridActions','$timeout','$uibModal','holdingsSvc','egUser','conjoinedSvc', + '$cookies', function($scope , $routeParams , $location , $window , $q , egCore , egHolds , egCirc , egConfirmDialog , ngToast , - egGridDataProvider , egHoldGridActions , $timeout , $uibModal , holdingsSvc , egUser , conjoinedSvc) { + egGridDataProvider , egHoldGridActions , $timeout , $uibModal , holdingsSvc , egUser , conjoinedSvc, + $cookies +) { var holdingsSvcInst = new holdingsSvc(); @@ -259,6 +262,14 @@ function($scope , $routeParams , $location , $window , $q , egCore , egHolds , e if ($routeParams.record_id) $scope.from_route = true; else $scope.from_route = false; + // set search and preferred library cookies + egCore.hatch.getItem('eg.search.search_lib').then(function(val) { + $cookies.put('eg_search_lib', val, { path : '/' }); + }); + egCore.hatch.getItem('eg.search.pref_lib').then(function(val) { + $cookies.put('eg_pref_lib', val, { path : '/' }); + }); + // will hold a ref to the opac iframe $scope.opac_iframe = null; $scope.parts_iframe = null; @@ -1440,6 +1451,16 @@ function($scope , $routeParams , $location , $window , $q , egCore , egHolds , e }); } + // if we're displaying the advanced search form, select + // whatever default pane the user has chosen via workstation + // preference + if (url.match(/\/opac\/advanced$/)) { + var adv_pane = egCore.hatch.getLocalItem('eg.search.adv_pane'); + if (adv_pane) { + url += '?pane=' + encodeURIComponent(adv_pane); + } + } + $scope.catalog_url = url; } -- 2.11.0