From 084e402e0910e2443a15fc6a0658994c2062a097 Mon Sep 17 00:00:00 2001 From: Kyle M Hall <kyle@bywatersolutions.com> Date: Thu, 9 Oct 2014 10:01:16 -0400 Subject: [PATCH] Bug 10632 - Enable datatables for courses and course details in the OPAC We should use datatables for the courses and course items tables. This will make the tables sortable and searchable from the client side. Test Plan: 1) Apply this patch 2) View the courses in the OPAC, try sorting and searching 3) View the course details for a course, try sorting and searching the items. Signed-off-by: Owen Leonard <oleonard@myacpl.org> Signing off, but have a follow-up to address some missing stuff. Signed-off-by: Jonathan Druart <jonathan.druart@biblibre.com> --- .../bootstrap/en/modules/opac-course-details.tt | 15 ++++++++++++-- .../bootstrap/en/modules/opac-course-reserves.tt | 23 +++++++++++----------- opac/opac-course-reserves.pl | 12 +++-------- 3 files changed, 28 insertions(+), 22 deletions(-) diff --git a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-course-details.tt b/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-course-details.tt index 2bab190..6608394 100644 --- a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-course-details.tt +++ b/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-course-details.tt @@ -6,7 +6,10 @@ [% INCLUDE 'doc-head-open.inc' %] [% IF ( LibraryNameTitle ) %][% LibraryNameTitle %][% ELSE %]Koha online[% END %] catalog › Course reserves for [% course.course_name %] [% INCLUDE 'doc-head-close.inc' %] -[% BLOCK cssinclude %][% END %] +[% BLOCK cssinclude %] + <link rel="stylesheet" type="text/css" href="[% themelang %]/css/datatables.css" /> +[% END %] + </head> [% INCLUDE 'bodytag.inc' bodyid='opac-main' %] [% INCLUDE 'masthead.inc' %] @@ -43,7 +46,7 @@ </div> [% IF ( course_reserves ) %] - <table class="table table-bordered table-striped table-condensed"> + <table id="course-items-table" class="table table-bordered table-striped table-condensed"> <thead> <tr> <th>Title</th> @@ -86,4 +89,12 @@ </div> <!-- / .main --> [% INCLUDE 'opac-bottom.inc' %] [% BLOCK jsinclude %] + [% INCLUDE 'datatables.inc' %] + <script type="text/javascript"> + $(document).ready(function() { + $("#course-items-table").dataTable($.extend(true, {}, dataTablesDefaults, { + "sDom": '<"bottom"flp>rt<"clear">', + })); + }); + </script> [% END %] diff --git a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-course-reserves.tt b/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-course-reserves.tt index e68fa25..0fe898c 100644 --- a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-course-reserves.tt +++ b/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-course-reserves.tt @@ -4,7 +4,10 @@ [% INCLUDE 'doc-head-open.inc' %] [% IF ( LibraryNameTitle ) %][% LibraryNameTitle %][% ELSE %]Koha online[% END %] catalog › Courses [% INCLUDE 'doc-head-close.inc' %] -[% BLOCK cssinclude %][% END %] +[% BLOCK cssinclude %] + <link rel="stylesheet" type="text/css" href="[% themelang %]/css/datatables.css" /> +[% END %] + </head> [% INCLUDE 'bodytag.inc' bodyid='opac-main' %] [% INCLUDE 'masthead.inc' %] @@ -20,16 +23,6 @@ <div class="span12"> <h1>Courses</h1> - <div id="search-toolbar"> - <form action="/cgi-bin/koha/opac-course-reserves.pl" method="get" id="search_courses_form" class="form-inline"> - - <fieldset><div class="input-append"> - <label for="search_on">Search courses:</label> <input type="text" name="search_on" id="search_on" /> - <input type="submit" class="btn" value="Search" /> - </div></fieldset> - - </form> - </div><!-- /search-toolbar --> <table id="course_reserves_table" class="table table-bordered table-striped table-condensed"> <thead> @@ -67,4 +60,12 @@ </div> <!-- / .main --> [% INCLUDE 'opac-bottom.inc' %] [% BLOCK jsinclude %] + [% INCLUDE 'datatables.inc' %] + <script type="text/javascript"> + $(document).ready(function() { + $("#course_reserves_table").dataTable($.extend(true, {}, dataTablesDefaults, { + "sDom": '<"bottom"flp>rt<"clear">', + })); + }); + </script> [% END %] diff --git a/opac/opac-course-reserves.pl b/opac/opac-course-reserves.pl index 6518ef4..b6a18ae 100755 --- a/opac/opac-course-reserves.pl +++ b/opac/opac-course-reserves.pl @@ -38,13 +38,7 @@ my ( $template, $borrowernumber, $cookie ) = get_template_and_user( } ); -my $search_on = $cgi->param('search_on'); +my $courses = SearchCourses( enabled => 'yes' ); -my $courses = SearchCourses( term => $search_on, enabled => 'yes' ); - -if ( @$courses == 1 ) { - print $cgi->redirect( "/cgi-bin/koha/opac-course-details.pl?course_id=" . $courses->[0]->{'course_id'} ); -} else { - $template->param( courses => $courses ); - output_html_with_http_headers $cgi, $cookie, $template->output; -} +$template->param( courses => $courses ); +output_html_with_http_headers $cgi, $cookie, $template->output; -- 2.1.0