Added a user setting for the number of lists per page.
Signed-off-by: Kyle Tomita <ktomita@catalystitservices.com>
return $self->load_myopac_hold_history if $path =~ m|opac/myopac/hold_history|;
return $self->load_myopac_prefs_notify if $path =~ m|opac/myopac/prefs_notify|;
return $self->load_myopac_prefs_settings if $path =~ m|opac/myopac/prefs_settings|;
+ return $self->load_myopac_prefs_my_lists if $path =~ m|opac/myopac/prefs_my_lists|;
return $self->load_myopac_prefs if $path =~ m|opac/myopac/prefs|;
return $self->load_sms_cn if $path =~ m|opac/sms_cn|;
return $self->_load_user_with_prefs || Apache2::Const::OK;
}
+sub load_myopac_prefs_my_lists {
+ my $self = shift;
+
+ my @user_prefs = qw/
+ opac.lists_per_page
+ /;
+
+ my $stat = $self->_load_user_with_prefs;
+ return $stat if $stat;
+
+ return Apache2::Const::OK
+ unless $self->cgi->request_method eq 'POST';
+
+ # some setting values from the form don't match the
+ # required value/format for the db, so they have to be
+ # individually translated.
+
+ my %settings;
+ my $set_map = $self->ctx->{user_setting_map};
+
+ foreach my $key (@user_prefs) {
+ my $val = $self->cgi->param($key);
+ $settings{$key}= $val unless $$set_map{$key} eq $val;
+ }
+
+ # Send the modified settings off to be saved
+ $U->simplereq(
+ 'open-ils.actor',
+ 'open-ils.actor.patron.settings.update',
+ $self->editor->authtoken, undef, \%settings);
+
+ # re-fetch user prefs
+ $self->ctx->{updated_user_settings} = \%settings;
+ return $self->_load_user_with_prefs || Apache2::Const::OK;
+}
+
sub fetch_user_holds {
my $self = shift;
my $hold_ids = shift;
return 0;
}
+sub _get_lists_per_page {
+ my $self = shift;
+
+ if($self->editor->requestor) {
+ $self->timelog("Checking for opac.lists_per_page preference");
+ # See if the user has a lists per page preference
+ my $ipp = $self->editor->search_actor_user_setting({
+ usr => $self->editor->requestor->id,
+ name => 'opac.lists_per_page'
+ })->[0];
+ $self->timelog("Got opac.lists_per_page preference");
+ return OpenSRF::Utils::JSON->JSON2perl($ipp->value) if $ipp;
+ }
+ return 10; # default
+}
+
sub load_myopac_bookbags {
my $self = shift;
my $e = $self->editor;
my $ctx = $self->ctx;
- my $limit = $self->cgi->param('limit') || 10;
+ my $limit = $self->_get_lists_per_page || 10;
my $offset = $self->cgi->param('offset') || 0;
$ctx->{bookbags_limit} = $limit;
VALUES ('opac.hits_per_page', TRUE, 'Hits per Page', 'Hits per Page', 'string');
INSERT INTO config.usr_setting_type (name,opac_visible,label,description,datatype)
+ VALUES (
+ 'opac.lists_per_page',
+ TRUE,
+ oils_i18n_gettext(
+ 'opac.lists_per_page',
+ 'Lists per Page',
+ 'cust',
+ 'label'
+ ),
+ oils_i18n_gettext(
+ 'opac.lists_per_page',
+ 'A number designating the amount of lists displayed per page.',
+ 'cust',
+ 'description'
+ ),
+ 'string'
+ );
+
+INSERT INTO config.usr_setting_type (name,opac_visible,label,description,datatype)
VALUES ('opac.hold_notify', TRUE, 'Hold Notification Format', 'Hold Notification Format', 'string');
INSERT INTO config.usr_setting_type (name,opac_visible,label,description,datatype)
--- /dev/null
+-- Evergreen DB patch XXXX.add_setting_for_selecting_lists_per_page_for_my_list.sql
+--
+-- Adds a setting for selecting the number of lists per page for my list.
+--
+BEGIN;
+
+-- check whether patch can be applied
+SELECT evergreen.upgrade_deps_block_check('XXXX', :eg_version);
+
+INSERT INTO config.usr_setting_type (name,opac_visible,label,description,datatype)
+ VALUES (
+ 'opac.lists_per_page',
+ TRUE,
+ oils_i18n_gettext(
+ 'opac.lists_per_page',
+ 'Lists per Page',
+ 'cust',
+ 'label'
+ ),
+ oils_i18n_gettext(
+ 'opac.lists_per_page',
+ 'A number designating the amount of lists displayed per page.',
+ 'cust',
+ 'description'
+ ),
+ 'string'
+ );
+
+COMMIT;
<span class='float-left' style='padding-left: 10px;'>
[%- IF offset > 0 -%]
<a href='[% mkurl(ctx.opac_root _ '/myopac/lists', {
- limit => limit, offset => (offset - limit)
+ offset => (offset - limit)
}) %]'><span class="nav_arrow_fix">◄</span>[% l('Previous') %]</a>
[%- END; -%]
[%- IF (ctx.bookbag_count - offset) > limit; -%]
<a href='[% mkurl(ctx.opac_root _ '/myopac/lists', {
- limit => limit, offset => (offset + limit)
+ offset => (offset + limit)
}) %]'>[% l('Next') %]<span class="nav_arrow_fix">►</span></a>
</span>
[%- END; -%]
--- /dev/null
+[% PROCESS "opac/parts/header.tt2";
+ WRAPPER "opac/parts/myopac/prefs_base.tt2";
+ myopac_page = "prefs";
+ prefs_page = 'my_lists' %]
+
+
+ <form method='post'>
+
+ <table class="full-width data_grid" id="acct_search_main">
+ <tbody>
+
+ [% IF ctx.updated_user_settings %]
+ <tr><td colspan='2'>
+ <div class='renew-summary'>
+ [% l('Account Successfully Updated') %]
+ </div>
+ </td></tr>
+ [% END %]
+
+ [%- setting = 'opac.lists_per_page' -%]
+ <tr >
+ <td width='20%'><label for='[% setting %]'>[%l("Lists per page") %]</label></td>
+ <td>
+ <select id='[% setting %]' name='[% setting %]'>
+ [% UNLESS ctx.user_setting_map.$setting;
+ ctx.user_setting_map.$setting = 10;
+ END;
+ FOR val IN [10, 15, 20, 25] %]
+ <option value='[% val | uri %]'
+ [% IF ctx.user_setting_map.$setting == val %]
+ selected='selected'[% END %]>[% val | html %]</option>
+ [% END %]
+ </select>
+ <img alt="[% l('List Items Help') %]"
+ src="[% ctx.media_prefix %]/images/question-mark.png"
+ title="[% l('The number of lists displayed per page.') %]"
+ />
+ </td>
+ </tr>
+ </tbody>
+ </table>
+ <input type="submit" value="[% l('Save') %]" alt="[% l('Save') %]" class="opac-button"/>
+ </form>
+ [% INCLUDE "opac/parts/myopac/prefs_hints.tt2" %]
+[% END %]
\ No newline at end of file
[%- setting = 'opac.hits_per_page' -%]
<tr >
- <td width='20%'><label for='[% setting %]'>l("Search hits per page") %]</label></td>
+ <td width='20%'><label for='[% setting %]'>[% l("Search hits per page") %]</label></td>
<td>
<select id='[% setting %]' name='[% setting %]'>
[% UNLESS ctx.user_setting_map.$setting;
<div class="align">
<a href='[% mkurl('prefs_settings') %]'>[% l("Search and History Preferences") %]</a>
</div>
+ <div class="align">
+ <a href='[% mkurl('prefs_my_lists') %]'>[% l("My Lists Preferences") %]</a>
+ </div>
[% ELSIF prefs_page == 'notify' %]
<div class="align">
<a href='[% mkurl('prefs') %]'>[% l("Personal Information") %]</a>
<div class="align" >
<a href='[% mkurl('prefs_settings') %]'>[% l("Search and History Preferences") %]</a>
</div>
- [% ELSE %]
+ <div class="align">
+ <a href='[% mkurl('prefs_my_lists') %]'>[% l("My Lists Preferences") %]</a>
+ </div>
+ [% ELSIF prefs_page == 'settings' %]
<div class="align">
<a href='[% mkurl('prefs') %]'>[% l("Personal Information") %]</a>
</div>
<div class="align selected" >
<a href='#'>[% l("Search and History Preferences") %]</a>
</div>
+ <div class="align">
+ <a href='[% mkurl('prefs_my_lists') %]'>[% l("My Lists Preferences") %]</a>
+ </div>
+ [% ELSE %]
+ <div class="align">
+ <a href='[% mkurl('prefs') %]'>[% l("Personal Information") %]</a>
+ </div>
+ <div class="align">
+ <a href='[% mkurl('prefs_notify') %]'>[% l("Notification Preferences") %]</a>
+ </div>
+ <div class="align" >
+ <a href='[% mkurl('prefs_settings') %]'>[% l("Search and History Preferences") %]</a>
+ </div>
+ <div class="align selected">
+ <a href='#'>[% l("My Lists Preferences") %]</a>
+ </div>
[% END %]
</div>
</div>