From eb647e5354db7d76f7fec3c75b0493913fc93466 Mon Sep 17 00:00:00 2001 From: Kyle Tomita Date: Wed, 3 Apr 2013 17:07:51 -0700 Subject: [PATCH] LP1164197 - Add page number navigation to my lists and setting for number of lists per page Added a user setting for the number of lists per page. Added code for page number navigation. Signed-off-by: Kyle Tomita Signed-off-by: Dan Wells --- .../lib/OpenILS/WWW/EGCatLoader/Account.pm | 19 +++++++++- Open-ILS/src/sql/Pg/950.data.seed-values.sql | 19 ++++++++++ ...r_selecting_lists_per_page_for_my_list.sql | 29 +++++++++++++++ Open-ILS/src/templates/opac/myopac/lists.tt2 | 35 +++++++++++++++++-- .../templates/opac/myopac/prefs_my_lists.tt2 | 20 +++++++++++ 5 files changed, 119 insertions(+), 3 deletions(-) create mode 100644 Open-ILS/src/sql/Pg/upgrade/XXXX.add_setting_for_selecting_lists_per_page_for_my_list.sql 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 6acb39e709..c9d53ae1fb 100644 --- a/Open-ILS/src/perlmods/lib/OpenILS/WWW/EGCatLoader/Account.pm +++ b/Open-ILS/src/perlmods/lib/OpenILS/WWW/EGCatLoader/Account.pm @@ -470,6 +470,7 @@ sub load_myopac_prefs_my_lists { my $self = shift; my @user_prefs = qw/ + opac.lists_per_page opac.list_items_per_page /; @@ -1737,6 +1738,22 @@ sub _update_bookbag_metadata { 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; @@ -1757,7 +1774,7 @@ 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; diff --git a/Open-ILS/src/sql/Pg/950.data.seed-values.sql b/Open-ILS/src/sql/Pg/950.data.seed-values.sql index 77cdf76c52..328ce33ea0 100644 --- a/Open-ILS/src/sql/Pg/950.data.seed-values.sql +++ b/Open-ILS/src/sql/Pg/950.data.seed-values.sql @@ -2556,6 +2556,25 @@ INSERT INTO config.usr_setting_type (name,opac_visible,label,description,datatyp oils_i18n_gettext('opac.default_pickup_location', 'Default location for holds pickup', 'cust', 'description'), 'integer'); +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', diff --git a/Open-ILS/src/sql/Pg/upgrade/XXXX.add_setting_for_selecting_lists_per_page_for_my_list.sql b/Open-ILS/src/sql/Pg/upgrade/XXXX.add_setting_for_selecting_lists_per_page_for_my_list.sql new file mode 100644 index 0000000000..3af2a1210e --- /dev/null +++ b/Open-ILS/src/sql/Pg/upgrade/XXXX.add_setting_for_selecting_lists_per_page_for_my_list.sql @@ -0,0 +1,29 @@ +-- 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; diff --git a/Open-ILS/src/templates/opac/myopac/lists.tt2 b/Open-ILS/src/templates/opac/myopac/lists.tt2 index 3be190f656..22b3bd9313 100644 --- a/Open-ILS/src/templates/opac/myopac/lists.tt2 +++ b/Open-ILS/src/templates/opac/myopac/lists.tt2 @@ -68,12 +68,43 @@ [%- IF offset > 0 -%] limit, offset => (offset - limit) + offset => (offset - limit) }) %]'>[% l('Previous') %] [%- END; -%] + [%- IF (offset - (limit * 3)) >= 0 -%] + (offset - (limit * 3)) + }) %]'>[% ((offset - (limit * 3)) / limit) + 1 %] + [%- END; -%] + [%- IF (offset - (limit * 2)) >= 0 -%] + (offset - (limit * 2)) + }) %]'>[% ((offset - (limit * 2)) / limit) + 1 %] + [%- END; -%] + [%- IF (offset - limit) >= 0 -%] + (offset - limit) + }) %]'>[% ((offset - limit) / limit) + 1 %] + [%- END; -%] + [% (offset / limit) + 1 %] + [%- IF (offset + limit) <= ctx.bookbag_count -%] + (offset + limit) + }) %]'>[% ((offset + limit) / limit) + 1 %] + [%- END; -%] + [%- IF (offset + (limit * 2)) <= ctx.bookbag_count -%] + (offset + (limit * 2)) + }) %]'>[% ((offset + (limit * 2)) / limit) + 1 %] + [%- END; -%] + [%- IF (offset + (limit * 3)) <= ctx.bookbag_count -%] + (offset + (limit * 3)) + }) %]'>[% ((offset + (limit * 3)) / limit) + 1 %] + [%- END; -%] [%- IF (ctx.bookbag_count - offset) > limit; -%] limit, offset => (offset + limit) + offset => (offset + limit) }) %]'>[% l('Next') %] [%- END; -%] diff --git a/Open-ILS/src/templates/opac/myopac/prefs_my_lists.tt2 b/Open-ILS/src/templates/opac/myopac/prefs_my_lists.tt2 index 746df98074..69106a43c0 100644 --- a/Open-ILS/src/templates/opac/myopac/prefs_my_lists.tt2 +++ b/Open-ILS/src/templates/opac/myopac/prefs_my_lists.tt2 @@ -17,6 +17,26 @@ [% END %] + [%- setting = 'opac.lists_per_page' -%] + + + + + [% l('List Items Help') %] + + [%- setting = 'opac.list_items_per_page' -%] -- 2.43.2