From 8c71fe6abc72720993a8448e39e82d2f782d274f Mon Sep 17 00:00:00 2001 From: Thomas Berezansky Date: Thu, 20 Sep 2012 14:33:41 -0400 Subject: [PATCH] Allow staff to pick search/pref libraries This adds a workstation-level set of settings for search and preferred libraries. These override the default search library and the preferred library individually, allowing staff to default searching at one OU but still get copy information for a different one. Original use case is "search everywhere, but show my local copies". Signed-off-by: Thomas Berezansky Signed-off-by: Jason Etheridge Signed-off-by: Ben Shum --- .../perlmods/lib/OpenILS/WWW/EGCatLoader/Util.pm | 8 ++ .../src/templates/opac/parts/pref_lib_display.tt2 | 4 +- Open-ILS/web/opac/locale/en-US/lang.dtd | 8 ++ .../staff_client/chrome/content/main/constants.js | 3 +- .../xul/staff_client/chrome/content/main/main.js | 9 +++ .../xul/staff_client/chrome/content/main/menu.js | 10 +++ .../chrome/content/main/menu_frame_menus.xul | 2 + .../chrome/content/main/search_prefs.xul | 90 ++++++++++++++++++++++ .../xul/staff_client/components/oils_protocol.js | 9 ++- 9 files changed, 138 insertions(+), 5 deletions(-) create mode 100644 Open-ILS/xul/staff_client/chrome/content/main/search_prefs.xul 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 470e381118..4dc5ea0376 100644 --- a/Open-ILS/src/perlmods/lib/OpenILS/WWW/EGCatLoader/Util.pm +++ b/Open-ILS/src/perlmods/lib/OpenILS/WWW/EGCatLoader/Util.pm @@ -378,6 +378,10 @@ sub _get_search_lib { $loc = $self->cgi->param('loc'); return $loc if $loc; + if ($self->apache->headers_in->get('OILS-Search-Lib')) { + return $self->apache->headers_in->get('OILS-Search-Lib'); + } + my $pref_lib = $self->_get_pref_lib(); return $pref_lib if $pref_lib; @@ -392,6 +396,10 @@ sub _get_pref_lib { my $plib = $self->cgi->param('plib'); return $plib if $plib; + if ($self->apache->headers_in->get('OILS-Pref-Lib')) { + return $self->apache->headers_in->get('OILS-Pref-Lib'); + } + if ($ctx->{user}) { # See if the user has a search library preference my $lset = $self->editor->search_actor_user_setting({ 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 635c766658..d8c9856416 100644 --- a/Open-ILS/src/templates/opac/parts/pref_lib_display.tt2 +++ b/Open-ILS/src/templates/opac/parts/pref_lib_display.tt2 @@ -1,7 +1,7 @@ [%- IF ctx.pref_ou && ctx.pref_ou != ctx.search_ou; %] [% l('Preferred library: [_1][_2][_3]', '', ctx.get_aou(ctx.pref_ou).name, ''); - %][% l('?') %] + IF NOT ctx.is_staff %][% l('?') %][% END; %] [%- END; %] diff --git a/Open-ILS/web/opac/locale/en-US/lang.dtd b/Open-ILS/web/opac/locale/en-US/lang.dtd index 055f2e3028..ce9e816bb6 100644 --- a/Open-ILS/web/opac/locale/en-US/lang.dtd +++ b/Open-ILS/web/opac/locale/en-US/lang.dtd @@ -874,6 +874,7 @@ + @@ -3633,3 +3634,10 @@ + + + + + + + diff --git a/Open-ILS/xul/staff_client/chrome/content/main/constants.js b/Open-ILS/xul/staff_client/chrome/content/main/constants.js index d3eb6e2534..8ec44a8fe3 100644 --- a/Open-ILS/xul/staff_client/chrome/content/main/constants.js +++ b/Open-ILS/xul/staff_client/chrome/content/main/constants.js @@ -522,7 +522,8 @@ var urls = { 'ALT_HOLDS_PRINT' : 'oils://remote/opac/extras/circ/alt_holds_print.html', 'SERIAL_PRINT_ROUTING_LIST_USERS' : 'oils://remote/eg/serial/print_routing_list_users', 'XUL_SERIAL_BATCH_RECEIVE': 'oils://remote/xul/server/serial/batch_receive.xul', - 'EG_TRIGGER_EVENTS' : 'oils://remote/eg/actor/user/event_log' + 'EG_TRIGGER_EVENTS' : 'oils://remote/eg/actor/user/event_log', + 'XUL_SEARCH_PREFS' : 'chrome://open_ils_staff_client/content/main/search_prefs.xul' } if(use_tpac) { diff --git a/Open-ILS/xul/staff_client/chrome/content/main/main.js b/Open-ILS/xul/staff_client/chrome/content/main/main.js index c131bbe594..53d8b875c8 100644 --- a/Open-ILS/xul/staff_client/chrome/content/main/main.js +++ b/Open-ILS/xul/staff_client/chrome/content/main/main.js @@ -376,6 +376,15 @@ function main_init() { var url = G.auth.controller.view.server_prompt.value.match(/^[^\/]*/).toString() || urls.remote; G.data.server_unadorned = url; G.data.stash('server_unadorned'); G.data.stash_retrieve(); + try { + G.data.search_lib = G.pref.getIntPref('open-ils.' + url + '.search_lib'); + G.data.pref_lib = G.pref.getIntPref('open-ils.' + url + '.pref_lib'); + } catch(E) { + G.data.search_lib = null; + G.data.pref_lib = null; + } + G.data.stash('search_lib'); + G.data.stash('pref_lib'); if (! url.match( '^(http|https)://' ) ) { url = 'http://' + url; } diff --git a/Open-ILS/xul/staff_client/chrome/content/main/menu.js b/Open-ILS/xul/staff_client/chrome/content/main/menu.js index 55a36826ce..32149183a5 100644 --- a/Open-ILS/xul/staff_client/chrome/content/main/menu.js +++ b/Open-ILS/xul/staff_client/chrome/content/main/menu.js @@ -1664,6 +1664,16 @@ main.menu.prototype = { xulG.pref.setBoolPref('oils.copy_editor.copy_location_name_first', !curvalue); } ], + 'cmd_search_prefs' : [ + ['oncommand'], + function() { + try { + obj.set_tab(obj.url_prefix('XUL_SEARCH_PREFS')); + } catch(E) { + alert(E) + } + } + ], }; JSAN.use('util.controller'); diff --git a/Open-ILS/xul/staff_client/chrome/content/main/menu_frame_menus.xul b/Open-ILS/xul/staff_client/chrome/content/main/menu_frame_menus.xul index 70128a9e7d..58caf07fc3 100644 --- a/Open-ILS/xul/staff_client/chrome/content/main/menu_frame_menus.xul +++ b/Open-ILS/xul/staff_client/chrome/content/main/menu_frame_menus.xul @@ -282,6 +282,7 @@ perm="DEBUG_CLIENT" /> + @@ -448,6 +449,7 @@ + diff --git a/Open-ILS/xul/staff_client/chrome/content/main/search_prefs.xul b/Open-ILS/xul/staff_client/chrome/content/main/search_prefs.xul new file mode 100644 index 0000000000..c36c7eb20c --- /dev/null +++ b/Open-ILS/xul/staff_client/chrome/content/main/search_prefs.xul @@ -0,0 +1,90 @@ + + + + + + + + + + + + + + + + + + + + + + + &staff.search_prefs.search_lib.description; + + + + + + + + &staff.search_prefs.pref_lib.description; + + + + + +