Bugzilla – Attachment 68399 Details for
Bug 9573
Ability to download items lost report
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 9573: Lost items report - Move filters code to a separate js file
Bug-9573-Lost-items-report---Move-filters-code-to-.patch (text/plain), 8.69 KB, created by
Biblibre Sandboxes
on 2017-10-23 14:09:38 UTC
(
hide
)
Description:
Bug 9573: Lost items report - Move filters code to a separate js file
Filename:
MIME Type:
Creator:
Biblibre Sandboxes
Created:
2017-10-23 14:09:38 UTC
Size:
8.69 KB
patch
obsolete
>From d34de164a062a9e5973750791c8c287f5b344853 Mon Sep 17 00:00:00 2001 >From: Jonathan Druart <jonathan.druart@bugs.koha-community.org> >Date: Thu, 5 Oct 2017 13:15:43 -0300 >Subject: [PATCH] Bug 9573: Lost items report - Move filters code to a separate > js file >MIME-Version: 1.0 >Content-Type: text/plain; charset=UTF-8 >Content-Transfer-Encoding: 8bit > >For the next patches we will need to reuse what is already done on the >bibliographic record detail page. This patch moves the code to make it >reusable easily and avoid copy and paste. > >Signed-off-by: Katrin Fischer <katrin.fischer.83@web.de> > >Signed-off-by: Séverine QUEUNE <severine.queune@bulac.fr> >--- > .../prog/en/includes/columns_settings.inc | 23 ++++++- > .../prog/en/modules/catalogue/detail.tt | 76 ++-------------------- > koha-tmpl/intranet-tmpl/prog/js/table_filters.js | 50 ++++++++++++++ > 3 files changed, 78 insertions(+), 71 deletions(-) > create mode 100644 koha-tmpl/intranet-tmpl/prog/js/table_filters.js > >diff --git a/koha-tmpl/intranet-tmpl/prog/en/includes/columns_settings.inc b/koha-tmpl/intranet-tmpl/prog/en/includes/columns_settings.inc >index b065a35..5d674bc 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/includes/columns_settings.inc >+++ b/koha-tmpl/intranet-tmpl/prog/en/includes/columns_settings.inc >@@ -1,7 +1,7 @@ > [% USE ColumnsSettings %] > > <script type="text/javascript"> >-function KohaTable(selector, dt_parameters, columns_settings) { >+function KohaTable(id_selector, dt_parameters, columns_settings, add_filters) { > var id = 0; > var hidden_ids = []; > var included_ids = []; >@@ -25,12 +25,31 @@ function KohaTable(selector, dt_parameters, columns_settings) { > text: _("Column visibility"), > } > ]; >- var table = $(selector).dataTable($.extend(true, {}, dataTablesDefaults, dt_parameters)); >+ >+ var table = $('#' + id_selector + ' table'); >+ if ( add_filters ) { >+ // Duplicate the table header row for columnFilter >+ thead_row = table.find('thead tr'); >+ clone = thead_row.clone().addClass('filters_row'); >+ clone.find("th.NoSort").html(''); >+ thead_row.before(clone); >+ } >+ >+ table.dataTable($.extend(true, {}, dataTablesDefaults, dt_parameters)); > > $(hidden_ids).each(function(index, value) { > table.fnSetColumnVis( value, false ); > }); > >+ if ( add_filters ) { >+ // show a link to activate filtering >+ link = $('<a>') >+ .attr('href', '#') >+ .attr('id', id_selector + '_activate_filters'); >+ $("." + id_selector + "_table_controls").prepend(link); >+ deactivate_filters(id_selector); >+ } >+ > return table; > } > >diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/detail.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/detail.tt >index be5932b..2ef56d3 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/detail.tt >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/detail.tt >@@ -1041,91 +1041,29 @@ > [% INCLUDE 'datatables.inc' %] > <script type="text/javascript" src="[% interface %]/lib/jquery/plugins/jquery.dataTables.columnFilter.js"></script> > [% INCLUDE 'browser-strings.inc' %] >+ [% INCLUDE 'columns_settings.inc' %] > <script type="text/javascript" src="[% interface %]/js/browser.js"></script> >+ <script type="text/javascript" src="[% interface %]/[% theme %]/js/table_filters.js"></script> > <script type="text/javascript"> > var browser = KOHA.browser('[% searchid %]', parseInt(biblionumber, 10)); > browser.show(); > >- function activate_filters(id) { >- var table = $("#" + id + " table"); >- if (table.length == 1) { >- filters_row = table.find('thead tr.filters_row'); >- >- var aoColumns = []; >- filters_row.find('th').each(function() { >- if(this.className === "NoSort"){ >- aoColumns.push(null); >- } else { >- aoColumns.push('text'); >- } >- }); >- >- if (table.find('thead tr.columnFilter').length == 0) { >- table.dataTable().columnFilter({ >- 'sPlaceHolder': 'head:after' >- , 'aoColumns': aoColumns >- }); >- filters_row.addClass('columnFilter'); >- } >- filters_row.show(); >- } >- >- $('#' + id + '_activate_filters') >- .html('<i class="fa fa-filter"></i> ' + _("Deactivate filters") ) >- .unbind('click') >- .click(function() { >- deactivate_filters(id); >- return false; >- }); >- } >- >- function deactivate_filters(id) { >- filters_row = $("#" + id + " table").find('thead tr.filters_row'); >- >- filters_row.find('input[type="text"]') >- .val('') // Empty filter text boxes >- .trigger('keyup') // Filter (display all rows) >- .trigger('blur'); // Reset value to the column name >- filters_row.hide(); >- >- $('#' + id + '_activate_filters') >- .html('<i class="fa fa-filter"></i> ' + _("Activate filters") ) >- .unbind('click') >- .click(function() { >- activate_filters(id); >- return false; >- }); >- } >- > $(document).ready(function() { > var ids = ['holdings', 'otherholdings']; >+ > for (var i in ids) { > var id = ids[i]; >- var table = $('#' + id + ' table'); >- >- // Duplicate the table header row for columnFilter >- thead_row = table.find('thead tr'); >- clone = thead_row.clone().addClass('filters_row'); >- clone.find("th.NoSort").html(''); >- thead_row.before(clone); >- >- // Enable sorting >- table.dataTable($.extend(true, {}, dataTablesDefaults, { >+ var dt_parameters = { > 'sDom': 't', > 'bPaginate': false, > 'bAutoWidth': false, > "aoColumnDefs": [ > { "bSortable": false, "bSearchable": false, 'aTargets': [ 'NoSort' ] } > ] >- })); >- >- // Show a link to activate filtering >- link = $('<a>') >- .attr('href', '#') >- .attr('id', id + '_activate_filters'); >- $("." + id + "_table_controls").prepend(link); >- deactivate_filters(id); >+ }; >+ var table = KohaTable(id, dt_parameters, null, 'with_filters'); > } >+ > [% IF Koha.Preference('AcquisitionDetails') %] > $("#orders").dataTable($.extend(true, {}, dataTablesDefaults, { > 'sDom': 't', >diff --git a/koha-tmpl/intranet-tmpl/prog/js/table_filters.js b/koha-tmpl/intranet-tmpl/prog/js/table_filters.js >new file mode 100644 >index 0000000..a1a914a >--- /dev/null >+++ b/koha-tmpl/intranet-tmpl/prog/js/table_filters.js >@@ -0,0 +1,50 @@ >+function activate_filters(id) { >+ var table = $("#" + id + " table"); >+ if (table.length == 1) { >+ filters_row = table.find('thead tr.filters_row'); >+ >+ var aoColumns = []; >+ filters_row.find('th').each(function() { >+ if(this.className === "NoSort"){ >+ aoColumns.push(null); >+ } else { >+ aoColumns.push('text'); >+ } >+ }); >+ >+ if (table.find('thead tr.columnFilter').length == 0) { >+ table.dataTable().columnFilter({ >+ 'sPlaceHolder': 'head:after' >+ , 'aoColumns': aoColumns >+ }); >+ filters_row.addClass('columnFilter'); >+ } >+ filters_row.show(); >+ } >+ >+ $('#' + id + '_activate_filters') >+ .html('<i class="fa fa-filter"></i> ' + _("Deactivate filters") ) >+ .unbind('click') >+ .click(function() { >+ deactivate_filters(id); >+ return false; >+ }); >+} >+ >+function deactivate_filters(id) { >+ filters_row = $("#" + id + " table").find('thead tr.filters_row'); >+ >+ filters_row.find('input[type="text"]') >+ .val('') // Empty filter text boxes >+ .trigger('keyup') // Filter (display all rows) >+ .trigger('blur'); // Reset value to the column name >+ filters_row.hide(); >+ >+ $('#' + id + '_activate_filters') >+ .html('<i class="fa fa-filter"></i> ' + _("Activate filters") ) >+ .unbind('click') >+ .click(function() { >+ activate_filters(id); >+ return false; >+ }); >+} >-- >2.7.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 9573
:
68085
|
68086
|
68087
|
68088
|
68089
|
68090
|
68184
|
68283
|
68351
|
68352
|
68353
|
68354
|
68355
|
68356
|
68357
|
68358
|
68398
|
68399
|
68400
|
68401
|
68402
|
68403
|
68404
|
68405
|
71275
|
71276
|
71277
|
71278
|
71279
|
71280
|
71281
|
71282
|
71872
|
71873
|
71874
|
71875
|
71876
|
71877
|
71878
|
71879
|
71880
|
71887
|
71888
|
71889
|
71890
|
71891
|
71892
|
71893
|
71894
|
71895