From e47caa19c3446daf52c6ffc03b6ce009a8a1a38d Mon Sep 17 00:00:00 2001 From: Owen Leonard Date: Wed, 12 Feb 2025 19:50:26 +0000 Subject: [PATCH] Bug 39095: Fix problems with article request deletion This patch fixes a number of issues with article request deletion in the OPAC: - Cancel button should work when initially hidden by DataTables' responsive behavior. - Table row hiding upon deletion should work when DataTables' responsive behavior has created a secondary row to display the hidden columns. - Tab and table caption article count should correctly update when a request is canceled. To test, apply the patch and enable ArticleRequests if necessary. If enabling ArticleRequests for the first time you may need to update your circulation rules to allow article requests on some patrons or item types. - Log in to the OPAC and place several article requests. - Go to your user summary page and open the article requests tab. - Narrow your browser window until at least the last column is hidden by DataTables. - Click the "+" button to show the hidden details, which should include the cancel button. - Click the cancel button. After confirming the deletion the original row should be hidden along with the row shown by DataTables. - The article request count in the article requests tab should now be updated to reflect the new number of requests. - The same should be true of the article requests table heading. Sponsored-by: Athens County Public Libraries Signed-off-by: David Nind --- .../opac-tmpl/bootstrap/en/modules/opac-user.tt | 12 +++++++----- 1 file changed, 7 insertions(+), 5 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 438878a6f1..42c49a2403 100644 --- a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-user.tt +++ b/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-user.tt @@ -942,7 +942,7 @@ [% FOREACH ar IN current_article_requests %] - + [% INCLUDE 'biblio-title.inc' biblio=ar.biblio link=> 1 %] [% ar.item.enumchron | html %] @@ -1095,7 +1095,7 @@ [% IF ( opac_user_article_requests ) %] $("#opac-user-views a[href='#opac-user-article-requests_panel']").tab("show"); [% END %] - $('#opac-user-article-requests caption .count').html(AR_CAPTION_COUNT.format('[% current_article_requests.size | html %]')); + $('#article-requests-table caption .count').html(AR_CAPTION_COUNT.format('[% current_article_requests.size | html %]')); $(".modal-nojs").addClass("modal").addClass("hide").removeClass("modal-nojs"); @@ -1123,7 +1123,7 @@ ); }); - $(".btn-delete-article-request").on("click", function(e){ + $("#article-requests-table").on("click", ".btn-delete-article-request", function(e){ e.preventDefault(); var article_request = $(this).data("title"); var article_request_id = $(this).data("article-request_id"); @@ -1134,16 +1134,18 @@ type: "DELETE", url: '/api/v1/public/patrons/'+borrowernumber+'/article_requests/'+article_request_id+'?cancellation_reason=OPAC', success: function( data ) { - row.parents('tr').hide({ + $("#article_" + article_request_id ).hide({ duration: 'slow', complete: function() { - var ar_tab = $('a[href="#opac-user-article-requests"'); + $(this).siblings(".child").hide(); + var ar_tab = $('a[href="#opac-user-article-requests_panel"'); var ar_table = $('#article-requests-table'); var ar_length = $('tbody tr:visible', ar_table).length; var ar_count = $('caption .count', ar_table); ar_tab.html(ar_tab.html().replace(/\(\d+\)/, '('+ar_length+')')); ar_count.html(AR_CAPTION_COUNT.format(ar_length)); + } }); } -- 2.39.5