Bugzilla – Attachment 58817 Details for
Bug 17817
Repeat this Tag (cloning) not working
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 17817: Fix cloning subfields using select2
Bug-17817-Fix-cloning-subfields-using-select2.patch (text/plain), 2.59 KB, created by
Patricio Marrone
on 2017-01-11 14:21:20 UTC
(
hide
)
Description:
Bug 17817: Fix cloning subfields using select2
Filename:
MIME Type:
Creator:
Patricio Marrone
Created:
2017-01-11 14:21:20 UTC
Size:
2.59 KB
patch
obsolete
>From 5ee6411a4a7b1f9bbc1971bef9bac6f676535312 Mon Sep 17 00:00:00 2001 >From: Patricio Marrone <pmarrone@unc.edu.ar> >Date: Tue, 10 Jan 2017 15:53:33 -0300 >Subject: [PATCH] Bug 17817: Fix cloning subfields using select2 > >Based on Jonathan's patch (the DO NOT PUSH one), I put together this fix. >What was changed is that select2 is reinitialized only after the cloned element >has been appended to the DOM (so that select2 can correctly calculate the field's >width). Also, I changed the selectors that searched for the line divs (for reordering) >and for the subfield's input element (for erasing the field's value) to be more specific, >since select2 introduced divs that broke some assumptions about the expected HTML structure >--- > koha-tmpl/intranet-tmpl/prog/js/cataloging.js | 14 ++++++++++++-- > 1 file changed, 12 insertions(+), 2 deletions(-) > >diff --git a/koha-tmpl/intranet-tmpl/prog/js/cataloging.js b/koha-tmpl/intranet-tmpl/prog/js/cataloging.js >index ee03961..0750d5c 100644 >--- a/koha-tmpl/intranet-tmpl/prog/js/cataloging.js >+++ b/koha-tmpl/intranet-tmpl/prog/js/cataloging.js >@@ -253,6 +253,10 @@ function CloneField(index, hideMarc, advancedMARCEditor) { > */ > function CloneSubfield(index, advancedMARCEditor){ > var original = document.getElementById(index); //original <div> >+ var original_selects = original.getElementsByTagName('select'); >+ for( var i=0,len=original_selects.length;i<len;i++){ >+ $(original_selects[i]).select2('destroy'); >+ } > var clone = original.cloneNode(true); > var new_key = CreateKey(); > // set the attribute for the new 'div' subfields >@@ -327,8 +331,14 @@ function CloneSubfield(index, advancedMARCEditor){ > } > // insert this line on the page > original.parentNode.insertBefore(clone,original.nextSibling); >+ >+ //Restablish select2 for the cloned elements. >+ for( var i=0,len=selects.length;i<len;i++){ >+ $(selects[i]).select2(); >+ $(original_selects[i]).select2(); >+ } > // delete data of cloned subfield >- document.getElementById(linkid).value = ""; >+ clone.querySelectorAll('input.input_marceditor').value = ""; > } > > function AddEventHandlers (oldcontrol, newcontrol, newinputid ) { >@@ -414,7 +424,7 @@ function upSubfield(index) { > var tag = line.parentNode; // get the dad of this line. (should be "<div id='tag_...'>") > > // getting all subfields for this tag >- var subfields = tag.getElementsByTagName('div'); >+ var subfields = tag.querySelectorAll('div.subfield_line'); > var subfieldsLength = subfields.length; > > if(subfieldsLength<=1) return; // nothing to do if there is just one subfield. >-- >2.1.4
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 17817
:
58464
|
58465
|
58579
|
58817
|
58823
|
58824
|
58827
|
58828
|
58844
|
58845
|
58847
|
58848
|
58849
|
58863
|
58864