Bugzilla – Attachment 34515 Details for
Bug 13419
Add filters and server-side processing to the shelves list view
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
[Signed-off] Bug 13419: Add filters on the list table
Bug-13419-Add-filters-on-the-list-table.patch (text/plain), 7.12 KB, created by
Marc Véron
on 2014-12-18 13:46:25 UTC
(
hide
)
Description:
[Signed-off] Bug 13419: Add filters on the list table
Filename:
MIME Type:
Creator:
Marc Véron
Created:
2014-12-18 13:46:25 UTC
Size:
7.12 KB
patch
obsolete
>From f5d5c4317ebda20591cf0c98c91938d371214391 Mon Sep 17 00:00:00 2001 >From: Jonathan Druart <jonathan.druart@biblibre.com> >Date: Mon, 8 Dec 2014 14:01:54 +0100 >Subject: [PATCH] Bug 13419: Add filters on the list table >MIME-Version: 1.0 >Content-Type: text/plain; charset=UTF-8 >Content-Transfer-Encoding: 8bit > >Tested together with patch #1, works as expected >Signed-off-by: Marc Véron <veron@veron.ch> >--- > C4/Utils/DataTables/VirtualShelves.pm | 23 +++++--------- > koha-tmpl/intranet-tmpl/prog/en/js/datatables.js | 3 ++ > .../prog/en/modules/virtualshelves/shelves.tt | 32 ++++++++++++++++++-- > .../virtualshelves/tables/shelves_results.tt | 2 +- > 4 files changed, 41 insertions(+), 19 deletions(-) > >diff --git a/C4/Utils/DataTables/VirtualShelves.pm b/C4/Utils/DataTables/VirtualShelves.pm >index 56bb280..6b51cef 100644 >--- a/C4/Utils/DataTables/VirtualShelves.pm >+++ b/C4/Utils/DataTables/VirtualShelves.pm >@@ -61,24 +61,20 @@ sub search { > > if ( defined $shelfname and $shelfname ne '' ) { > push @where_strs, 'shelfname LIKE ?'; >- push @args, 'shelfname%'; >- } >- if ( defined $count and $count ne '' ) { >- push @where_strs, 'count = ?'; >- push @args, $count; >+ push @args, "%$shelfname%"; > } > if ( defined $owner and $owner ne '' ) { >- push @where_strs, 'owner LIKE ?'; >- push @args, 'owner%'; >- # FIXME search borronumber by name?? >+ #push @where_strs, 'owner LIKE ?'; >+ #push @args, "$owner%"; > # WHERE category=1 AND (vs.owner=? OR sh.borrowernumber=?); >+ push @where_strs, '( bo.firstname LIKE ? OR bo.surname LIKE ? )'; >+ push @args, "%$owner%", "%$owner%"; > } > if ( defined $sortby and $sortby ne '' ) { > push @where_strs, 'sortfield = ?'; >- push @args, 'sortfield'; >+ push @args, $sortby; > } > >- > push @where_strs, 'category = ?'; > push @args, $type; > >@@ -90,7 +86,7 @@ sub search { > my $where; > $where = " WHERE " . join (" AND ", @where_strs) if @where_strs; > my $orderby = dt_build_orderby($dt_params); >- $orderby =~ s|shelfnumber|vs.shelfnumber|; >+ $orderby =~ s|shelfnumber|vs.shelfnumber| if $orderby; > > my $limit; > # If iDisplayLength == -1, we want to display all shelves >@@ -114,10 +110,7 @@ sub search { > ($orderby ? $orderby : ""), > ($limit ? $limit : "") > ); >- my $sth = $dbh->prepare($query); >- $sth->execute(@args); >- >- my $shelves = $sth->fetchall_arrayref({}); >+ my $shelves = $dbh->selectall_arrayref( $query, { Slice => {} }, @args ); > > # Get the iTotalDisplayRecords DataTable variable > $query = "SELECT COUNT(vs.shelfnumber) " . $from_total . ($where ? $where : ""); >diff --git a/koha-tmpl/intranet-tmpl/prog/en/js/datatables.js b/koha-tmpl/intranet-tmpl/prog/en/js/datatables.js >index b3d97fe..e42918c 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/js/datatables.js >+++ b/koha-tmpl/intranet-tmpl/prog/en/js/datatables.js >@@ -130,6 +130,9 @@ jQuery.fn.dataTableExt.oApi.fnAddFilters = function ( oSettings, sClass, iDelay > }, iDelay); > } > }); >+ $(table).find("select."+sClass).on('change', function() { >+ table.fnFilter($(this).val(), $(this).attr('data-column_num')); >+ }); > } > > // Useful if you want to filter on dates with 2 inputs (start date and end date) >diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/virtualshelves/shelves.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/virtualshelves/shelves.tt >index 7460d1c..a51f6b2 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/virtualshelves/shelves.tt >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/virtualshelves/shelves.tt >@@ -3,6 +3,7 @@ > [% INCLUDE 'doc-head-close.inc' %] > <link rel="stylesheet" type="text/css" href="[% themelang %]/css/datatables.css" /> > [% INCLUDE 'datatables.inc' %] >+<script type="text/javascript" src="[% interface %]/lib/jquery/plugins/jquery.dataTables.columnFilter.js"></script> > [% IF ( viewshelf ) %] > <script type="text/javascript" src="[% interface %]/lib/jquery/plugins/jquery.checkboxes.min.js"></script> > <script type="text/javascript" src="[% interface %]/lib/jquery/plugins/jquery.fixFloat.js"></script> >@@ -24,8 +25,16 @@ $(document).ready(function(){ > aoData.push({ > 'name': 'type', > 'value': type, >- }, >- { >+ },{ >+ 'name': 'shelfname', >+ 'value': $("#searchshelfname_filter").val(), >+ },{ >+ 'name': 'owner', >+ 'value': $("#searchowner_filter").val(), >+ },{ >+ 'name': 'sortby', >+ 'value': $("#searchsortby_filter").val(), >+ },{ > 'name': 'template_path', > 'value': 'virtualshelves/tables/shelves_results.tt', > }); >@@ -52,8 +61,9 @@ $(document).ready(function(){ > ], > 'bAutoWidth': false, > 'sPaginationType': 'full_numbers', >+ 'bFilter': false, > "bProcessing": true, >- 'bFilter': false >+ "bSortCellsTop": true > })); > > dtListResults.fnAddFilters("filter", 750); >@@ -595,6 +605,22 @@ function placeHold () { > <th>Sort by</th> > <th>Actions</th> > </tr> >+ <tr class="filters_row"> >+ <th></th> >+ <th><input class="filter text_filter" id="searchshelfname_filter" placeholder="List name"></th> >+ <th></th> >+ <th><input class="filter text_filter" id="searchowner_filter" placeholder="Owner"></th> >+ <th> >+ <select class="filter text_filter" id="searchsortby_filter"> >+ <option value=""></option> >+ <option value="title">Title</option> >+ <option value="author">Author</option> >+ <option value="copyrightdate">Copyrightdate</option> >+ <option value="itemcallnumber">Call number</option> >+ </select> >+ </th> >+ <th></th> >+ </tr> > </thead> > <tbody></tbody> > </table> >diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/virtualshelves/tables/shelves_results.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/virtualshelves/tables/shelves_results.tt >index 6d4d730..f29be39 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/virtualshelves/tables/shelves_results.tt >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/virtualshelves/tables/shelves_results.tt >@@ -8,7 +8,7 @@ > "dt_type": > "[% data.type %]", > "dt_shelfname": >- "<a href='cgi-bin/koha/virtualshelves/shelves.pl?viewshelf=[% data.shelfnumber %]'>[% data.shelfname %]</a>", >+ "<a href='/cgi-bin/koha/virtualshelves/shelves.pl?viewshelf=[% data.shelfnumber %]'>[% data.shelfname %]</a>", > "dt_count": > "[% data.count %] item(s)", > "dt_owner": >-- >1.7.10.4
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 13419
:
34241
|
34242
|
34243
|
34504
|
34514
|
34515
|
34516
|
34517
|
34518
|
34577
|
34578
|
34579
|
34580
|
38188
|
38189
|
38190
|
38191
|
38193
|
38194
|
38195
|
38196
|
38347
|
38355