From d9e3f8d8a934bb99edaab78f1c105653309dd27a Mon Sep 17 00:00:00 2001 From: Tomas Cohen Arazi Date: Thu, 23 Sep 2021 08:52:50 -0300 Subject: [PATCH] Bug 29083: Fix OPAC listing of article requests This patch makes the OPAC template reuse a precalculated value for the active article requests for the patron (and its count). The original code relied on the methods returning a list, which is not the case for _new_from_dbic until bug 28883 is pushed. This patch fixes that. Note: there was an odd behavior when ArticleRequests was enabled but no active article requests were present: the tab wasn't rendered but the 'empty table' with the 'You have no article requests currently.' message was displayed below the Checkouts tab. I'm not sure that was caused by this patches, or other. Fixed on this patch. To test: 1. In the OPAC, go to 'your summary' => FAIL: Things don't show for article requests 2. Add some article requests and repeat 1 => FAIL: Something's wrong there 3. Apply this patch and repeat 1 => Yes! Things show correctly! 4. Cancel all your article requests => SUCCESS: Things render as they should 5. Re-enter the 'your summary' page (to force re-rendering) => SUCCESS: Things render correctly for empty article requests 6. Sign off :-D Signed-off-by: Tomas Cohen Arazi Signed-off-by: Martin Renvoize Signed-off-by: Nick Clemens --- koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-user.tt | 8 ++++---- opac/opac-user.pl | 7 +++++++ 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-user.tt b/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-user.tt index bc97a5c2ab..a50609d9cc 100644 --- a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-user.tt +++ b/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-user.tt @@ -217,7 +217,7 @@ [% END %] [% IF ( RESERVES.count ) %]
  • Holds ([% RESERVES.count | html %])
  • [% END %] - [% IF Koha.Preference('ArticleRequests') && logged_in_user.article_requests_current %]
  • Article requests ([% logged_in_user.article_requests_current.count | html %])
  • [% END %] + [% IF Koha.Preference('ArticleRequests') %]
  • Article requests ([% current_article_requests_count || 0 | html %])
  • [% END %] [% IF ( OverDriveCirculation ) %]
  • OverDrive Account
  • [% END %] @@ -714,7 +714,7 @@ [% IF Koha.Preference('ArticleRequests') %]
    - [% IF logged_in_user.article_requests_current.count %] + [% IF current_article_requests_count %] @@ -737,7 +737,7 @@ - [% FOREACH ar IN logged_in_user.article_requests_current %] + [% FOREACH ar IN current_article_requests %]
    Article requests
    [% INCLUDE 'biblio-title.inc' biblio=ar.biblio %] @@ -853,7 +853,7 @@ } } $(document).ready(function(){ - $('#opac-user-article-requests caption .count').html(AR_CAPTION_COUNT.format('[% logged_in_user.article_requests_current.count | html %]')); + $('#opac-user-article-requests caption .count').html(AR_CAPTION_COUNT.format('[% current_article_requests_count | html %]')); $('#opac-user-views').tabs(); $(".modal-nojs").addClass("modal").addClass("hide").removeClass("modal-nojs"); $(".suspend-until").prop("readonly",1); diff --git a/opac/opac-user.pl b/opac/opac-user.pl index 8deb054e72..1cd97b628e 100755 --- a/opac/opac-user.pl +++ b/opac/opac-user.pl @@ -386,6 +386,13 @@ if ( C4::Context->preference('AllowPatronToSetFinesVisibilityForGuarantor') $template->param( relatives_with_fines => \@relatives_with_fines ); } +if ( C4::Context->preference("ArticleRequests") ) { + my @current_article_requests = $patron->article_requests_current->as_list; + $template->param( + current_article_requests => \@current_article_requests, + current_article_requests_count => scalar @current_article_requests, + ); +} $template->param( patron_messages => $patron_messages, -- 2.20.1