Added a user setting for the number of lists per page.
Added code for page number navigation.
Signed-off-by: Kyle Tomita <ktomita@catalystitservices.com>
Signed-off-by: Dan Wells <dbw2@calvin.edu>
my $self = shift;
my @user_prefs = qw/
+ opac.lists_per_page
opac.list_items_per_page
/;
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 _get_items_per_page {
my $self = shift;
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;
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.list_items_per_page',
TRUE,
oils_i18n_gettext(
--- /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 (offset - (limit * 3)) >= 0 -%]
+ <a href='[% mkurl(ctx.opac_root _ '/myopac/lists', {
+ offset => (offset - (limit * 3))
+ }) %]'>[% ((offset - (limit * 3)) / limit) + 1 %]</a>
+ [%- END; -%]
+ [%- IF (offset - (limit * 2)) >= 0 -%]
+ <a href='[% mkurl(ctx.opac_root _ '/myopac/lists', {
+ offset => (offset - (limit * 2))
+ }) %]'>[% ((offset - (limit * 2)) / limit) + 1 %]</a>
+ [%- END; -%]
+ [%- IF (offset - limit) >= 0 -%]
+ <a href='[% mkurl(ctx.opac_root _ '/myopac/lists', {
+ offset => (offset - limit)
+ }) %]'>[% ((offset - limit) / limit) + 1 %]</a>
+ [%- END; -%]
+ <span style="color:red;" >[% (offset / limit) + 1 %]</span>
+ [%- IF (offset + limit) <= ctx.bookbag_count -%]
+ <a href='[% mkurl(ctx.opac_root _ '/myopac/lists', {
+ offset => (offset + limit)
+ }) %]'>[% ((offset + limit) / limit) + 1 %]</a>
+ [%- END; -%]
+ [%- IF (offset + (limit * 2)) <= ctx.bookbag_count -%]
+ <a href='[% mkurl(ctx.opac_root _ '/myopac/lists', {
+ offset => (offset + (limit * 2))
+ }) %]'>[% ((offset + (limit * 2)) / limit) + 1 %]</a>
+ [%- END; -%]
+ [%- IF (offset + (limit * 3)) <= ctx.bookbag_count -%]
+ <a href='[% mkurl(ctx.opac_root _ '/myopac/lists', {
+ offset => (offset + (limit * 3))
+ }) %]'>[% ((offset + (limit * 3)) / limit) + 1 %]</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; -%]
</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>
[%- setting = 'opac.list_items_per_page' -%]
<tr >
<td width='20%'><label for='[% setting %]'>[%l("List items per page") %]</label></td>