From 9e18b9403c8809f91e50a441ab8bb863908cf69d Mon Sep 17 00:00:00 2001 From: Jonathan Druart Date: Tue, 27 Jul 2021 15:29:38 +0200 Subject: [PATCH] Bug 28445: UI change for repeatable and regex This patch applies the changes describe in the main commit message about the "limitation" and "the behaviour in master was buggy". Signed-off-by: Nick Clemens Signed-off-by: Tomas Cohen Arazi Signed-off-by: Jonathan Druart --- .../intranet-tmpl/prog/en/modules/tools/batchMod-edit.tt | 7 +++++++ koha-tmpl/intranet-tmpl/prog/js/cataloging.js | 8 ++++++++ 2 files changed, 15 insertions(+) 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 5660a2cb45..75402985f0 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 @@ -260,6 +260,13 @@ $(tag_editor).hide(); $(this).html('Text'); $(disable_input).prop('disabled', true); + let input_name = $(editor).attr('name'); + let cloned = $("input[name='"+input_name+"']"); + if ( cloned.length > 1 ) { + for( i = 1 ; i < cloned.length ; i++){ + $(cloned[i]).parent().remove(); + } + } } else { $(editor).show(); $(tag_editor).show(); diff --git a/koha-tmpl/intranet-tmpl/prog/js/cataloging.js b/koha-tmpl/intranet-tmpl/prog/js/cataloging.js index f93fefc833..5ba1e76714 100644 --- a/koha-tmpl/intranet-tmpl/prog/js/cataloging.js +++ b/koha-tmpl/intranet-tmpl/prog/js/cataloging.js @@ -543,6 +543,14 @@ function CloneItemSubfield(original){ var new_id = original.getAttribute('id')+new_key; clone.setAttribute('id',new_id); + // Don't clone "RegEx". We don't handle it for repeatable subfields + var links = clone.getElementsByTagName('a'); + for( i = 0 ,len = links.length ; i < len ; i++){ + if( $(links[i]).hasClass('field_regex') ) { + $(links[i]).remove(); + } + } + // insert this line on the page original.parentNode.insertBefore(clone,original.nextSibling); Select2Utils.initSelect2($(original).find('select')); -- 2.39.5