Bug 39888 - Error on acquisitions home when no budgets are defined
Summary: Error on acquisitions home when no budgets are defined
Status: Pushed to main
Alias: None
Product: Koha
Classification: Unclassified
Component: Acquisitions (show other bugs)
Version: unspecified
Hardware: All All
: P5 - low normal
Assignee: Martin Renvoize (ashimema)
QA Contact: Jonathan Druart
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2025-05-13 10:39 UTC by Martin Renvoize (ashimema)
Modified: 2025-05-13 11:04 UTC (History)
0 users

See Also:
GIT URL:
Change sponsored?: ---
Patch complexity: ---
Documentation contact:
Documentation submission:
Text to go in the release notes:
Version(s) released in:
25.05.00
Circulation function:


Attachments
Bug 39888: Prevent load of superflous JS when table is not present (1.40 KB, patch)
2025-05-13 10:41 UTC, Martin Renvoize (ashimema)
Details | Diff | Splinter Review
Bug 39888: Prevent load of superflous JS when table is not present (7.83 KB, patch)
2025-05-13 11:03 UTC, Jonathan Druart
Details | Diff | Splinter Review

Note You need to log in before you can comment on or make changes to this bug.
Description Martin Renvoize (ashimema) 2025-05-13 10:39:32 UTC
We see the following error in the browser console when loading acqui-home.pl without any budgets defined:

Cannot read properties of undefined (reading 'DataTable')

This is due to loading a large chunk of javascript to deal with a table we opt not to load into the DOM at all when budgets are not found.

This causes cypress test failures as there appears to be a transaction that removes budgets somewhere in our test suite.

Either way, we shouldn't load the JS when there's no DOM to action upon.
Comment 1 Martin Renvoize (ashimema) 2025-05-13 10:41:38 UTC
Created attachment 182352 [details] [review]
Bug 39888: Prevent load of superflous JS when table is not present

We shouldn't attempt to load the JS block for dealing with the budgets
table if there is no budgets defined and thus no budgets table.

Test plan
1) Remove all budgets
2) Load acqui-home.pl and note an error in the browser console
3) Apply the patch
4) Reload acqui-home.pl and note the errors have gone

Signed-off-by: Martin Renvoize <martin.renvoize@openfifth.co.uk>
Comment 2 Martin Renvoize (ashimema) 2025-05-13 10:42:36 UTC
Self QA to get Jenkins green again... Matt is trying to track down where in the test suite we're not rolling back a transaction that removes all budgets.
Comment 3 Jonathan Druart 2025-05-13 11:03:25 UTC
Created attachment 182353 [details] [review]
Bug 39888: Prevent load of superflous JS when table is not present

We shouldn't attempt to load the JS block for dealing with the budgets
table if there is no budgets defined and thus no budgets table.

Test plan
1) Remove all budgets
2) Load acqui-home.pl and note an error in the browser console
3) Apply the patch
4) Reload acqui-home.pl and note the errors have gone

Signed-off-by: Martin Renvoize <martin.renvoize@openfifth.co.uk>

Amended-by: Jonathan Druart
Tidy

Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
Comment 4 Jonathan Druart 2025-05-13 11:04:56 UTC
Pushed to main for 25.05