From: Victoria Lewis Date: Wed, 19 Aug 2015 17:03:30 +0000 (-0700) Subject: Added code to set the default search library, the preferred library X-Git-Url: https://old-git.evergreen-ils.org/?a=commitdiff_plain;h=688a1102be58f81c8c1c4b5f270fe14de47bb258;p=working%2FEvergreen.git Added code to set the default search library, the preferred library and the advanced search default pane. modified: Open-ILS/src/templates/opac/parts/advanced/expert.tt2 modified: Open-ILS/src/templates/opac/parts/advanced/numeric.tt2 modified: Open-ILS/src/templates/opac/parts/advanced/search.tt2 modified: Open-ILS/src/templates/opac/parts/pref_lib_display.tt2 modified: Open-ILS/src/templates/opac/parts/searchbar.tt2 modified: Open-ILS/src/templates/opac/results.tt2 new file: Open-ILS/src/templates/staff/admin/workstation/t_search_prefs.tt2 modified: Open-ILS/web/js/ui/default/staff/admin/workstation/app.js modified: Open-ILS/web/js/ui/default/staff/cat/catalog/app.js --- 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/Search.pm b/Open-ILS/src/perlmods/lib/OpenILS/WWW/EGCatLoader/Search.pm index 19f3a258e9..ec9dfce14f 100644 --- a/Open-ILS/src/perlmods/lib/OpenILS/WWW/EGCatLoader/Search.pm +++ b/Open-ILS/src/perlmods/lib/OpenILS/WWW/EGCatLoader/Search.pm @@ -141,7 +141,8 @@ sub _prepare_biblio_search { my $pref_ou = $ctx->{pref_ou}; if (defined($pref_ou) and $pref_ou ne '' and $pref_ou != $org and ($pref_ou ne $ctx->{aou_tree}->()->id) and not $query =~ / pref_ou\(\S+\)/) { my $plib = $ctx->{get_aou}->($pref_ou)->shortname; - $query = "pref_ou($plib) $query"; + my $pref_scrubber = "pref_ou($plib) $query"; + push @naive_query_re, $pref_scrubber; } if (my $grp = $ctx->{copy_location_group}) { @@ -174,7 +175,7 @@ sub _prepare_biblio_search { push @naive_query_re, $thing; } - # This gives templates a way to take site() and depth() back out of + # This gives templates a way to take site(), pref_ou(), and depth() back out of # query strings when they shouldn't be there (because they're controllable # with other widgets). $ctx->{naive_query_scrub} = sub { 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/expert.tt2 b/Open-ILS/src/templates/opac/parts/advanced/expert.tt2 index 85e2ca2c29..489a8b0c6f 100644 --- a/Open-ILS/src/templates/opac/parts/advanced/expert.tt2 +++ b/Open-ILS/src/templates/opac/parts/advanced/expert.tt2 @@ -1,4 +1,5 @@
+
[% l("Expert Search") %]
diff --git a/Open-ILS/src/templates/opac/parts/advanced/numeric.tt2 b/Open-ILS/src/templates/opac/parts/advanced/numeric.tt2 index 4644600568..e720a58b32 100644 --- a/Open-ILS/src/templates/opac/parts/advanced/numeric.tt2 +++ b/Open-ILS/src/templates/opac/parts/advanced/numeric.tt2 @@ -1,4 +1,6 @@ + +
[% l("Numeric Search") %]
@@ -13,7 +15,6 @@ -
[%- lib_select_id="numeric_search_library" -%] diff --git a/Open-ILS/src/templates/opac/parts/advanced/search.tt2 b/Open-ILS/src/templates/opac/parts/advanced/search.tt2 index e35095b074..460d079ea8 100644 --- a/Open-ILS/src/templates/opac/parts/advanced/search.tt2 +++ b/Open-ILS/src/templates/opac/parts/advanced/search.tt2 @@ -2,6 +2,8 @@ PROCESS "opac/parts/misc_util.tt2"; PROCESS get_library; %] + + + +
+ +
diff --git a/Open-ILS/src/templates/staff/t_splash.tt2 b/Open-ILS/src/templates/staff/t_splash.tt2 index 2884ba6c0f..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') %] @@ -43,6 +50,18 @@ [% l('Copy 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 ae771ec60e..cbbabd1c06 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 @@ -31,6 +31,12 @@ angular.module('egWorkstationAdmin', controller: 'StoredPrefsCtrl', resolve : resolver }); + + $routeProvider.when('/admin/workstation/search/prefs', { + templateUrl: './admin/workstation/t_search_prefs', + controller: 'SearchPrefsCtrl', + resolve : resolver + }); // default page @@ -48,7 +54,6 @@ function($scope , $window , $location , egCore , egConfirmDialog) { var allWorkstations = []; var permMap = {}; $scope.contextOrg = egCore.org.get(egCore.auth.user().ws_ou()); - egCore.perm.hasPermAt('REGISTER_WORKSTATION', true) .then(function(orgList) { @@ -64,7 +69,7 @@ function($scope , $window , $location , egCore , egConfirmDialog) { // fetch the stored WS info egCore.hatch.getItem('eg.workstation.all') .then(function(all) { - allWorkstations = all || []; + allWorkstations = all || []; $scope.workstations = allWorkstations.map(function(w) { return w.name }); return egCore.hatch.getItem('eg.workstation.default'); @@ -172,6 +177,163 @@ function($scope , $window , $location , egCore , egConfirmDialog) { 'eg.hatch.url', $scope.hatchURL); } }]) +/* + * Search Preferences Controller + */ +.controller('SearchPrefsCtrl', + ['$scope','$window','$location', 'egCore', 'egOrg','egConfirmDialog', 'egAuth', +function($scope , $window , $location, egCore, egOrg, egConfirmDialog, egAuth) { + console.log('SearchPrefsCtrl'); + $scope.orgList = egOrg.list().map(function(org) { + return { + id : org.id(), + shortname : org.shortname(), + depth : org.ou_type().depth() + } + }); + + $scope.paneList = ['Advanced', 'Numeric', 'Expert']; + var preferredPane; + + egCore.hatch.getItem('eg.pref.lib.default') + .then(function(prefDef) { + if (prefDef == undefined) { + egCore.hatch.setItem( + 'eg.pref.lib.default', $scope.orgList[0]); + prefDef = $scope.orgList[0].shortname; + } + //This lets our dropdown auto-select our default preferred lib. + $scope.selectedPrefOrg = prefDef; + $scope.getPrefDefaultSelectedName = getSelectedName($scope.selectedPrefOrg.shortname); + }); + + egCore.hatch.getItem('eg.adv.pane.default') + .then(function(prefPane) { + if (prefPane == undefined) { + egCore.hatch.setItem( + 'eg.adv.pane.default', 'advanced'); + preferredPane = 'Advanced'; + prefPane = 'advanced'; + } + //This lets our dropdown auto-select our default pane. + switch(prefPane) { + case 'advanced': + $scope.selectedPane = 'Advanced'; + break; + case 'numeric': + $scope.selectedPane = 'Numeric'; + break; + case 'expert': + $scope.selectedPane = 'Expert' + break; + default: + $scope.selectedPane = 'Advanced'; + } + $scope.getPrefDefaultSelectedPane = getSelectedName($scope.selectedPane); + }); + + + egCore.hatch.getItem('eg.search.lib.default') + .then(function(def) { + if (def == undefined) { + egCore.hatch.setItem( + 'eg.search.lib.default', $scope.orgList[0]); + def = $scope.orgList[0].shortname; + } + //This lets our dropdown auto-select our default search lib. + $scope.selectedOrg = def; + $scope.getDefaultSelectedName = getSelectedName($scope.selectedOrg.shortname); + }); + + $scope.orgDefaultChanged = function(org) { + $scope.selectedOrg = org; + $scope.getDefaultSelectedName = $scope.selectedOrg.shortname; + if ($scope.onchange) $scope.onchange($scope.getDefaultSelectedName); + } + + $scope.prefOrgDefaultChanged = function(org) { + $scope.selectedPrefOrg = org; + $scope.getPrefDefaultSelectedName = $scope.selectedPrefOrg.shortname; + if ($scope.onchange) $scope.onchange($scope.getPrefDefaultSelectedName); + } + + $scope.prefPaneDefaultChanged = function(pane) { + $scope.selectedPane = pane; + $scope.getPrefDefaultSelectedPane = $scope.selectedPane; + if ($scope.onchange) $scope.onchange($scope.getPrefDefaultSelectedName); + } + + var getSelectedName = function(prefOrg) { + if (prefOrg) { + return prefOrg; + } else { + return $scope.orgList[0].shortname; + } + } + + $scope.setDefaultLibs = function() { + if($scope.selectedOrg.shortname){ + setDefaultSearchLib(); + } + if($scope.selectedPrefOrg.shortname ){ + setDefaultPrefLib(); + } + if($scope.selectedPane ){ + setDefaultPrefPane(); + } + } + + function setDefaultSearchLib() { + if($scope.selectedOrg){ + egCore.hatch.setItem( + 'eg.search.lib.default', ($scope.selectedOrg)) + } + } + + function setDefaultPrefLib() { + if($scope.selectedPrefOrg ) { + egCore.hatch.setItem( + 'eg.pref.lib.default', $scope.selectedPrefOrg) + } + } + + function setDefaultPrefPane() { + if($scope.selectedPane) { + switch($scope.selectedPane) { + case 'Advanced': + preferredPane = 'advanced'; + break; + case 'Numeric': + preferredPane = 'numeric'; + break; + case 'Expert': + preferredPane = 'expert'; + break; + default: + preferredPane = 'advanced'; + } + egCore.hatch.setItem( + 'eg.adv.pane.default', preferredPane) + } + } + + // --------------------- + // Hatch Configs + $scope.hatchURL = egCore.hatch.hatchURL(); + $scope.hatchRequired = + egCore.hatch.getLocalItem('eg.hatch.required'); + + $scope.updateHatchRequired = function() { + egCore.hatch.setLocalItem( + 'eg.hatch.required', $scope.hatchRequired); + } + + $scope.updateHatchURL = function() { + egCore.hatch.setLocalItem( + 'eg.hatch.url', $scope.hatchURL); + } + +}]) .controller('PrintConfigCtrl', ['$scope','egCore', 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 4cd81d71fa..85b04adbc9 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 @@ -262,6 +262,21 @@ function($scope , $routeParams , $location , $q , egCore , egHolds, if ($scope.catalog_url) return; var url = $location.absUrl().replace(/\/staff.*/, '/opac/advanced'); + var default_search_library = egCore.hatch.getLocalItem('eg.search.lib.default'); + var preferred_search_library = egCore.hatch.getLocalItem('eg.pref.lib.default'); + var default_adv_pane = egCore.hatch.getLocalItem('eg.adv.pane.default'); + + if (default_search_library.id) { + url += '?locg=' + default_search_library.id; + } + + if (preferred_search_library.id) { + url += '&plib=' + preferred_search_library.id; + } + + if (default_adv_pane) { + url += '&pane=' + default_adv_pane; + } // A record ID in the path indicates a request for the record- // specific page. diff --git a/Open-ILS/web/js/ui/default/staff/circ/in_house_use/app.js b/Open-ILS/web/js/ui/default/staff/circ/in_house_use/app.js index 06a18892e1..f58eab25ec 100644 --- a/Open-ILS/web/js/ui/default/staff/circ/in_house_use/app.js +++ b/Open-ILS/web/js/ui/default/staff/circ/in_house_use/app.js @@ -98,6 +98,7 @@ function($scope, egCore, egGridDataProvider , egConfirmDialog) { coArgs, {title : $scope.selectedNcType()} ); } + $scope.args.barcode=' '; } function performCheckout(method, args, data) {