From 6b9692b8813900e0509227cb4a18d0b5b495f9b7 Mon Sep 17 00:00:00 2001
From: Owen Leonard <oleonard@myacpl.org>
Date: Fri, 19 Feb 2021 00:01:26 +0000
Subject: [PATCH] Bug 24623: Phase out jquery.cookie.js: Advanced MARC editor

This patch changes cookie handling in the MARC editor templates so that
the js-cookie plugin is used instead of jquery.cookie.

To test, apply the patch and go to Cataloging.

 - Search for a title using the cataloging search in the header search
   form.
 - In the search results, choose "Edit record" from the "Actions" menu.
 - By default you should be taken to the "basic" MARC editor.
 - From the "Settings" menu button, choose "Switch to advanced editor."
 - Return to the cataloging home page and perform another search.
 - Now when you choose "Edit record" you should be taken directly to the
   advanced editor.
 - In the advanced editor, choose "Switch to basic editor" from the
   "Settings" menu.
 - The basic editor should now be saved as the default.
 - Test also with "Edit record" links in catalog search results.

Signed-off-by: David Nind <david@davidnind.com>
---
 koha-tmpl/intranet-tmpl/prog/en/includes/cateditor-ui.inc       | 2 +-
 koha-tmpl/intranet-tmpl/prog/en/modules/cataloguing/addbooks.tt | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/koha-tmpl/intranet-tmpl/prog/en/includes/cateditor-ui.inc b/koha-tmpl/intranet-tmpl/prog/en/includes/cateditor-ui.inc
index 62bbe96a94..39f03f75b5 100644
--- a/koha-tmpl/intranet-tmpl/prog/en/includes/cateditor-ui.inc
+++ b/koha-tmpl/intranet-tmpl/prog/en/includes/cateditor-ui.inc
@@ -1207,7 +1207,7 @@ require( [ 'koha-backend', 'search', 'macros', 'marc-editor', 'marc-record', 'pr
         $( '#switch-editor' ).click( function() {
             if ( !confirm( _("Any changes will not be saved. Continue?") ) ) return;
 
-            $.cookie( 'catalogue_editor_[% logged_in_user.borrowernumber | html %]', 'basic', { expires: 365, path: '/' } );
+            Cookies.set( "catalogue_editor_[% logged_in_user.borrowernumber | html %]", "basic", { expires: 365, path: '/' } );
 
             if ( state.backend == 'catalog' ) {
                 window.location = '/cgi-bin/koha/cataloguing/addbiblio.pl?biblionumber=' + state.recordID;
diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/cataloguing/addbooks.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/cataloguing/addbooks.tt
index d6cc00d9f4..6a2b34e6ac 100644
--- a/koha-tmpl/intranet-tmpl/prog/en/modules/cataloguing/addbooks.tt
+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/cataloguing/addbooks.tt
@@ -247,7 +247,7 @@
             });
 
             $("#useadvanced").click(function(){
-                $.cookie( 'catalogue_editor_[% logged_in_user.borrowernumber | html %]', 'advanced', { expires: 365, path: '/' } );
+                Cookies.set( "catalogue_editor_[% logged_in_user.borrowernumber | html %]", "advanced", { expires: 365, path: '/' } );
                 return true;
             });
 
-- 
2.11.0