Bug 34478: Manual fix - update ops and use forms - editCollections

Bug 34478: TO SQUASH - Manual fix editCollections

Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
This commit is contained in:
Nick Clemens 2024-01-31 08:10:53 -05:00 committed by Jonathan Druart
parent 7ba13418bc
commit 1858268384
No known key found for this signature in database
GPG Key ID: A085E712BEF0E0F0
5 changed files with 32 additions and 17 deletions

View File

@ -1,6 +1,6 @@
<div id="toolbar" class="btn-toolbar">
<div class="btn-group">
<a class="btn btn-default" href="/cgi-bin/koha/rotating_collections/editCollections.pl?action=new"><i class="fa fa-plus"></i> New collection</a>
<a class="btn btn-default" href="/cgi-bin/koha/rotating_collections/editCollections.pl?op=new"><i class="fa fa-plus"></i> New collection</a>
</div>
[% IF ( colId ) %]
@ -8,10 +8,15 @@
<a class="btn btn-default" href="/cgi-bin/koha/rotating_collections/transferCollection.pl?colId=[% colId | html %]"><i class="fa-solid fa-right-left"></i> Transfer</a>
</div>
<div class="btn-group">
<a class="btn btn-default" href="/cgi-bin/koha/rotating_collections/editCollections.pl?action=edit&amp;colId=[% colId | html %]"><i class="fa-solid fa-pencil" aria-hidden="true"></i> Edit</a>
<a class="btn btn-default" href="/cgi-bin/koha/rotating_collections/editCollections.pl?op=edit&amp;colId=[% colId | html %]"><i class="fa-solid fa-pencil" aria-hidden="true"></i> Edit</a>
</div>
<div class="btn-group">
<a class="btn btn-default confirmdelete" href="/cgi-bin/koha/rotating_collections/editCollections.pl?action=delete&amp;colId=[% colId | html %]"><i class="fa fa-trash-can"></i> Delete</a>
<form method="post" action="/cgi-bin/koha/rotating_collections/editCollections.pl">
[% INCLUDE 'csrf-token.inc' %]
<input type="hidden" name="op" value="cud-delete">
<input type="hidden" name="colId" value="[% colId | html %]">
<button type="submit" class="btn btn-default confirmdelete"><i class="fa fa-trash-can"></i> Delete</button>
</form>
</div>
[% END %]
</div>

View File

@ -4,9 +4,9 @@
[% SET footerjs = 1 %]
[% INCLUDE 'doc-head-open.inc' %]
<title>[% 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 %] &rsaquo;
@ -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">

View File

@ -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&amp;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&amp;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&amp;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>

View File

@ -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");

View File

@ -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;