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.list_items_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_items_per_page {
+ my $self = shift;
+
+ if($self->editor->requestor) {
+ $self->timelog("Checking for opac.list_items_per_page preference");
+ # See if the user has a list items per page preference
+ my $ipp = $self->editor->search_actor_user_setting({
+ usr => $self->editor->requestor->id,
+ name => 'opac.list_items_per_page'
+ })->[0];
+ $self->timelog("Got opac.list_items_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;
$ctx->{bookbags_limit} = $limit;
$ctx->{bookbags_offset} = $offset;
+ # for list item pagination
+ my $itemLimit = $self->_get_items_per_page;
+ my $itemPage = $self->cgi->param('itemPage') || 1;
+ my $itemOffset = ($itemPage - 1) * $itemLimit;
+ $ctx->{bookbags_itemPage} = $itemPage;
+
my ($sorter, $modifier) = $self->_get_bookbag_sort_params("sort");
$e->xact_begin; # replication...
$ctx->{bookbag_count} = $r->[0]->{'count'};
# If the user wants a specific bookbag's items, load them.
- # XXX add bookbag item paging support
if ($self->cgi->param("bbid")) {
my ($bookbag) =
grep { $_->id eq $self->cgi->param("bbid") } @{$ctx->{bookbags}};
if ($bookbag) {
+ # Calculate total count of the items in selected bookbag.
+ # This total includes record entries that have no assets available.
+ my $iq = {
+ 'select' => { 'acn' => [ { 'column' => 'record', 'distinct' => 'true', 'transform' => 'count', 'aggregate' => 'true', 'alias' => 'count' } ] },
+ 'from' => {'cbrebi' =>
+ { 'bre' =>
+ { 'join' =>
+ { 'acn' =>
+ { 'join' =>
+ { 'acp' =>
+ { 'join' =>
+ { 'ccs' => {}
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ },
+ 'where' => {
+ '+cbrebi' => { 'bucket' => $bookbag->id },
+ '+acn' => { 'deleted' => 'f' },
+ '+ccs' => { 'opac_visible' => 't' },
+ '+acp' => {
+ 'deleted' => 'f',
+ 'opac_visible' => 't'
+ }
+ }
+ };
+ my $ir = $e->json_query($iq);
+ $ctx->{bb_item_count} = $ir->[0]->{'count'};
+ #now add ebooks
+ my $ebook_q = {
+ 'select' => { 'cbrebi' => [ { 'column' => 'target_biblio_record_entry', 'distinct' => 'true', 'transform' => 'count', 'aggregate' => 'true', 'alias' => 'count' } ] },
+ 'from' => {'cbrebi' =>
+ { 'bre' =>
+ { 'join' =>
+ {
+ 'cbs' => {}
+ }
+ }
+ }
+ },
+ 'where' => {
+ '+cbrebi' => { 'bucket' => $bookbag->id },
+ '+bre' => {
+ 'deleted' => 'f',
+ 'active' => 't'
+ },
+ '+cbs' => { 'transcendant' => 't' }
+ }
+ };
+ my $ebook_r = $e->json_query($ebook_q);
+ $ctx->{bb_item_count} = $ctx->{bb_item_count} + $ebook_r->[0]->{'count'};
+
+ #calculate page count
+ $ctx->{bb_page_count} = int ((($ctx->{bb_item_count} - 1) / $itemLimit) + 1);
+
if ( ($self->cgi->param("action") || '') eq "editmeta") {
if (!$self->_update_bookbag_metadata($bookbag)) {
$e->rollback;
$bookbag->id, $sorter, $modifier
);
- # XXX Limiting to 1000 for now. This way you should be able to see entire
- # list contents. Need to add paging here instead.
+ # For list items pagination
my $args = {
- "limit" => 1000,
- "offset" => 0
+ "limit" => $itemLimit,
+ "offset" => $itemOffset
};
my $items = $U->bib_container_items_via_search($bookbag->id, $query, $args)
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.list_items_per_page',
+ TRUE,
+ oils_i18n_gettext(
+ 'opac.list_items_per_page',
+ 'List Items per Page',
+ 'cust',
+ 'label'
+ ),
+ oils_i18n_gettext(
+ 'opac.list_items_per_page',
+ 'A number designating the amount of list items displayed per page of a selected list.',
+ 'cust',
+ 'description'
+ ),
+ 'string'
+ );
+
-- Add groups for org_unit settings
INSERT INTO config.settings_group (name, label) VALUES
('acq', oils_i18n_gettext('config.settings_group.system', 'Acquisitions', 'coust', 'label')),
--- /dev/null
+-- Evergreen DB patch XXXX.add_setting_for_selecting_items_per_page_of_a_my_list.sql
+--
+-- Adds a setting for selecting the number of items per page of a 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.list_items_per_page',
+ TRUE,
+ oils_i18n_gettext(
+ 'opac.list_items_per_page',
+ 'List Items per Page',
+ 'cust',
+ 'label'
+ ),
+ oils_i18n_gettext(
+ 'opac.list_items_per_page',
+ 'A number designating the amount of list items displayed per page of a selected list.',
+ 'cust',
+ 'description'
+ ),
+ 'string'
+ );
+
myopac_page = "lists"
limit = ctx.bookbags_limit;
offset = ctx.bookbags_offset;
+ itemPage = ctx.bookbags_itemPage;
%]
<div id='myopac_bookbag_div' style="padding:5px;">
<div class="bookbag-controls most">
[% baseurl = ctx.opac_root _ '/myopac/lists';
IF bbag.id != CGI.param("bbid");
- url = mkurl(baseurl,{bbid => bbag.id},['edit_notes','sort']);
+ url = mkurl(baseurl,{bbid => bbag.id, itemPage => 1},['edit_notes','sort']);
ltitle = l("Show items in list");
ELSE;
url = mkurl(baseurl, {}, ['bbid', 'edit_notes', 'sort']);
[% END %]
</tbody>
</table>
+
+ [% IF ctx.bb_page_count > 1; %]
+ <div class="header_middle" style="padding-top:7px;">
+ <span class="float-left" style="padding-left:34px;">[% l('Navigate Selected List ') %]</span>
+ <span class='float-left' style='padding-left: 10px;'>
+ [%- IF itemPage > 1 -%]
+ <a href='[% mkurl(ctx.opac_root _ '/myopac/lists', {
+ itemPage => itemPage - 1
+ }) %]'><span class="nav_arrow_fix">◄</span>[% l('Previous') %]</a>
+ [%- END; -%]
+
+ [%- IF (itemPage - 3) >= 1 -%]
+ <a href='[% mkurl(ctx.opac_root _ '/myopac/lists', {
+ itemPage => itemPage - 3
+ }) %]'>[% itemPage - 3 %]</a>
+ [%- END; -%]
+ [%- IF (itemPage - 2) >= 1 -%]
+ <a href='[% mkurl(ctx.opac_root _ '/myopac/lists', {
+ itemPage => itemPage - 2
+ }) %]'>[% itemPage - 2 %]</a>
+ [%- END; -%]
+ [%- IF (itemPage - 1) >= 1 -%]
+ <a href='[% mkurl(ctx.opac_root _ '/myopac/lists', {
+ itemPage => itemPage - 1
+ }) %]'>[% itemPage - 1%]</a>
+ [%- END; -%]
+ <span style="color:red;" >[% itemPage %]</span>
+ [%- IF (itemPage + 1) <= ctx.bb_page_count -%]
+ <a href='[% mkurl(ctx.opac_root _ '/myopac/lists', {
+ itemPage => itemPage + 1
+ }) %]'>[% itemPage + 1 %]</a>
+ [%- END; -%]
+ [%- IF (itemPage + 2) <= ctx.bb_page_count -%]
+ <a href='[% mkurl(ctx.opac_root _ '/myopac/lists', {
+ itemPage => itemPage + 2
+ }) %]'>[% itemPage + 2 %]</a>
+ [%- END; -%]
+ [%- IF (itemPage + 3) <= ctx.bb_page_count -%]
+ <a href='[% mkurl(ctx.opac_root _ '/myopac/lists', {
+ itemPage => itemPage + 3
+ }) %]'>[% itemPage + 3 %]</a>
+ [%- END; -%]
+
+ [%- IF (itemPage + 1) <= ctx.bb_page_count; -%]
+ <a href='[% mkurl(ctx.opac_root _ '/myopac/lists', {
+ itemPage => itemPage + 1
+ }) %]'>[% l('Next') %]<span class="nav_arrow_fix">►</span></a>
+ [%- END; -%]
+ </span>
+ </div>
+ <div class="clear-both"></div>
+ [% END %]
+ <br/>
+
</form>
[% END %]
[% 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.list_items_per_page' -%]
+ <tr >
+ <td width='20%'><label for='[% setting %]'>[%l("List items 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, 50] %]
+ <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 list items displayed per page when viewing a selected list.') %]"
+ />
+ </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 %]
<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>