From aa852f3cb10556e1e6c42770cc43fa09a7d23ef2 Mon Sep 17 00:00:00 2001 From: Lari Taskula Date: Mon, 28 Mar 2022 10:50:18 +0000 Subject: [PATCH] Bug 30376: Fix missing mandatory date acquired error on item save If you set 952$d (date acquired or "dateaccessioned") as mandatory in your MARC framework, you'll be unable to edit or add items because item form validation fails with error "1 mandatory fields empty". To test: 1. Edit a MARC framework of your choice (e.g. Default) 2. Locate 952$d "Date acquired" and click Edit /cgi-bin/koha/admin/marc_subfields_structure.pl?op=add_form&tagfield=952&frameworkcode=#subdfield 3. Tick "Mandatory" checkbox 4. Save changes 5. Edit any item using MARC framework you edited in step 1 /cgi-bin/koha/cataloguing/additem.pl?op=edititem&biblionumber=123&itemnumber=456 6. Set "Date acquired" to any date 7. Click Save 8. Observe error "- 1 mandatory fields empty (highlighted)" (JavaScript alert) 9. Apply patch 10. Repeat steps 5-7 11. Observe no error, item saves as expected --- koha-tmpl/intranet-tmpl/prog/js/cataloging.js | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/koha-tmpl/intranet-tmpl/prog/js/cataloging.js b/koha-tmpl/intranet-tmpl/prog/js/cataloging.js index 5ba1e76714..028388d6ef 100644 --- a/koha-tmpl/intranet-tmpl/prog/js/cataloging.js +++ b/koha-tmpl/intranet-tmpl/prog/js/cataloging.js @@ -566,6 +566,12 @@ function CheckMandatorySubfields(p){ var total = 0; $(p).find(".subfield_line input[name='mandatory'][value='1']").each(function(){ var editor = $(this).siblings(".input_marceditor"); + if (editor.length === 0) { + var flatpickr_editor = $(this).siblings("span.flatpickr_wrapper").children(".input_marceditor"); + if (flatpick_editor.length === 1) { + editor = flatpickr_editor; + } + } if (!editor.val()) { editor.addClass("missing"); total++; @@ -578,6 +584,12 @@ function CheckImportantSubfields(p){ var total = 0; $(p).find(".subfield_line input[name='important'][value='1']").each(function(i){ var editor = $(this).siblings(".input_marceditor"); + if (editor.length === 0) { + var flatpickr_editor = $(this).siblings("span.flatpickr_wrapper").children(".input_marceditor"); + if (flatpick_editor.length === 1) { + editor = flatpickr_editor; + } + } if (!editor.val()) { editor.addClass("missing"); total++; -- 2.25.1