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 <david@davidnind.com>

Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl>
Signed-off-by: Katrin Fischer <katrin.fischer@bsz-bw.de>
This commit is contained in:
Owen Leonard 2025-02-12 19:50:26 +00:00 committed by Katrin Fischer
parent 41a368f35e
commit 168d282e94
No known key found for this signature in database
GPG Key ID: 0EF6E2C03357A834
1 changed files with 7 additions and 5 deletions

View File

@ -942,7 +942,7 @@
<tbody>
[% FOREACH ar IN current_article_requests %]
<tr>
<tr id="article_[% ar.id | html %]">
<td class="article-request-record-title">
[% 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));
}
});
}