Bug 33616 - JavaScript error in when using claims return button in checkout table
Summary: JavaScript error in when using claims return button in checkout table
Status: RESOLVED DUPLICATE of bug 33621
Alias: None
Product: Koha
Classification: Unclassified
Component: Circulation (show other bugs)
Version: Main
Hardware: All All
: P5 - low normal (vote)
Assignee: Lucas Gass
QA Contact: Marcel de Rooy
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2023-04-26 15:07 UTC by Lucas Gass
Modified: 2023-04-28 14:19 UTC (History)
3 users (show)

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


Attachments
Bug 33616: Make sure match() is evaluated against a string (1.40 KB, patch)
2023-04-26 15:30 UTC, Lucas Gass
Details | Diff | Splinter Review
Bug 33616: Make sure match() is evaluated against a string (1.45 KB, patch)
2023-04-26 17:27 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 Lucas Gass 2023-04-26 15:07:23 UTC
To recreate:

1. Set ClaimReturnedLostValue to a LOST value
2. Check out an item to a patron.
3. Click the Claim returned button within the checkout table.
4. Get spinning icon in place of the button
5. In the web developer tools console: Uncaught TypeError: value.match is not a function


Looks like this is coming from includes/js-date-format.inc:

 46             if ( ! value.match(/^\d{4}-\d{2}-\d{2}$/ ) ) {
 47                 m = m.tz(tz);
 48             }
Comment 1 Lucas Gass 2023-04-26 15:24:50 UTC
match() matches a string against a regular expression. We need to make sure the value passed is a string.
Comment 2 Lucas Gass 2023-04-26 15:30:35 UTC
Created attachment 150248 [details] [review]
Bug 33616: Make sure match() is evaluated against a string

To Test:

1. Set ClaimReturnedLostValue to a LOST value
2. Check out an item to a patron.
3. Click the Claim returned button within the checkout table.
4. Get spinning icon in place of the button
5. In the web developer tools console: Uncaught TypeError: value.match is not a function
6. Apply patch
7. Try 2 - 3 again. This time the spinning icon should turn into a grey button with the correct date.
8. There should no longer be a console error.
Comment 3 David Nind 2023-04-26 17:27:09 UTC
Created attachment 150249 [details] [review]
Bug 33616: Make sure match() is evaluated against a string

To Test:

1. Set ClaimReturnedLostValue to a LOST value
2. Check out an item to a patron.
3. Click the Claim returned button within the checkout table.
4. Get spinning icon in place of the button
5. In the web developer tools console: Uncaught TypeError: value.match is not a function
6. Apply patch
7. Try 2 - 3 again. This time the spinning icon should turn into a grey button with the correct date.
8. There should no longer be a console error.

Signed-off-by: David Nind <david@davidnind.com>
Comment 4 Marcel de Rooy 2023-04-28 10:46:25 UTC
(In reply to Lucas Gass from comment #1)
> match() matches a string against a regular expression. We need to make sure
> the value passed is a string.

Looks good to me. Do you know what you got that triggered the type error?
In theory we could pass something that may not have a toString method too and cause a new error? Probably not reproducable :)
Comment 5 Lucas Gass 2023-04-28 14:18:45 UTC
I think this is now a duplicate of Bug 33621.
Comment 6 Lucas Gass 2023-04-28 14:19:16 UTC

*** This bug has been marked as a duplicate of bug 33621 ***