From b640c3372a451c16ba7b6a0b01545f17b1d81439 Mon Sep 17 00:00:00 2001 From: Victoria Lewis Date: Tue, 6 Oct 2015 13:06:46 -0700 Subject: [PATCH] LP 1437112 Added set preferred default library in web client. Preparing to switch to demo branch. --- .../src/perlmods/lib/OpenILS/WWW/EGCatLoader.pm | 1 + .../perlmods/lib/OpenILS/WWW/EGCatLoader/Util.pm | 11 ++++++- .../src/templates/opac/parts/advanced/search.tt2 | 3 ++ .../src/templates/opac/parts/pref_lib_display.tt2 | 6 ++-- .../templates/staff/admin/workstation/index.tt2 | 1 + .../staff/admin/workstation/t_search_prefs.tt2 | 12 ++++---- Open-ILS/src/templates/staff/t_splash.tt2 | 7 +++++ .../js/ui/default/staff/admin/workstation/app.js | 35 ++++++++++++++++++++-- .../web/js/ui/default/staff/cat/catalog/app.js | 6 ++++ 9 files changed, 69 insertions(+), 13 deletions(-) diff --git a/Open-ILS/src/perlmods/lib/OpenILS/WWW/EGCatLoader.pm b/Open-ILS/src/perlmods/lib/OpenILS/WWW/EGCatLoader.pm index b1527fb87d..d366e6ac42 100644 --- a/Open-ILS/src/perlmods/lib/OpenILS/WWW/EGCatLoader.pm +++ b/Open-ILS/src/perlmods/lib/OpenILS/WWW/EGCatLoader.pm @@ -321,6 +321,7 @@ sub load_common { $self->load_search_filter_groups($ctx->{search_ou}); $self->load_org_util_funcs; $self->load_perm_funcs; + $self->_get_pref_lib; return Apache2::Const::OK; } 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..021071a255 100644 --- a/Open-ILS/src/perlmods/lib/OpenILS/WWW/EGCatLoader/Util.pm +++ b/Open-ILS/src/perlmods/lib/OpenILS/WWW/EGCatLoader/Util.pm @@ -9,6 +9,8 @@ use OpenILS::Utils::CStoreEditor qw/:funcs/; use OpenILS::Utils::Fieldmapper; use OpenILS::Application::AppUtils; use OpenSRF::MultiSession; +use CGI qw/:standard/; +use CGI::Cookie; my $U = 'OpenILS::Application::AppUtils'; @@ -559,9 +561,16 @@ sub _get_pref_lib { my $self = shift; my $ctx = $self->ctx; + if( $ctx->{is_staff}) { # plib param takes precedence - my $plib = $self->cgi->param('plib'); + # my $plib = $self->cgi->param('plib'); #replaced url 'plib' with cookie 'pplib' + my $plib = $self->cgi->cookie('pplib'); + my $pref_clump = $plib; + my ($org, $grp) = split(/:/, $pref_clump); + $ctx->{pref_lib_org} = $self->_resolve_org_id_or_shortname($org); + $ctx->{pref_ou} = $ctx->{pref_lib_org}; return $plib if $plib; + } if ($self->apache->headers_in->get('OILS-Pref-Lib')) { return $self->apache->headers_in->get('OILS-Pref-Lib'); diff --git a/Open-ILS/src/templates/opac/parts/advanced/search.tt2 b/Open-ILS/src/templates/opac/parts/advanced/search.tt2 index e35095b074..1bc79fc411 100644 --- a/Open-ILS/src/templates/opac/parts/advanced/search.tt2 +++ b/Open-ILS/src/templates/opac/parts/advanced/search.tt2 @@ -61,6 +61,9 @@ class='hidden'[% END %]>
+ + [% IF adv_chunk.adv_special; SWITCH adv_chunk.adv_special; diff --git a/Open-ILS/src/templates/opac/parts/pref_lib_display.tt2 b/Open-ILS/src/templates/opac/parts/pref_lib_display.tt2 index 9fe7d9cecf..7c3aa616b9 100644 --- a/Open-ILS/src/templates/opac/parts/pref_lib_display.tt2 +++ b/Open-ILS/src/templates/opac/parts/pref_lib_display.tt2 @@ -1,6 +1,6 @@ -[%- IF ctx.pref_ou && ctx.pref_ou != ctx.search_ou; %] -[% - l('Preferred library: [_1]', '' _ ctx.get_aou(ctx.pref_ou).name _ ''); +[%- IF ctx.pref_ou && ctx.pref_ou != ctx.search_ou; ctx.pref_ou = CGI.cookie('pplib')%] + [% + l('Preferred library: [_1]','' _ ctx.get_aou(ctx.pref_ou).name _ ''); IF NOT ctx.is_staff %][% l('?') %][% END; %] diff --git a/Open-ILS/src/templates/staff/admin/workstation/index.tt2 b/Open-ILS/src/templates/staff/admin/workstation/index.tt2 index 0512483109..46ed053ea7 100644 --- a/Open-ILS/src/templates/staff/admin/workstation/index.tt2 +++ b/Open-ILS/src/templates/staff/admin/workstation/index.tt2 @@ -15,6 +15,7 @@ angular.module('egCoreMod').run(['egStrings', function(s) { '[% l('Delete content for key "[_1]"?', '{{deleteKey}}') %]'; s.DEFAULT_WS_LABEL = '[% l('[_1] (Default)', '{{ws}}') %]'; s.DEFAULT_ORG_LABEL = '[% l( '[_1] {{org}}') %]'; + s.DEFAULT_PREF_ORG_LABEL = '[% l( '[_1] {{org}}') %]'; s.WS_EXISTS = '[% l("Workstation name already exists. Use it anyway?") %]'; }]); diff --git a/Open-ILS/src/templates/staff/admin/workstation/t_search_prefs.tt2 b/Open-ILS/src/templates/staff/admin/workstation/t_search_prefs.tt2 index cde8e6811b..5b1c12a433 100644 --- a/Open-ILS/src/templates/staff/admin/workstation/t_search_prefs.tt2 +++ b/Open-ILS/src/templates/staff/admin/workstation/t_search_prefs.tt2 @@ -41,8 +41,7 @@ - - @@ -54,10 +53,10 @@ copies show up first in search results.

- +
@@ -78,7 +77,6 @@
- diff --git a/Open-ILS/src/templates/staff/t_splash.tt2 b/Open-ILS/src/templates/staff/t_splash.tt2 index 970d0983f0..d517105f4a 100644 --- a/Open-ILS/src/templates/staff/t_splash.tt2 +++ b/Open-ILS/src/templates/staff/t_splash.tt2 @@ -35,6 +35,13 @@
[% l('Item Search and Cataloging') %]
+
+
+ + +
+
[% l('Record Buckets') %] 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 34142519b9..5b38f1979f 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 @@ -192,6 +192,22 @@ function($scope , $window , $location, egCore, egOrg, egConfirmDialog, egAuth) { } }); + egCore.hatch.getItem('eg.pref.lib.default') + .then(function(def) { + if (def == undefined) { + egCore.hatch.setItem( + 'eg.pref.lib.default', $scope.orgList[0]); + def = $scope.orgList[0].shortname; + } + //This lets our dropdown auto-select our default preferred lib. + $scope.selectedPrefOrg = def; + angular.forEach($scope.orgList, function(val, key) { + if(JSON.stringify(def.shortname) == JSON.stringify(val.shortname)){ + $scope.selectedPrefOrg = val.shortname; + } + }); + }); + egCore.hatch.getItem('eg.search.lib.default') .then(function(def) { if (def == undefined) { @@ -213,12 +229,28 @@ function($scope , $window , $location, egCore, egOrg, egConfirmDialog, egAuth) { egCore.strings.$replace(egCore.strings.DEFAULT_ORG_LABEL, {org:org}) :org; } - $scope.setDefaultSearchLib = function() { + $scope.getPrefOrgLabel = function(org) { + return org == $scope.defaultPrefLib? + egCore.strings.$replace(egCore.strings.DEFAULT_PREF_ORG_LABEL, {pref:org}) :org; + } + + $scope.setDefaultLibs = function() { + setDefaultSearchLib(); + setDefaultPrefLib(); + } + + function setDefaultSearchLib() { egCore.hatch.setItem( 'eg.search.lib.default', JSON.parse($scope.selectedOrg)) .then(function() { $scope.defaultSearchLib = $scope.selectedOrg }); } + function setDefaultPrefLib() { + egCore.hatch.setItem( + 'eg.pref.lib.default', JSON.parse($scope.selectedPrefOrg)) + .then(function() { $scope.defaultPrefLib = $scope.selectedPrefOrg }); + } + // --------------------- // Hatch Configs $scope.hatchURL = egCore.hatch.hatchURL(); @@ -235,7 +267,6 @@ function($scope , $window , $location, egCore, egOrg, egConfirmDialog, egAuth) { 'eg.hatch.url', $scope.hatchURL); } - }]) .controller('PrintConfigCtrl', 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 6593210851..0f356b55bf 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 @@ -263,10 +263,16 @@ function($scope , $routeParams , $location , $q , egCore , egHolds, var default_search_library = egCore.hatch.getLocalItem('eg.search.lib.default'); var url = $location.absUrl().replace(/\/staff.*/, '/opac/advanced'); + var preferred_search_library = egCore.hatch.getLocalItem('eg.pref.lib.default'); if (default_search_library.id) { url += '?locg=' + default_search_library.id; } + + if (preferred_search_library.id) { + url += '&plib=' + preferred_search_library.id; + } + // A record ID in the path indicates a request for the record- // specific page. if ($routeParams.record_id) { -- 2.11.0