From 36f290de12947ddaae78a6108c350694d7dce05d Mon Sep 17 00:00:00 2001
From: Slava Shishkin <slavashishkin@gmail.com>
Date: Mon, 20 Nov 2023 18:32:51 +0200
Subject: [PATCH] Bug 35383: Make subfields of repeated tags draggable

To reproduce:
1. Open any biblio and edit that record.
   (select "Edit record" from the "Edit" drop-down menu).
2. Repeat any tag that may be repeated and has more than one subfield
   (e.g. 050 or 082) (click "Repeat this tag")
3. Try dragging a subfield of the new repeated tag

Apply the patch and make sure dragging a subfield works well.

Signed-off-by: Phil Ringnalda <phil@chetcolibrary.org>
---
 koha-tmpl/intranet-tmpl/prog/js/cataloging.js | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/koha-tmpl/intranet-tmpl/prog/js/cataloging.js b/koha-tmpl/intranet-tmpl/prog/js/cataloging.js
index f257b19666..64a5c4cc7f 100644
--- a/koha-tmpl/intranet-tmpl/prog/js/cataloging.js
+++ b/koha-tmpl/intranet-tmpl/prog/js/cataloging.js
@@ -324,6 +324,12 @@ function CloneField(index, hideMarc, advancedMARCEditor) {
     // insert this line on the page
     original.parentNode.insertBefore(clone,original.nextSibling);
 
+    $(clone).find("ul.sortable_subfield").each((i, e) => {
+        Sortable.create(e, {
+            animation: 150,
+        });
+    });
+
     Select2Utils.initSelect2($(original).find('select'));
     Select2Utils.initSelect2($(clone).find('select'));
 }
-- 
2.40.0