From 52bfea6e8c736a7f7570e530d3a0641adfd73a70 Mon Sep 17 00:00:00 2001
From: Fridolin Somers <fridolin.somers@biblibre.com>
Date: Wed, 31 May 2017 16:02:44 +0200
Subject: [PATCH] Bug 18706 - subfields to delete not disabled anymore in batch
 item modification

In Tools > Batch item modification, one can click a checkbox to delete a subfield.
This click use to disable the input to change the field value.

This comes from the patch : Bug 13501: Move "Required" and checkbox after input/select
Because input is found using JQuery next().

This patch replaces with $(this).parent().find("[name='field_value']").

Test plan :
- Go to Tools > Batch item modification
- Enter a barcode and submit
- Click on a checkbox on a non-mandatory subfield
=> Without patch the input or select is not disabled
=> With patch the input or select is disabled
- Submit
=> Check that subfield is deleted
---
 koha-tmpl/intranet-tmpl/prog/en/modules/tools/batchMod-edit.tt | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/tools/batchMod-edit.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/tools/batchMod-edit.tt
index c04733c..91c5214 100644
--- a/koha-tmpl/intranet-tmpl/prog/en/modules/tools/batchMod-edit.tt
+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/tools/batchMod-edit.tt
@@ -22,13 +22,13 @@ $(document).ready(function(){
   $("input[name='disable_input']").click(function() {
       var row = $(this).attr("id");
       row = row.replace("row","hint");
-      var subfield = $(this).next();
-      if ($(this).is(":checked")){
+      var editor = $(this).parent().find("[name='field_value']");
+      if ($(this).is(":checked")) {
           $(this).val($(this).siblings("[name='subfield']").val());
-          $(subfield).prop('disabled', true);
+          $(editor).prop('disabled', true);
           $("#"+row).html(_("This subfield will be deleted"));
       } else {
-          $(subfield).prop('disabled', false);
+          $(editor).prop('disabled', false);
           $("#"+row).html("");
       }
   });
-- 
2.7.4