From 67a2606376232fec9d2803a30f146f4176695402 Mon Sep 17 00:00:00 2001 From: Dan Scott Date: Wed, 28 Dec 2011 18:42:18 -0500 Subject: [PATCH] TPAC: Add "preferred search location" preference setting Working towards parity with the JSPAC, give the user the ability to set their preferred search library in account preferences via the org selector. The value defaults to the user's home OU. Also set a sane default of 10 search results per page in the absence of any preference, as the default had been set to 5. While we're in there, remove some of the inline styles and weird markup in the user preference page, and refactor the O:W:EGCatLoader:Account module to accept an easily-appended list of preferences to be set. Signed-off-by: Dan Scott Signed-off-by: Jason Stephenson --- .../lib/OpenILS/WWW/EGCatLoader/Account.pm | 16 +++-- .../templates/opac/myopac/prefs_settings.tt2 | 58 +++++++------------ 2 files changed, 33 insertions(+), 41 deletions(-) diff --git a/Open-ILS/src/perlmods/lib/OpenILS/WWW/EGCatLoader/Account.pm b/Open-ILS/src/perlmods/lib/OpenILS/WWW/EGCatLoader/Account.pm index 526fbfa927..116f8c5e28 100644 --- a/Open-ILS/src/perlmods/lib/OpenILS/WWW/EGCatLoader/Account.pm +++ b/Open-ILS/src/perlmods/lib/OpenILS/WWW/EGCatLoader/Account.pm @@ -297,6 +297,11 @@ sub _prepare_anonlist_sorting_query { sub load_myopac_prefs_settings { my $self = shift; + my @user_prefs = qw/ + opac.hits_per_page + opac.default_search_location + /; + my $stat = $self->_load_user_with_prefs; return $stat if $stat; @@ -310,13 +315,14 @@ sub load_myopac_prefs_settings { my %settings; my $set_map = $self->ctx->{user_setting_map}; - my $key = 'opac.hits_per_page'; - my $val = $self->cgi->param($key); - $settings{$key}= $val unless $$set_map{$key} eq $val; + foreach my $key (@user_prefs) { + my $val = $self->cgi->param($key); + $settings{$key}= $val unless $$set_map{$key} eq $val; + } my $now = DateTime->now->strftime('%F'); - for $key (qw/history.circ.retention_start history.hold.retention_start/) { - $val = $self->cgi->param($key); + foreach my $key (qw/history.circ.retention_start history.hold.retention_start/) { + my $val = $self->cgi->param($key); if($val and $val eq 'on') { # Set the start time to 'now' unless a start time already exists for the user $settings{$key} = $now unless $$set_map{$key}; diff --git a/Open-ILS/src/templates/opac/myopac/prefs_settings.tt2 b/Open-ILS/src/templates/opac/myopac/prefs_settings.tt2 index 0a117bb7a7..7cb310379e 100644 --- a/Open-ILS/src/templates/opac/myopac/prefs_settings.tt2 +++ b/Open-ILS/src/templates/opac/myopac/prefs_settings.tt2 @@ -1,4 +1,5 @@ [% PROCESS "opac/parts/header.tt2"; + PROCESS "opac/parts/org_selector.tt2"; WRAPPER "opac/parts/myopac/prefs_base.tt2"; myopac_page = "prefs_notify"; prefs_page = 'settings' %] @@ -6,15 +7,7 @@
-
-
-
- -
-
-
- - +
[% IF ctx.updated_user_settings %] @@ -28,20 +21,32 @@ + + + + @@ -71,30 +76,11 @@ - - - - - - - - - - -->
[% l("Search hits per page") %] -
-
- [% l('Search Hits Help') %] -
-
[% setting = 'opac.hits_per_page' %] + [% l('Search Hits Help') %] +
[% l("Preferred search location") %] + [%- setting = 'opac.default_search_location'; + thang = ctx.user.home_ou.id; + IF ctx.user_setting_map.$setting; + thang = ctx.user_setting_map.$setting; + END; + PROCESS build_org_selector name=setting value=thang; + %]
[% l("Default Search Location") %] -
- - [% l("Search my home library by default.") %] -
- -
[% l("Default Search Range") %] - -
+
[% INCLUDE "opac/parts/myopac/prefs_hints.tt2" %] [% END %] -- 2.43.2