From 1858268384c43d9f8b685ffae6bfc8ad33cca4ee Mon Sep 17 00:00:00 2001 From: Nick Clemens Date: Wed, 31 Jan 2024 08:10:53 -0500 Subject: [PATCH] Bug 34478: Manual fix - update ops and use forms - editCollections Bug 34478: TO SQUASH - Manual fix editCollections Signed-off-by: Jonathan Druart --- .../en/includes/rotating-collections-toolbar.inc | 11 ++++++++--- .../rotating_collections/editCollections.tt | 14 +++++++------- .../rotating_collections/rotatingCollections.tt | 10 ++++++++-- .../intranet-tmpl/prog/js/rotating-collections.js | 1 + rotating_collections/editCollections.pl | 13 ++++++++----- 5 files changed, 32 insertions(+), 17 deletions(-) diff --git a/koha-tmpl/intranet-tmpl/prog/en/includes/rotating-collections-toolbar.inc b/koha-tmpl/intranet-tmpl/prog/en/includes/rotating-collections-toolbar.inc index f8f8ab552f..b395d41031 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/includes/rotating-collections-toolbar.inc +++ b/koha-tmpl/intranet-tmpl/prog/en/includes/rotating-collections-toolbar.inc @@ -1,6 +1,6 @@
[% IF ( colId ) %] @@ -8,10 +8,15 @@ Transfer
- Delete +
+ [% INCLUDE 'csrf-token.inc' %] + + + +
[% END %] diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/rotating_collections/editCollections.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/rotating_collections/editCollections.tt index 46168d9df2..f687e9bc2f 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/rotating_collections/editCollections.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/rotating_collections/editCollections.tt @@ -4,9 +4,9 @@ [% SET footerjs = 1 %] [% INCLUDE 'doc-head-open.inc' %] [% FILTER collapse %] - [% IF ( action == "new" ) %] + [% IF ( op == "new" ) %] [% t("Add a new collection") | html %] - [% ELSIF ( action == "delete" ) %] + [% ELSIF ( op == "cud-delete" ) %] [% t("Collection deleted") | html %] [% ELSE %] [% t("Edit collection") | html %] › @@ -32,11 +32,11 @@ <a href="/cgi-bin/koha/rotating_collections/rotatingCollections.pl">Rotating collections</a> [% END %] - [%- IF ( action == "new" ) %] + [%- IF ( op == "new" ) %] [% WRAPPER breadcrumb_item bc_active= 1 %] <span>Add a new collection</span> [% END %] - [% ELSIF ( action == "delete" ) %] + [% ELSIF ( op == "cud-delete" ) %] [% WRAPPER breadcrumb_item bc_active= 1 %] <span>Collection deleted</span> [% END %] @@ -116,7 +116,7 @@ <div> - [% IF action == "new" || action == "edit" %] + [% IF op == "new" || op == "edit" %] [% IF ( previousActionEdit ) %] <h1>Edit collection <em>[% editColTitle | html %]</em></h1> [% ELSE %] @@ -126,10 +126,10 @@ <form action="editCollections.pl" method="post" class="validated"> [% INCLUDE 'csrf-token.inc' %] [% IF ( previousActionEdit ) %] - <input type="hidden" name="action" value="update" /> + <input type="hidden" name="op" value="cud-update" /> <input type="hidden" name="colId" value="[% editColId | html %]" /> [% ELSE %] - <input type="hidden" name="action" value="create" /> + <input type="hidden" name="op" value="cud-create" /> [% END %] <fieldset class="rows"> diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/rotating_collections/rotatingCollections.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/rotating_collections/rotatingCollections.tt index ecb0b514bf..4ddafa0a17 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/rotating_collections/rotatingCollections.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/rotating_collections/rotatingCollections.tt @@ -62,8 +62,14 @@ <ul class="dropdown-menu pull-right" role="menu" aria-labelledby="collectionsactions[% collectionsLoo.colId | html %]"> <li><a href="/cgi-bin/koha/rotating_collections/addItems.pl?colId=[% collectionsLoo.colId | uri %]"><i class="fa fa-plus"></i> Manage items</a></li> <li><a href="/cgi-bin/koha/rotating_collections/transferCollection.pl?colId=[% collectionsLoo.colId | uri %]"><i class="fa-solid fa-right-left"></i> Transfer</a></li> - <li><a href="/cgi-bin/koha/rotating_collections/editCollections.pl?action=edit&colId=[% collectionsLoo.colId | uri %]"><i class="fa-solid fa-pencil" aria-hidden="true"></i> Edit</a></li> - <li><a class="confirmdelete" href="/cgi-bin/koha/rotating_collections/editCollections.pl?action=delete&colId=[% collectionsLoo.colId | html %]"><i class="fa fa-trash-can"></i> Delete</a></li> + <li><a href="/cgi-bin/koha/rotating_collections/editCollections.pl?op=edit&colId=[% collectionsLoo.colId | uri %]"><i class="fa-solid fa-pencil" aria-hidden="true"></i> Edit</a></li> + <li><form id="delete_rc" action="/cgi-bin/koha/rotating_collections/editCollections.pl" method="post"> + [% INCLUDE 'csrf-token.inc' %] + <input type="hidden" name="op" value="cud-delete"> + <input type="hidden" name="colId" value="[% collectionsLoo.colId | html %]"> + <a class="confirmdelete"><i class="fa fa-trash-can"></i> Delete</a> + </form> + </li> </ul> </div> </td> diff --git a/koha-tmpl/intranet-tmpl/prog/js/rotating-collections.js b/koha-tmpl/intranet-tmpl/prog/js/rotating-collections.js index 78197ac2f7..5879ca917e 100644 --- a/koha-tmpl/intranet-tmpl/prog/js/rotating-collections.js +++ b/koha-tmpl/intranet-tmpl/prog/js/rotating-collections.js @@ -6,6 +6,7 @@ $(document).ready(function(){ $(".confirmdelete").click(function(){ $(this).parents('tr').addClass("warn"); if(confirm(__("Are you sure you want to delete this rotating collection?"))){ + $(this).parents('form').submit(); return true; } else { $(this).parents('tr').removeClass("warn"); diff --git a/rotating_collections/editCollections.pl b/rotating_collections/editCollections.pl index 6433e0106c..0d473e49e5 100755 --- a/rotating_collections/editCollections.pl +++ b/rotating_collections/editCollections.pl @@ -38,10 +38,11 @@ my ( $template, $loggedinuser, $cookie ) = get_template_and_user( ); my $action = $query->param('action'); -$template->param( action => $action ); +my $op = $query->param('op'); +$template->param( op => $op ); # Create new Collection -if ( $action eq 'create' ) { +if ( $op eq 'cud-create' ) { my $title = $query->param('title'); my $description = $query->param('description'); @@ -63,7 +64,7 @@ if ( $action eq 'create' ) { } ## Delete a club or service -elsif ( $action eq 'cud-delete' ) { +elsif ( $op eq 'cud-delete' ) { my $colId = $query->param('colId'); my ( $success, $errorCode, $errorMessage ) = DeleteCollection($colId); @@ -78,7 +79,7 @@ elsif ( $action eq 'cud-delete' ) { } ## Edit a club or service: grab data, put in form. -elsif ( $action eq 'cud-edit' ) { +elsif ( $op eq 'edit' ) { my ( $colId, $colTitle, $colDesc, $colBranchcode ) = GetCollection( $query->param('colId') ); $template->param( @@ -90,7 +91,7 @@ elsif ( $action eq 'cud-edit' ) { } # Update a Club or Service -elsif ( $action eq 'cud-update' ) { +elsif ( $op eq 'cud-update' ) { my $colId = $query->param('colId'); my $title = $query->param('title'); my $description = $query->param('description'); @@ -112,4 +113,6 @@ elsif ( $action eq 'cud-update' ) { } } +# Else, this should be 'new' and a blank form + output_html_with_http_headers $query, $cookie, $template->output; -- 2.39.5