From 3ca0234d34ac9708a8335cfa97805fb7498201bf Mon Sep 17 00:00:00 2001 From: Fridolin Somers Date: Thu, 31 Jan 2019 09:12:13 +0100 Subject: [PATCH] Bug 22242: Javascript error in value builder cased by Select2 Same as Bug 17780 but in value builders. Select2 (Bug 13501) introduced divs and inputs that broke some assumptions about the expected HTML structure. This patch checks if input has name attribute, because some inputs in Select2 have not. It brakes value builders marc21_linking_section.tt and unimarc_field_4XX.tt. Test plan : 1) On a MARC21 database 2) Define 774$0 as a regular subfield 3) Define 774$4 with an authorised value category 4) Define 774$t with value builder marc21_linking_section 5) Create a new record 6) Use value builder in 774$t 7) Search for a record and click choose 8) Without patch : a popup window does not close and show a blank screen 9) With patch : popup windows get close and you see in field 774 $0 and $t field with values 10) Same tests with a UNIMARC database on field 461 with value builder unimarc_field_4XX.tt Signed-off-by: Owen Leonard Tested successfully with MARC21 Signed-off-by: Josef Moravec Signed-off-by: Nick Clemens --- .../modules/cataloguing/value_builder/marc21_linking_section.tt | 1 + .../en/modules/cataloguing/value_builder/unimarc_field_4XX.tt | 1 + 2 files changed, 2 insertions(+) diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/cataloguing/value_builder/marc21_linking_section.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/cataloguing/value_builder/marc21_linking_section.tt index 4b7f2788f5..292d529ae9 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/cataloguing/value_builder/marc21_linking_section.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/cataloguing/value_builder/marc21_linking_section.tt @@ -144,6 +144,7 @@ var re = /^tag_\d*_code_/; for (var i = 0, len = subfields.length; i < len; i++) { + if (subfields[i].hasAttribute('name') == 0) { continue; } // div elements specific to Select2 if (subfields[i].getAttribute('name').match(re)) { // it s a subfield var code = subfields[i]; var subfield = subfields[i + 1]; diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/cataloguing/value_builder/unimarc_field_4XX.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/cataloguing/value_builder/unimarc_field_4XX.tt index 8f613adf6d..2268a0953c 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/cataloguing/value_builder/unimarc_field_4XX.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/cataloguing/value_builder/unimarc_field_4XX.tt @@ -161,6 +161,7 @@ var re = /^tag_\d*_code_/; for(var i=0, len = subfields.length ; i< len ; i++) { + if(subfields[i].hasAttribute('name') == 0) { continue; } // div elements specific to Select2 if(subfields[i].getAttribute('name').match(re)){ // it s a subfield var code = subfields[i]; var subfield = subfields[i+1]; -- 2.39.5