From 4e5944f7f97ff6ce21f664e5094f54112362ab0a Mon Sep 17 00:00:00 2001 From: Owen Leonard Date: Fri, 23 Feb 2024 15:30:22 +0000 Subject: [PATCH] Bug 34478: Fixes for MARC modification template management This patch converts several delete links to POSTed forms and corrects the op variable names in the script. The patch also simplifies the deletion click handlers. Signed-off-by: Jonathan Druart --- .../tools/marc_modification_templates.tt | 23 ++++++++++++++++--- .../prog/js/marc_modification_templates.js | 19 ++++++--------- tools/marc_modification_templates.pl | 4 ++-- 3 files changed, 29 insertions(+), 17 deletions(-) diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/tools/marc_modification_templates.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/tools/marc_modification_templates.tt index 69a96a113e..f2eecda293 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/tools/marc_modification_templates.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/tools/marc_modification_templates.tt @@ -70,7 +70,12 @@ New template [% IF ( template_id != '' ) %] New action - Delete template +
+ [% INCLUDE 'csrf-token.inc' %] + + + +
[% END %] @@ -103,7 +108,13 @@ Edit actions Duplicate - Delete + +
+ [% INCLUDE 'csrf-token.inc' %] + + + +
[% END %] @@ -199,7 +210,13 @@ Edit - Delete +
+ [% INCLUDE 'csrf-token.inc' %] + + + + +
[% END # /FOREACH ActionsLoo %] diff --git a/koha-tmpl/intranet-tmpl/prog/js/marc_modification_templates.js b/koha-tmpl/intranet-tmpl/prog/js/marc_modification_templates.js index 847f88c009..39dfd7226d 100644 --- a/koha-tmpl/intranet-tmpl/prog/js/marc_modification_templates.js +++ b/koha-tmpl/intranet-tmpl/prog/js/marc_modification_templates.js @@ -97,10 +97,6 @@ $(document).ready(function() { } }); - $(".delete_template").on("click",function(){ - return confirmDelete(); - }); - $(".edit_action").on("click", function(){ var mmta_id = $(this).data("mmta_id"); var mmta = $.grep(mmtas, function(elt, id) { @@ -113,6 +109,13 @@ $(document).ready(function() { KohaTable("templatest", { }, table_settings); + $(".confirm-delete-action").on("click", function(){ + return confirm( __("Are you sure you wish to delete this template action?") ); + }); + + $(".confirm-delete-template").on("click", function(){ + return confirm( __("Are you sure you wish to delete this template?") ); + }); }); function updateAllEvery(){ @@ -261,14 +264,6 @@ function clearFormElements(divId) { } -function confirmDeleteAction() { - return confirm( __("Are you sure you wish to delete this template action?") ); -} - -function confirmDelete() { - return confirm( __("Are you sure you wish to delete this template?") ); -} - var modaction_legend_innerhtml; var action_submit_value; diff --git a/tools/marc_modification_templates.pl b/tools/marc_modification_templates.pl index 3517a8a8a0..6105d74c15 100755 --- a/tools/marc_modification_templates.pl +++ b/tools/marc_modification_templates.pl @@ -50,7 +50,7 @@ if ( $op eq "cud-create_template" ) { $template_id = '' unless $cgi->param('duplicate_current_template'); $template_id = AddModificationTemplate( scalar $cgi->param('template_name'), $template_id ); -} elsif ( $op eq "delete_template" ) { +} elsif ( $op eq "cud-delete_template" ) { DelModificationTemplate( $template_id ); $template_id = ''; @@ -108,7 +108,7 @@ if ( $op eq "cud-create_template" ) { $template->param( error => 'no_from_field' ); } -} elsif ( $op eq "delete_action" ) { +} elsif ( $op eq "cud-delete_action" ) { DelModificationTemplateAction( scalar $cgi->param('mmta_id') ); } elsif ( $op eq "move_action" ) { -- 2.39.5