From 2e37669f71d17cc00001c676f21b76812a7df4df Mon Sep 17 00:00:00 2001
From: Matt Blenkinsop <matt.blenkinsop@ptfs-europe.com>
Date: Tue, 11 Jul 2023 16:41:50 +0000
Subject: [PATCH] Bug 27378: (QA follow-up) Add cancel button to cookie modal

This patch adds a cancel button to the modal for reviewing cookie consents. Previously there was no way to exit without selecting one of the cookie options
---
 .../intranet-tmpl/prog/en/includes/intranet-bottom.inc     | 1 +
 koha-tmpl/intranet-tmpl/prog/js/cookieconsent.js           | 7 +++++++
 koha-tmpl/opac-tmpl/bootstrap/en/includes/masthead.inc     | 1 +
 koha-tmpl/opac-tmpl/bootstrap/js/cookieconsent.js          | 7 +++++++
 4 files changed, 16 insertions(+)

diff --git a/koha-tmpl/intranet-tmpl/prog/en/includes/intranet-bottom.inc b/koha-tmpl/intranet-tmpl/prog/en/includes/intranet-bottom.inc
index f9e1a27bc0..7627476516 100644
--- a/koha-tmpl/intranet-tmpl/prog/en/includes/intranet-bottom.inc
+++ b/koha-tmpl/intranet-tmpl/prog/en/includes/intranet-bottom.inc
@@ -137,6 +137,7 @@
                                 <button type="button" class="btn btn-primary consentAcceptEssential">Accept only essential cookies</button>
                                 <button type="button" class="btn btn-success" id="consentAcceptSelected">Accept selected non-essential cookies</button>
                             [% END %]
+                            <button type="button" class="btn btn-secondary consentCloseModal">Cancel</button>
                         </div>
                     </div>
                 </div> <!-- /.modal-content -->
diff --git a/koha-tmpl/intranet-tmpl/prog/js/cookieconsent.js b/koha-tmpl/intranet-tmpl/prog/js/cookieconsent.js
index 9c1ffab0ee..1b6ca51530 100644
--- a/koha-tmpl/intranet-tmpl/prog/js/cookieconsent.js
+++ b/koha-tmpl/intranet-tmpl/prog/js/cookieconsent.js
@@ -159,6 +159,13 @@
             runConsentedCode();
         });
 
+        // "Cancel" handler
+        $('.consentCloseModal').on('click', function(e) {
+            e.preventDefault();
+            hideContainer();
+            showConsentBar();
+        });
+
         // "More information" handler
         $('#consentMoreInfo, #viewCookieConsents').on(
             'click',
diff --git a/koha-tmpl/opac-tmpl/bootstrap/en/includes/masthead.inc b/koha-tmpl/opac-tmpl/bootstrap/en/includes/masthead.inc
index 0622ca323e..8098b87078 100644
--- a/koha-tmpl/opac-tmpl/bootstrap/en/includes/masthead.inc
+++ b/koha-tmpl/opac-tmpl/bootstrap/en/includes/masthead.inc
@@ -503,6 +503,7 @@
                                 <button type="button" class="btn btn-primary consentAcceptEssential">Accept only essential cookies</button>
                                 <button type="button" class="btn btn-warning" id="consentAcceptSelected">Accept selected non-essential cookies</button>
                             [% END %]
+                            <button type="button" class="btn btn-secondary consentCloseModal">Cancel</button>
                         </div>
                     </div>
                 </div> <!-- /.modal-content -->
diff --git a/koha-tmpl/opac-tmpl/bootstrap/js/cookieconsent.js b/koha-tmpl/opac-tmpl/bootstrap/js/cookieconsent.js
index 72bc87d624..088d3ba2aa 100644
--- a/koha-tmpl/opac-tmpl/bootstrap/js/cookieconsent.js
+++ b/koha-tmpl/opac-tmpl/bootstrap/js/cookieconsent.js
@@ -175,6 +175,13 @@
             showYourCookies();
         });
 
+        // "Cancel" handler
+        $('.consentCloseModal').on('click', function(e) {
+            e.preventDefault();
+            hideContainer();
+            showConsentBar();
+        });
+
         // "More information" handler
         $('#consentMoreInfo, #cookieConsentButton, #viewCookieConsents').on(
             'click',
-- 
2.37.1 (Apple Git-137.1)