Bug 32175 - Item info not cloning when receiving multiple items due to Flatpickr issue
Summary: Item info not cloning when receiving multiple items due to Flatpickr issue
Status: RESOLVED DUPLICATE of bug 23202
Alias: None
Product: Koha
Classification: Unclassified
Component: Acquisitions (show other bugs)
Version: Main
Hardware: All All
: P5 - low normal (vote)
Assignee: David Cook
QA Contact: Testopia
URL:
Keywords:
Depends on: 29369
Blocks:
  Show dependency treegraph
 
Reported: 2022-11-10 23:05 UTC by David Cook
Modified: 2022-11-18 06:00 UTC (History)
2 users (show)

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


Attachments
Bug 32175: Prevent Javascript error by checking for kohafield sibling (1.97 KB, patch)
2022-11-10 23:33 UTC, David Cook
Details | Diff | Splinter Review

Note You need to log in before you can comment on or make changes to this bug.
Description David Cook 2022-11-10 23:05:47 UTC
Bug 29369 added Flatpickr to the "Date acquired" field

When creating items at receival time in Acquisitions, the item info should be cloned/prefilled for the next item after adding an item.

However, if you've added a value to "Date acquired", it will trigger a Javascript error that stops the clone/prefill from working.

This is because the "input[name='field_value']" element is wrapped by '<span class="flatpickr_wrapper">' which creates a problematic inconsistency with the HTML structure...
Comment 1 David Cook 2022-11-10 23:16:02 UTC Comment hidden (obsolete)
Comment 2 David Cook 2022-11-10 23:20:05 UTC
I don't know how widely used this cloneItemBlock function is... although it looks like it might not be working correctly in other parts of Koha.

I'm tempted to just handle the error, although that means "Date acquired" won't be cloned...
Comment 3 David Cook 2022-11-10 23:33:12 UTC
Created attachment 143738 [details] [review]
Bug 32175: Prevent Javascript error by checking for kohafield sibling

This patch checks for kohafield sibling before proceeding with
data clone when creating items during receival.

If the kohafield sibling is not available, don't try to clone the
value.

Test plan:
1. Create a test vendor
2. Create a test basket (create item on receival)
3. Create a test order for 3 items
4. Close the test basket
5. Receive the order
6. Fill out many item fields including "Date acquired"
7. Click "Add item"
8. Note that the fields aren't cloned and there is a Javascript error
in the console

9. Apply the patch

10. Refresh the page
11. Fill out many item fields including "Date acquired"
12. Click "Add item"
13. Note that the fields are cloned, except "Date acquired"
Comment 4 David Cook 2022-11-10 23:33:37 UTC
Note that not cloning "Date acquired" isn't too big of a deal, as it will automatically be set (these days) when saving the item.
Comment 5 David Nind 2022-11-11 02:31:21 UTC
I had a go at testing a couple of times, but I couldn't replicate the issue (on current master just updated, using Firefox).
Comment 6 David Cook 2022-11-11 05:45:16 UTC
(In reply to David Nind from comment #5)
> I had a go at testing a couple of times, but I couldn't replicate the issue
> (on current master just updated, using Firefox).

Hmm, ok, I'll have another look at this one
Comment 7 Jonathan Druart 2022-11-11 08:42:29 UTC
Same, I cannot recreate on master.
Comment 8 Katrin Fischer 2022-11-13 14:58:47 UTC
This sounds a bit similar to bug 23202 we encountered after the switch to flatpickr for 'items on ordering'. 

I also had no issues testing this on current master.
Comment 9 Jonathan Druart 2022-11-18 06:00:16 UTC
Closing, please reopen if needed.

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