From 1b5c0966bbb600b6927fa04edcb1691a794f38f6 Mon Sep 17 00:00:00 2001 From: Jonathan Druart Date: Wed, 17 Sep 2014 13:11:00 +0200 Subject: [PATCH] Bug 12937: Deleting suggestions should ask for a confirmation On the suggestion management page, the librarian can choose to delete suggestions but no confirmation is needed. This could produce unexpected lost of data. Test plan: - go on the suggestion management page - don't select any suggestion and try to delete (check the checkbox and submit the form). Verify that you get an alert. - select 1 suggestion and delete it, verify you get a confirmation message - select 1+ suggestions and delete it, verify you get a confirmation message Signed-off-by: Owen Leonard Signed-off-by: Kyle M Hall Signed-off-by: Tomas Cohen Arazi --- .../prog/en/modules/suggestion/suggestion.tt | 26 ++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-) diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/suggestion/suggestion.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/suggestion/suggestion.tt index a0d9468137..70d00addeb 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/suggestion/suggestion.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/suggestion/suggestion.tt @@ -134,6 +134,30 @@ $(document).ready(function() { datesAD.not( this ).datepicker( "option", option, date ); } }); + + $("form.update_suggestions").on("submit", function(e){ + var form = this; + var action_delete_selected = $(this).find("input[value='delete']").is(":checked"); + if ( action_delete_selected ) { + var suggestions_to_delete = $(this).find("input[name='edit_field']:checked"); + if ( suggestions_to_delete.length == 0 ) { + alert(_("No suggestion to delete")); + e.preventDefault(); + return false; + } else if ( suggestions_to_delete.length == 1 ) { + if ( ! confirm(_("Are you sure you want to delete this suggestion")) ) { + e.preventDefault(); + return false; + } + } else if ( suggestions_to_delete.length > 1 ) { + if ( ! confirm(_("Are you sure you want to delete these suggestions")) ) { + e.preventDefault(); + return false; + } + } + } + return true; + }); }); // ]]> @@ -460,7 +484,7 @@ h4.local_collapse a { font-size : 80%; text-decoration: none; } fieldset.brief o [% FOREACH suggestion IN suggestions %]
-
+ [% IF ( suggestion.suggestions_loop ) %]

Check all | Uncheck all

-- 2.39.5