From b7050039ab6f12916e6057f4d5ed8aa44deafcb8 Mon Sep 17 00:00:00 2001 From: David Cook Date: Thu, 10 Nov 2022 23:28:54 +0000 Subject: [PATCH] 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" --- koha-tmpl/intranet-tmpl/prog/js/additem.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/koha-tmpl/intranet-tmpl/prog/js/additem.js b/koha-tmpl/intranet-tmpl/prog/js/additem.js index a83310f29d..6f1a68f3a3 100644 --- a/koha-tmpl/intranet-tmpl/prog/js/additem.js +++ b/koha-tmpl/intranet-tmpl/prog/js/additem.js @@ -191,7 +191,8 @@ function cloneItemBlock(index, unique_item_fields, callback) { /* Copy values from the original block (input) */ $(original).find("input[name='field_value']").each(function(){ var kohafield = $(this).siblings("input[name='kohafield']").val(); - if($(this).val() && $.inArray(kohafield,dont_copy_fields) == -1) { + //NOTE: flatpickr_wrapper prevents kohafield from being found + if(kohafield && $(this).val() && $.inArray(kohafield,dont_copy_fields) == -1) { $(this).parent("div").attr("id").match(/^(subfield.)/); var id = RegExp.$1; var value = $(this).val(); -- 2.25.1