From 0c4fe03c2331e2fc255e955312fcd4c5c9606225 Mon Sep 17 00:00:00 2001 From: David Cook Date: Wed, 30 Aug 2023 00:28:53 +0000 Subject: [PATCH] Bug 34650: Convert list toolbar delete into form POST This patch adds a HTML form with a CSRF token to POST the list delete, which is triggered by a click handler on the A element. The A element is still needed for existing style reasons. Test plan: 0. Apply patch 1. koha-plack --reload kohadev 2. In the staff interface, add a list 3. Go into that list (e.g. virtualshelves/shelves.pl?op=view&shelfnumber=X) 4. From the toolbar click the "Edit" dropdown 5. From the dropdown try either "Edit list" or "Delete list" 6. Note no CSRF error and operation completes as expected Signed-off-by: Lucas Gass Signed-off-by: Marcel de Rooy Signed-off-by: Tomas Cohen Arazi (cherry picked from commit 5d3b7cf08949d5776b732f24cefcbe377260c281) Signed-off-by: Fridolin Somers --- .../prog/en/includes/virtualshelves-toolbar.inc | 9 ++++++++- .../prog/en/modules/virtualshelves/shelves.tt | 8 ++++++++ 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/koha-tmpl/intranet-tmpl/prog/en/includes/virtualshelves-toolbar.inc b/koha-tmpl/intranet-tmpl/prog/en/includes/virtualshelves-toolbar.inc index c5a6306a78..7f2c3b07c3 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/includes/virtualshelves-toolbar.inc +++ b/koha-tmpl/intranet-tmpl/prog/en/includes/virtualshelves-toolbar.inc @@ -17,7 +17,14 @@ [% END %] diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/virtualshelves/shelves.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/virtualshelves/shelves.tt index 783d97738c..2081ed88f4 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/virtualshelves/shelves.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/virtualshelves/shelves.tt @@ -957,6 +957,14 @@ e.preventDefault(); } }); + $("#deleteshelf_toolbar").on('click',function(e){ + if(confirm(_("Are you sure you want to delete this list?"))){ + $("#deleteshelf_toolbar_form").submit(); + return false; + } else { + e.preventDefault(); + } + }); }); [% END %] -- 2.39.5