From 97f17c03dd7e82a84e813f01fe350ccc3674aeb4 Mon Sep 17 00:00:00 2001
From: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
Date: Thu, 8 Jul 2021 15:48:36 +0200
Subject: [PATCH] Bug 27526: Fix mandatory and important checks

The input names have been changed from "field_value" to $kohafield.
Modifying this could have an impact in other area, where
CheckMandatorySubfields and CheckImportantSubfields are called.
Using .input_marceditor let us fix the additem.tt form and prevent to
break the other ones.
Note that the other ones are actually broken (!)

Also note that there is a typo in the error message
        alertString2 += "\n- " + "%s " + MSG_MANDATORY_FIELDS_EMPTY.format(total_errors);
There is an extra %s

Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
---
 koha-tmpl/intranet-tmpl/prog/js/cataloging.js | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/koha-tmpl/intranet-tmpl/prog/js/cataloging.js b/koha-tmpl/intranet-tmpl/prog/js/cataloging.js
index e037f6ff82..df2e77135f 100644
--- a/koha-tmpl/intranet-tmpl/prog/js/cataloging.js
+++ b/koha-tmpl/intranet-tmpl/prog/js/cataloging.js
@@ -557,7 +557,7 @@ function CloneItemSubfield(original){
 function CheckMandatorySubfields(p){
     var total = 0;
     $(p).find(".subfield_line input[name='mandatory'][value='1']").each(function(){
-        var editor = $(this).siblings("[name='field_value']");
+        var editor = $(this).siblings(".input_marceditor");
         if (!editor.val()) {
             editor.addClass("missing");
             total++;
@@ -569,7 +569,7 @@ function CheckMandatorySubfields(p){
 function CheckImportantSubfields(p){
     var total = 0;
     $(p).find(".subfield_line input[name='important'][value='1']").each(function(i){
-        var editor = $(this).siblings("[name='field_value']");
+        var editor = $(this).siblings(".input_marceditor");
         if (!editor.val()) {
             editor.addClass("missing");
             total++;
-- 
2.32.0