Bug 39957 - Fix JS error on credit and debit types administration pages
Summary: Fix JS error on credit and debit types administration pages
Status: Pushed to main
Alias: None
Product: Koha
Classification: Unclassified
Component: Templates (show other bugs)
Version: Main
Hardware: All All
: P5 - low minor
Assignee: Owen Leonard
QA Contact: Katrin Fischer
URL:
Keywords:
Depends on: 39099 39810
Blocks:
  Show dependency treegraph
 
Reported: 2025-05-21 15:22 UTC by Owen Leonard
Modified: 2025-05-23 13:39 UTC (History)
2 users (show)

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


Attachments
Bug 39957: Fix JS error on credit and debit types administration pages (4.89 KB, patch)
2025-05-21 15:45 UTC, Owen Leonard
Details | Diff | Splinter Review
Bug 39957: Fix JS error on credit and debit types administration pages (4.92 KB, patch)
2025-05-21 21:09 UTC, David Nind
Details | Diff | Splinter Review

Note You need to log in before you can comment on or make changes to this bug.
Description Owen Leonard 2025-05-21 15:22:04 UTC
+++ This bug was initially created as a clone of Bug #39810 +++

When you're not adding or editing a credit or debit type there is a JS error in the console.
Comment 1 Owen Leonard 2025-05-21 15:33:43 UTC
Same for the files changed in Bug 39099, itemtypes.tt, categories.js, and authorised_values.tt.
Comment 2 Owen Leonard 2025-05-21 15:45:41 UTC
Created attachment 182696 [details] [review]
Bug 39957: Fix JS error on credit and debit types administration pages

This patch fixes an JS error in several administration pages, introduced
by Bug 39099 and 39810. We can't access a DOM node without checking for
its existence first.

To test, apply the patch and go to Administration.

- Check the following pages:
  - Authorized values
  - Credit types
  - Debit types
  - Item types
  - Patron categories.
- On each page check the JavaScript console on the initial page. There
  should be no errors.
- Check the add/edit page for each and confirm that the library
  limitation Select2 widget works correctly.

Sponsored-by: Athens County Public Libraries
Comment 3 David Nind 2025-05-21 21:09:11 UTC
Created attachment 182709 [details] [review]
Bug 39957: Fix JS error on credit and debit types administration pages

This patch fixes an JS error in several administration pages, introduced
by Bug 39099 and 39810. We can't access a DOM node without checking for
its existence first.

To test, apply the patch and go to Administration.

- Check the following pages:
  - Authorized values
  - Credit types
  - Debit types
  - Item types
  - Patron categories.
- On each page check the JavaScript console on the initial page. There
  should be no errors.
- Check the add/edit page for each and confirm that the library
  limitation Select2 widget works correctly.

Sponsored-by: Athens County Public Libraries
Signed-off-by: David Nind <david@davidnind.com>
Comment 4 David Nind 2025-05-21 21:11:24 UTC
Testing notes (using KTD):

1. Both before and after the patch, on the patron categories and item types pages (after clearing the browser cache, and a flush_memcached, restart_all), but not all the time, I get:
   - [Violation] 'setTimeout' handler took 55ms 

2. Also, on both those pages, this error appears if you don't do anything else on the page for a period of time:
   . "Unchecked runtime.lastError: A listener indicated an asynchronous response by returning true, but the message channel closed before a response was received"
Comment 5 Jonathan Druart 2025-05-22 13:54:03 UTC
This fix clearly shows that the code should not be duplicated.