From 221bf85e6ee7a5633ad7cb89613d0652efb3a698 Mon Sep 17 00:00:00 2001 From: Owen Leonard Date: Tue, 9 Jul 2024 13:13:34 +0000 Subject: [PATCH] Bug 37270: Fix deletion of saved reports This patch fixes deletion of saved reports in two instances which were broken by the CSRF changes: From the dropdown menu in the table of saved reports, and in the modal window which appears if you click the "Preview" dropdown menu in the table of saved reports. The patch also makes a minor change to form-submit.js so that the event handler will attach to dynamically-generated elements (as is the case with the preview modal). To test, apply the patch and go to Reports -> Use saved. - Add one or more reports if necessary. - In the table of reports, click the secondary dropdown link in the "Run" button. - Click "Delete." You should be asked to confirm, and confirming should correctly delete the report. - Now test the "Preview SQL" link in the menu. - A modal window should appear showing you the SQL of the report. - In the footer of the modal, test the "Delete" button. Sponsored-by: Athens County Public Libraries Signed-off-by: Phil Ringnalda Signed-off-by: Martin Renvoize --- .../modules/reports/guided_reports_start.tt | 30 ++----------------- .../intranet-tmpl/prog/js/form-submit.js | 2 +- 2 files changed, 4 insertions(+), 28 deletions(-) diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/reports/guided_reports_start.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/reports/guided_reports_start.tt index 50f7a65a4ff..17fda2b0b54 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/reports/guided_reports_start.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/reports/guided_reports_start.tt @@ -389,12 +389,7 @@
  • Schedule
  • [% IF ( CAN_user_reports_delete_reports ) %]
  • -
    - [% INCLUDE 'csrf-token.inc' %] - - -
    - Delete + Delete
  • [% END %] @@ -1567,7 +1562,7 @@ [% Asset.js( "lib/codemirror/highlight.js" ) | $raw %] [% Asset.css("lib/codemirror/highlight.css") | $raw %] [% Asset.js( "js/mana.js" ) | $raw %] - + [% Asset.js("js/form-submit.js") | $raw %] [% END %] diff --git a/koha-tmpl/intranet-tmpl/prog/js/form-submit.js b/koha-tmpl/intranet-tmpl/prog/js/form-submit.js index d7b8222cbe6..697f41be6ab 100644 --- a/koha-tmpl/intranet-tmpl/prog/js/form-submit.js +++ b/koha-tmpl/intranet-tmpl/prog/js/form-submit.js @@ -1,6 +1,6 @@ /* keep tidy */ $(document).ready(function () { - $(".submit-form-link").click(function (e) { + $("body").on("click", ".submit-form-link", function (e) { e.preventDefault(); let form_data = $(this).data(); -- 2.45.2