Bugzilla – Attachment 115574 Details for
Bug 27508
Can't duplicate the MARC field tag with JavaScript if option "advancedMARCeditor" is set to "Don't display"
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 27508: do nothing if tag label elements don't exist
Bug-27508-do-nothing-if-tag-label-elements-dont-ex.patch (text/plain), 2.64 KB, created by
Owen Leonard
on 2021-01-21 16:19:25 UTC
(
hide
)
Description:
Bug 27508: do nothing if tag label elements don't exist
Filename:
MIME Type:
Creator:
Owen Leonard
Created:
2021-01-21 16:19:25 UTC
Size:
2.64 KB
patch
obsolete
>From 02662cbc56efe34c04c53c14262da024b0cc4d0c Mon Sep 17 00:00:00 2001 >From: Petro Vashchuk <stalkernoid@gmail.com> >Date: Thu, 21 Jan 2021 14:11:24 +0200 >Subject: [PATCH] Bug 27508: do nothing if tag label elements don't exist > >When JavaScript make copy of DOM set for MARC tag, it tries to reassign >label elements to another id, the problem is there is no check for >existence of that label element, so in case when option >"advancedMARCeditor" is set to "Don't display", labels were absent >which caused JavaScript to crush in the middle of process with uncaught >exception. > >This patch wraps this label assignment in try/catch hook like it's done >in the code around for other elements, to allow the script to proceed >when description labels are not present. > >To test: >1) Check in the system preferences interface subsection that > "advancedMARCeditor" is set to "Display". >2) Go to the "Add MARC record" cataloguing section and press "Repeat > this tag" button near the MARC tag record to ensure that it makes > duplicate in the interface as expected. >3) Then again in the system preferences interface subsection change > "advancedMARCeditor" to "Don't display". >4) Return back to the "Add MARC record" interface, refresh the page to > have no MARC field labels displayed, and try duplicating the tag > again. >5) Ensure that it doesn't work, also you can notice a JavaScript error > "Cannot read property "setAttribute" of undefined..." in the > JavaScript console of your browser. >6) Apply the patch. >7) Repeat the test sequence (changes will be in the step 5), ensure that > the tag gets duplicated even when description labels are not present. > >Signed-off-by: Owen Leonard <oleonard@myacpl.org> >--- > koha-tmpl/intranet-tmpl/prog/js/cataloging.js | 9 +++++++-- > 1 file changed, 7 insertions(+), 2 deletions(-) > >diff --git a/koha-tmpl/intranet-tmpl/prog/js/cataloging.js b/koha-tmpl/intranet-tmpl/prog/js/cataloging.js >index 64a9ebdce5..2dc65396ad 100644 >--- a/koha-tmpl/intranet-tmpl/prog/js/cataloging.js >+++ b/koha-tmpl/intranet-tmpl/prog/js/cataloging.js >@@ -230,8 +230,13 @@ function CloneField(index, hideMarc, advancedMARCEditor) { > } > } > // when cloning a subfield, re set its label too. >- var labels = divs[i].getElementsByTagName('label'); >- labels[0].setAttribute('for', id_input); >+ try { >+ var labels = divs[i].getElementsByTagName('label'); >+ labels[0].setAttribute('for', id_input); >+ } >+ catch(e) { >+ // do nothing if label does not exist. >+ } > > // setting its '+' and '-' buttons > try { >-- >2.11.0
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 27508
:
115535
|
115574
|
115739