From 3387aa306e7257b17a7deb0388317dbf34cc55fd Mon Sep 17 00:00:00 2001 From: Aleisha Amohia Date: Thu, 31 Aug 2017 22:02:05 +0000 Subject: [PATCH] Bug 19231: Add number of attached items to confirm message when deleting course 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 --- course_reserves/course-details.pl | 1 + .../prog/en/modules/course_reserves/course-details.tt | 8 +++++++- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/course_reserves/course-details.pl b/course_reserves/course-details.pl index af1eb62..a9ffe2c 100755 --- a/course_reserves/course-details.pl +++ b/course_reserves/course-details.pl @@ -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; diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/course_reserves/course-details.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/course_reserves/course-details.tt index 3e6f8c3..e9f6e7b 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/course_reserves/course-details.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/course_reserves/course-details.tt @@ -23,7 +23,13 @@ }); $("#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(); -- 2.1.4