From f5fcd2a55eed9358f7a75c66a7eb6ef7d45b586f Mon Sep 17 00:00:00 2001 From: Owen Leonard Date: Thu, 23 Sep 2021 21:14:52 +0000 Subject: [PATCH] Bug 29019: Unable to delete HTML customization This patch makes some corrections to additional contents to allow content to be deleted. The wrong parameter was being passed to the script. The script was also not handling multiple deletions correctly. The patch also adds a "category" parameter to the delete operation so that the page is redirected correctly. The patch also changes some strings which referred to "news" referencing operations which might be performed on news or on HTML customizations, e.g.: "Are you sure you want to delete the selected content?" instead of "Are you sure you want to delete the selected news?" To test, apply the patch and go to Tools -> News. - Create multiple news items if necessary. - Test the "Delete" button corresponding to a single news item: - Clicking the button should ask you to confirm. - Check that the wording of the message is correct. - After confirming the news item should be deleted. - Ideally, test on news items which are on the second page of the DataTable of news items. - Test the process of deleting multiple news items at once: - Check the checkbox next to multiple items. - Click the "Delete selected" button at the bottom of the page. - Check that the wording of the confirmation message is correct. - After you confirm, the items should be deleted. - Repeat these tests under Tools -> HTML customizations to confirm that redirects work correctly. After deleting an HTML customization you should be redirected back to the list of HTML customizations. Signed-off-by: Caroline Cyr La Rose Signed-off-by: Katrin Fischer Signed-off-by: Jonathan Druart --- .../en/modules/tools/additional-contents.tt | 22 ++++++++++++++----- tools/additional-contents.pl | 2 +- 2 files changed, 17 insertions(+), 7 deletions(-) diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/tools/additional-contents.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/tools/additional-contents.tt index c693a68b2e..21dd0eeb04 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/tools/additional-contents.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/tools/additional-contents.tt @@ -366,16 +366,22 @@ [% END %] - + +
+
+ + + +
[% ELSE %]
There are no additional contents.
[% END %] @@ -482,15 +488,19 @@ "sPaginationType": "full_numbers" })); - $(".delete_news").on("click", function(){ - return confirmDelete( _("Are you sure you want to delete this news item? This cannot be undone.") ); + $("#del_form").on("click", ".delete_news", function(e){ + e.preventDefault(); + if( confirmDelete( _("Are you sure you want to delete this content? This cannot be undone.") ) ){ + $("#del_ids").val( $(this).data("idnew") ); + $("#delete_single").submit(); + } }); $("#del_form").on("submit",function(){ if ( Checkbox() ) { - return confirmDelete( _("Are you sure you want to delete the selected news?") ); + return confirmDelete( _("Are you sure you want to delete the selected content?") ); } else { - alert(_("Please select a news item to delete.")); + alert(_("Please select content to delete.")); return false; } }); diff --git a/tools/additional-contents.pl b/tools/additional-contents.pl index e4a409cb68..288c6e1ab7 100755 --- a/tools/additional-contents.pl +++ b/tools/additional-contents.pl @@ -174,7 +174,7 @@ elsif ( $op eq 'add_validate' ) { elsif ( $op eq 'delete_confirmed' ) { my @ids = $cgi->multi_param('ids'); my $deleted = - eval { Koha::AdditionalContents->search( { idnew => @ids } )->delete; }; + map { Koha::AdditionalContents->find($_)->delete() } @ids; if ( $@ or not $deleted ) { push @messages, { type => 'error', code => 'error_on_delete' }; -- 2.39.5