Bug 36347: Avoid return claims table being loaded twice
authorJulian Maurice <julian.maurice@biblibre.com>
Mon, 18 Mar 2024 15:07:02 +0000 (16:07 +0100)
committerFridolin Somers <fridolin.somers@biblibre.com>
Thu, 23 May 2024 08:45:02 +0000 (10:45 +0200)
commit4183ec10c0ecab8f9c6d0bf1f2360cef3be30ff7
tree5e5cd80c3c32e238a0f89540ff46b8fcb14e27c1
parentf353bd8d969800c0320b13510fce27d0583d9fab
Bug 36347: Avoid return claims table being loaded twice

The issue is caused by these lines in circulation.js:

$("#finesholdsissues a[data-toggle='tab']").on("shown.bs.tab", function(e){
    $(this).click();
});

When the user clicks on a hidden tab, 'shown.bs.tab' is triggered and
then another click event is triggered. And because the table was loaded
on tab click, it was loaded twice.
Visually it could have caused the rows to be duplicated (it was random,
probably due to timing, network latency, ...)

I don't know why we need to trigger a click in this case, but removing
this will probably break something else, so the fix here is to load the
table on 'shown.bs.tab' event instead of 'click'

This patch also contains a small fix in refreshReturnClaimsTable which
was reloading the table right after the table initialization.

Test plan:
1. Check out an item, and in the checkouts table, click "Claim returned"
2. Open the network tab of your browser's developer tools
3. Click on the "Claims" tab, verify that only one call is made to
   svc/return_claims
4. Verify that the claims table is displayed correctly

Signed-off-by: David Nind <david@davidnind.com>
Signed-off-by: Lucas Gass <lucas@bywatersolutions.com>
Signed-off-by: Katrin Fischer <katrin.fischer@bsz-bw.de>
(cherry picked from commit 5783d01af00a5bf21527c81a05252d99a2a14e9a)
Signed-off-by: Fridolin Somers <fridolin.somers@biblibre.com>
koha-tmpl/intranet-tmpl/prog/js/checkouts.js