From e68c56745abd59ace4266443f90cb8bae1e431c9 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 (cherry picked from commit 44d0703b4a9a9ab116b4d473c2805e3fb283c2a2) Signed-off-by: Lucas Gass --- .../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 af0912e082..9dc7e30a75 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 %] @@ -1572,7 +1567,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 11f4a2a89b..5795891e4b 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.39.5