From cc86d69eb20400de0f301606512ecc8536294330 Mon Sep 17 00:00:00 2001 From: Sam Lau Date: Mon, 24 Jun 2024 19:55:59 +0000 Subject: [PATCH] Bug 27182: Add ability to rename a MARC modification template This patch adds a new 'Rename template' button on the MARC modifications templates page. To test: 1) Go to Cataloging -> MARC modification templates 2) Click the button at the top 'New template'. Name your template and press submit. 3) You should now be on the actions page for that template. Notice there isn't any options to rename your template. 4) Apply patch and restart_all 5) Notice that there is now a "Rename template' button. 6) Click this and rename your template and press submit. 7) Notice that the template name changed correctly. 8) Go back to the general MARC modifications templates page. Note the name of your template is correctly displayed in the table. --- C4/MarcModificationTemplates.pm | 15 +++++++++ .../tools/marc_modification_templates.tt | 32 +++++++++++++++++++ tools/marc_modification_templates.pl | 4 +++ 3 files changed, 51 insertions(+) diff --git a/C4/MarcModificationTemplates.pm b/C4/MarcModificationTemplates.pm index 13b81ca0b4..8129fba820 100644 --- a/C4/MarcModificationTemplates.pm +++ b/C4/MarcModificationTemplates.pm @@ -43,6 +43,7 @@ BEGIN { GetModificationTemplates AddModificationTemplate DelModificationTemplate + RenameModificationTemplate GetModificationTemplateAction GetModificationTemplateActions @@ -162,6 +163,20 @@ sub DelModificationTemplate { $sth->execute( $template_id ); } +=head2 + RenameModificationTemplate + + RenameModificatoinTemplate( $template_name, $template_id ); +=cut + +sub RenameModificationTemplate { + my ( $template_name, $template_id ) = @_; + + my $dbh = C4::Context->dbh; + my $sth = $dbh->prepare("UPDATE marc_modification_templates SET name = ? WHERE template_id = ?"); + $sth->execute( $template_name, $template_id ); +} + =head2 GetModificationTemplateAction 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 f2eecda293..61086861d8 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,6 +70,7 @@ New template [% IF ( template_id != '' ) %] New action + Rename template
[% INCLUDE 'csrf-token.inc' %] @@ -373,6 +374,37 @@ + +
+ diff --git a/tools/marc_modification_templates.pl b/tools/marc_modification_templates.pl index 6105d74c15..be5472a891 100755 --- a/tools/marc_modification_templates.pl +++ b/tools/marc_modification_templates.pl @@ -31,6 +31,7 @@ use C4::MarcModificationTemplates qw( GetModificationTemplates ModModificationTemplateAction MoveModificationTemplateAction + RenameModificationTemplate ); my $cgi = CGI->new; @@ -55,6 +56,9 @@ if ( $op eq "cud-create_template" ) { DelModificationTemplate( $template_id ); $template_id = ''; +} elsif ( $op eq "cud-rename_template" ) { + RenameModificationTemplate ( scalar $cgi->param('template_name'), $template_id ); + } elsif ( $op eq "cud-add_action" ) { my $mmta_id = $cgi->param('mmta_id'); -- 2.39.2