Bug 19231: Add number of attached items to confirm message when deleting course
authorAleisha Amohia <aleishaamohia@hotmail.com>
Thu, 31 Aug 2017 22:02:05 +0000 (22:02 +0000)
committerJonathan Druart <jonathan.druart@bugs.koha-community.org>
Fri, 27 Oct 2017 19:05:55 +0000 (16:05 -0300)
To test:
1) Ensure UseCourseReserves is enabled
2) Go to Course Reserves and create 3 new courses
3) Add one item to a course, add two items to another course, and add no
items to the third course
4) Delete the course with no items. Confirm the error message shows up.
No need to say how many attached items there are here (because there are
none).
5) Delete the course with one item. Confirm the error message shows and
warns of the one attached item and makes grammatical sense
6) Delete the course with two items. Confirm the error message shows and
shows the correct number of attached items and makes grammatical sense
7) Confirm clicking 'Cancel' and 'OK' does what is expected

Sponsored-by: Catalyst IT
Signed-off-by: Claire Gravely <claire.gravely@bsz-bw.de>

Looks good!

Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>

Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>

course_reserves/course-details.pl
koha-tmpl/intranet-tmpl/prog/en/modules/course_reserves/course-details.tt

index af1eb62..a9ffe2c 100755 (executable)
@@ -60,6 +60,7 @@ my $course_reserves = GetCourseReserves(
 $template->param(
     course          => $course,
     course_reserves => $course_reserves,
+    count           => scalar @$course_reserves,
 );
 
 output_html_with_http_headers $cgi, $cookie, $template->output;
index e07cbe5..1600824 100644 (file)
         });
 
         $("#delete_course").click(function(){
-            return confirm( _("Are you sure you want to delete this course?") );
+            [% IF count == 1 %]
+                return confirmDelete(_("Are you sure you want to delete this course? There is [% count %] attached item.") );
+            [% ELSIF count != 1 && count > 0 %]
+                return confirmDelete(_("Are you sure you want to delete this course? There are [% count %] attached items.") );
+            [% ELSE %]
+                return confirmDelete(_("Are you sure you want to delete this course?"));
+            [% END %]
         });
         $(".disabled").tooltip().on("click", function(e){
             e.preventDefault();