Browse Source

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>
Signed-off-by: Tomas Cohen Arazi <tomascohen@gmail.com>
3.18.x
Kyle Hall 10 years ago
committed by Tomas Cohen Arazi
parent
commit
4413a1ac4a
  1. 15
      koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-course-details.tt
  2. 23
      koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-course-reserves.tt
  3. 12
      opac/opac-course-reserves.pl

15
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 &rsaquo; 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 %]

23
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 &rsaquo; 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 %]

12
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;

Loading…
Cancel
Save