[Koha-patches] [PATCH] Bug 11713 - Use new DataTables include in course reserves templates

Owen Leonard oleonard at myacpl.org
Fri Feb 7 18:32:26 CET 2014


This patch modifies two course reserves templates to use the new
DataTables include. This simplifies the inclusion of assets and updates
to the latest DataTables version. Also included:

- Adds a sorting filter on the course reserves detail table to excluding
  articles from sorting.
- Corrects the logic controlling column sorting configuration so that
  the correct columns have sorting disabled under various combinations
  of item_level_itypes, CAN_user_coursereserves_delete_reserves, and
  CAN_user_coursereserves_delete_reserves.
- Corrects the styling of toolbar buttons (buttons should have btn and
  btn-small classes).

To test you must have UseCourseReserves enabled and have multiple
existing courses, at least one of which should have items on reserve.

1. View the list of courses. Table sorting should work correctly. The
   "new course" button should look consistent with other staff client
   toolbar buttons.

2. View the list of reserves on a course.
   - Toolbar buttons should look consistent with other staff client
     toolbar buttons.
   - Sorting should work correctly, excluding sorting on the Edit,
     Remove, and "Other course reserves" columns.
   - Titles on reserve which begin with an article should be sorted
     correctly with article excluded
   - Test sorting with item-level_itypes on and off.
   - Test sorting using a patron whose permissions include various
     combinations of add_reserves and delete_reserves

To test, go to cataloging and choose "New from Z39.50." Perform a search
and confirm that table sorting still works correctly.
---
 .../en/modules/course_reserves/course-details.tt   |   27 ++++++++++++++------
 .../en/modules/course_reserves/course-reserves.tt  |    6 ++---
 2 files changed, 21 insertions(+), 12 deletions(-)

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 5e69702..e062b47 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
@@ -6,9 +6,7 @@
 [% INCLUDE 'doc-head-close.inc' %]
 
 <link rel="stylesheet" type="text/css" href="[% themelang %]/css/datatables.css" />
-<script type="text/javascript" src="[% themelang %]/lib/jquery/plugins/jquery.dataTables.min.js"></script>
-[% INCLUDE 'datatables-strings.inc' %]
-<script type="text/javascript" src="[% themelang %]/js/datatables.js"></script>
+[% INCLUDE 'datatables.inc' %]
 <script type="text/javascript">
 //<![CDATA[
     $(document).ready(function(){
@@ -17,8 +15,21 @@
             "aLengthMenu": [[10, 20, 50, 100, -1], [10, 20, 50, 100, "All"]],
             "iDisplayLength": 20,
             "aoColumnDefs": [
-                { 'bSortable': false, 'aTargets': [ 9, 10, 11 ] }
-            ]
+                [% IF ( CAN_user_coursereserves_add_reserves ) %]
+                    [% IF ( CAN_user_coursereserves_delete_reserves ) %]
+                        { 'bSortable': false, 'aTargets': [ -1, -2, -3 ] }
+                    [% ELSE %]
+                        { 'bSortable': false, 'aTargets': [ -1, -2 ] }
+                    [% END %]
+                [% ELSIF ( CAN_user_coursereserves_delete_reserves ) %]
+                    { 'bSortable': false, 'aTargets': [ -1, -2 ] }
+                [% ELSE %]
+                    { 'bSortable': false, 'aTargets': [ -1 ] }
+                [% END %]
+            ],
+            "aoColumns": [
+                { "sType": "anti-the" },null,null,[% IF item_level_itypes %]null,[% END %]null,null,null,null,null,[% IF CAN_user_coursereserves_add_reserves %]null,[% END %][% IF CAN_user_coursereserves_delete_reserves %]null,[% END %]null
+            ],
         }));
 
         $("a.delete_item").click(function(){
@@ -47,9 +58,9 @@
         <div id="yui-main">
             <div id="toolbar">
                 <ul class="toolbar">
-                    [% IF CAN_user_coursereserves_add_reserves %]<li><a class="btn" id="add_items" href="/cgi-bin/koha/course_reserves/add_items.pl?course_id=[% course.course_id %]"><i class="icon-plus"></i> Add reserves</a></li>[% END %]
-                    [% IF ( CAN_user_coursereserves_manage_courses ) %]<li><a class="btn" id="edit_course" href="/cgi-bin/koha/course_reserves/course.pl?course_id=[% course.course_id %]"><i class="icon-pencil"></i> Edit course</a></li>[% END %]
-                    [% IF ( CAN_user_coursereserves_manage_courses ) %]<li><a class="btn" id="delete_course" href="/cgi-bin/koha/course_reserves/mod_course.pl?course_id=[% course.course_id %]&action=del"><i class="icon-remove"></i> Delete course</a></li>[% END %]
+                    [% IF CAN_user_coursereserves_add_reserves %]<li><a class="btn btn-small" id="add_items" href="/cgi-bin/koha/course_reserves/add_items.pl?course_id=[% course.course_id %]"><i class="icon-plus"></i> Add reserves</a></li>[% END %]
+                    [% IF ( CAN_user_coursereserves_manage_courses ) %]<li><a class="btn btn-small" id="edit_course" href="/cgi-bin/koha/course_reserves/course.pl?course_id=[% course.course_id %]"><i class="icon-pencil"></i> Edit course</a></li>[% END %]
+                    [% IF ( CAN_user_coursereserves_manage_courses ) %]<li><a class="btn btn-small" id="delete_course" href="/cgi-bin/koha/course_reserves/mod_course.pl?course_id=[% course.course_id %]&action=del"><i class="icon-remove"></i> Delete course</a></li>[% END %]
                 </ul>
             </div><!-- /toolbar -->
 
diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/course_reserves/course-reserves.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/course_reserves/course-reserves.tt
index 820c1a2..15ae5ba 100644
--- a/koha-tmpl/intranet-tmpl/prog/en/modules/course_reserves/course-reserves.tt
+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/course_reserves/course-reserves.tt
@@ -4,9 +4,7 @@
 [% INCLUDE 'doc-head-close.inc' %]
 
 <link rel="stylesheet" type="text/css" href="[% themelang %]/css/datatables.css" />
-<script type="text/javascript" src="[% themelang %]/lib/jquery/plugins/jquery.dataTables.min.js"></script>
-[% INCLUDE 'datatables-strings.inc' %]
-<script type="text/javascript" src="[% themelang %]/js/datatables.js"></script>
+[% INCLUDE 'datatables.inc' %]
 <script type="text/javascript" id="js">
 $(document).ready(function() {
     $("#course_reserves_table").dataTable($.extend(true, {}, dataTablesDefaults, {
@@ -34,7 +32,7 @@ $(document).ready(function() {
                     <div id="toolbar">
                         <ul class="toolbar">
                             [% IF ( CAN_user_coursereserves_manage_courses ) %]
-                            <li><a class="btn" id="new_course" href="/cgi-bin/koha/course_reserves/course.pl">New course</a></li>
+                            <li><a class="btn btn-small" id="new_course" href="/cgi-bin/koha/course_reserves/course.pl"><i class="icon-plus"></i> New course</a></li>
                             [% END %]
                         </ul>
                     </div><!-- /toolbar -->
-- 
1.7.9.5


More information about the Koha-patches mailing list