Bug 21959: Batch item modification - ability to apply regular expression on text...
[koha.git] / koha-tmpl / intranet-tmpl / prog / en / modules / tools / batchMod-edit.tt
index 30afde8..8097f41 100644 (file)
@@ -24,17 +24,37 @@ $(document).ready(function(){
       var row = $(this).attr("id");
       row = row.replace("row","hint");
       var todisable = $(this).parent().find("[name='field_value'],[name='tag'],[name='subfield'],[name='mandatory']");
+      var regex_input = $(this).parent().find("[name='field_regex']");
       if ($(this).is(":checked")) {
           $(todisable).prop('disabled', true);
           $("#"+row).html(_("This subfield will be deleted"));
+          $(regex_input).prop('disabled', true);
       } else {
           $(todisable).prop('disabled', false);
           $("#"+row).html("");
+          $(regex_input).prop('disabled', false);
       }
   });
     $("#mainformsubmit").on("click",function(){
         return submitBackgroundJob(this.form);
     });
+  $('input[name="field_regex"]').change(function() {
+    var id = $(this).attr('id');
+    var editor = $(this).parent().find("[name='field_value']");
+    var regex = $(this).parent().find("[name='regex_fields']");
+    var disable_input = $(this).parent().find("[name='disable_input']");
+    if ($(this).is(':checked')) {
+      $(editor).hide();
+      $(regex).show();
+      $(this).parent().find('.hint').html(_("Enter a regular expression for this subflied"));
+      $(disable_input).prop('disabled', true);
+    } else {
+      $(editor).show();
+      $(regex).hide();
+      $(this).parent().find('.hint').html(_(""));
+      $(disable_input).prop('disabled', false);
+    }
+  });
 });
 //]]>
 </script>
@@ -285,12 +305,22 @@ $(document).ready(function(){
                 <textarea tabindex="1" id="[%- mv.id | html -%]" name="field_value" class="input_marceditor" size="50" maxlength="255">[%- mv.value | html -%]"</textarea>
               [%- END -%]
 
+              <span name="regex_fields" style="display: none;">
+                s/<input type="text" id="[% mv.id | html %]" name="regex_search" placeholder="regex pattern" />/
+                <input type="text" id="[% mv.id | html %]" name="regex_replace" placeholder="regex replacement" />/
+                <input type="text" id="[% mv.id | html %]" name="regex_modifiers" placeholder="ig" size="3" />
+              </span>
+
               [% UNLESS ( ite.mandatory ) %]
                 <input type="checkbox" id="row[% ite.tag | html %][% ite.subfield | html %][% ite.random | html %]" title="Check to delete subfield [% ite.subfield | html %]" name="disable_input" value="[% ite.subfield | html %]" />
               [% ELSE %]
                 <span class="required">Required</span>
               [% END %]
 
+              [% IF (mv.type == 'text' || mv.type == 'textarea' ) %]
+                <input type="checkbox" name="field_regex" id="[% ite.id | html %]" title="Use regular expression">
+              [% END %]
+
               <input type="hidden" name="tag"       value="[% ite.tag | html %]" />
               <input type="hidden" name="subfield"       value="[% ite.subfield | html %]" />
               <input type="hidden" name="mandatory"       value="[% ite.mandatory | html %]" />