From ebd95e8e02ce3931e07b0047eaa15a53b62c5ad7 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". --- .../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 5660a2cb459..75402985f02 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 f93fefc8332..5ba1e767146 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.25.1