From 79bf5b6a871df59170e43a6c05404cf32c6a10c0 Mon Sep 17 00:00:00 2001
From: Owen Leonard <oleonard@myacpl.org>
Date: Fri, 1 Nov 2019 18:15:53 +0000
Subject: [PATCH] Bug 23947: Phase out jquery.cookie.js: Authority merge

This patch updates the JavaScript which sets cookies during the
authority merge process so that it uses the new js-cookie library.

To test, apply the patch and perform a search in the authority module
which will return multiple results.

 - Select "Merge" from the Actions menu next to any result.
   - A message should appear at the top of the page: "Merging with
     authority: <title>".
   - Click "Cancel merge." The message should disappear.
 - Select a record to merge again.
   - Select another record.
   - The page should redirect to the authority merge page.
---
 koha-tmpl/intranet-tmpl/prog/en/includes/authorities_js.inc | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/koha-tmpl/intranet-tmpl/prog/en/includes/authorities_js.inc b/koha-tmpl/intranet-tmpl/prog/en/includes/authorities_js.inc
index 7109dc94cae..f2966019cf3 100644
--- a/koha-tmpl/intranet-tmpl/prog/en/includes/authorities_js.inc
+++ b/koha-tmpl/intranet-tmpl/prog/en/includes/authorities_js.inc
@@ -1,29 +1,29 @@
 <script>
 
 function mergeAuth(authid, summary) {
-    var alreadySelected = $.cookie('auth_to_merge');
+    var alreadySelected = Cookies.get('auth_to_merge');
     if (alreadySelected !== undefined) {
         alreadySelected = JSON.parse(alreadySelected);
-        $.cookie('auth_to_merge', '', { 'path': '/', 'expires': -1 });
+        Cookies.remove('auth_to_merge');
         var refstring = "";
         if (typeof alreadySelected.mergereference !== 'undefined') {
             refstring = "&mergereference=" + alreadySelected.mergereference;
         }
         window.location.href = "/cgi-bin/koha/authorities/merge.pl?authid=" + authid + "&authid=" + alreadySelected.authid + refstring;
     } else {
-        $.cookie('auth_to_merge', JSON.stringify({ 'authid': authid, 'summary': summary }), { 'path' : '/' });
+        Cookies.set('auth_to_merge', JSON.stringify({ 'authid': authid, 'summary': summary }), { 'path' : '/' });
         showMergingInProgress();
     }
 }
 
 function showMergingInProgress() {
-    var alreadySelected = $.cookie('auth_to_merge');
+    var alreadySelected = Cookies.get('auth_to_merge');
     if (alreadySelected !== undefined) {
         alreadySelected = JSON.parse(alreadySelected);
         $('#merge_in_progress').html(_("Merging with authority: ") + "<a href='detail.pl?authid=" + alreadySelected.authid + "'><span class='authorizedheading'>" + alreadySelected.summary + "</span> (" + alreadySelected.authid + ")</a> <a href='#' id='cancel_merge'>" + _("Cancel merge") + "</a>");
         $('#cancel_merge').click(function(event) {
             event.preventDefault();
-            $.cookie('auth_to_merge', '', { 'path': '/', 'expires': -1 });
+            Cookies.remove('auth_to_merge');
             $('#merge_in_progress').empty();
         });
     } else {
-- 
2.11.0