Bugzilla – Attachment 115929 Details for
Bug 27005
Adding a filter in the datatable of opac-readingrecord page
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 27005: (follow-up) Enable the exclusion of columns from export
Bug-27005-follow-up-Enable-the-exclusion-of-column.patch (text/plain), 7.93 KB, created by
David Nind
on 2021-01-28 10:49:20 UTC
(
hide
)
Description:
Bug 27005: (follow-up) Enable the exclusion of columns from export
Filename:
MIME Type:
Creator:
David Nind
Created:
2021-01-28 10:49:20 UTC
Size:
7.93 KB
patch
obsolete
>From fd1fa4a864f586a4d9a40c0a8aafe0f6883423e7 Mon Sep 17 00:00:00 2001 >From: Owen Leonard <oleonard@myacpl.org> >Date: Wed, 27 Jan 2021 11:48:47 +0000 >Subject: [PATCH] Bug 27005: (follow-up) Enable the exclusion of columns from > export > >This patch copies code from the staff interface which allows us to add a >class to table columns which should not be included in print or export >operations. The hidden column which facilitates the "Checkouts" and >"On-site checkouts" tabs can now be hidden in prints and exports. > >To test, apply the patch and follow the previous test plan. When testing >the export and print buttons, confirm that the column with >"standard_checkout" data is not included. > >Signed-off-by: David Nind <david@davidnind.com> >--- > .../bootstrap/en/includes/columns_settings.inc | 104 +++++++++++++++++++-- > .../bootstrap/en/modules/opac-readingrecord.tt | 18 ++-- > 2 files changed, 104 insertions(+), 18 deletions(-) > >diff --git a/koha-tmpl/opac-tmpl/bootstrap/en/includes/columns_settings.inc b/koha-tmpl/opac-tmpl/bootstrap/en/includes/columns_settings.inc >index 97f201be30..2e702e1678 100644 >--- a/koha-tmpl/opac-tmpl/bootstrap/en/includes/columns_settings.inc >+++ b/koha-tmpl/opac-tmpl/bootstrap/en/includes/columns_settings.inc >@@ -19,18 +19,108 @@ function KohaTable(selector, dt_parameters, columns_settings) { > } > id++; > }); >+ >+ // By default we include all visible columns in exports and print unless they have the "noExport" class >+ var exportColumns = ":visible:not(.noExport)"; >+ if( dt_parameters.hasOwnProperty("exportColumns") ){ >+ // A custom buttons configuration has been passed from the page >+ exportColumns = dt_parameters["exportColumns"]; >+ } >+ // Data which has the "noExport" class should not appear in print or export >+ var export_format = { >+ body: function ( data, row, column, node ) { >+ var newnode = $(node); >+ >+ if ( newnode.find(".noExport").length > 0 ) { >+ newnode = newnode.clone(); >+ newnode.find(".noExport").remove(); >+ } >+ >+ return newnode.text().replace( /\n/g, ' ' ).trim(); >+ } >+ } >+ >+ // Add a "Clear filter" button to table filter form field > dt_parameters[ "buttons" ] = [ > { >- extend: 'colvis', >- columns: included_ids, >- text: _("Column visibility"), >+ fade: 100, >+ className: "dt_button_clear_filter", >+ titleAttr: _("Clear filter"), >+ enabled: false, >+ text: '<i class="fa fa-lg fa-remove"></i> <span class="dt-button-text">' + _("Clear filter") + '</span>', >+ action: function ( e, dt, node, config ) { >+ dt.search( "" ).draw("page"); >+ node.addClass("disabled"); >+ } >+ }, >+ { >+ extend: 'csvHtml5', >+ text: _("CSV"), >+ exportOptions: { >+ columns: exportColumns, >+ format: export_format >+ }, >+ }, >+ { >+ extend: 'copyHtml5', >+ text: _("Copy"), >+ exportOptions: { >+ columns: exportColumns, >+ format: export_format >+ }, >+ }, >+ { >+ extend: 'print', >+ text: _("Print"), >+ exportOptions: { >+ columns: exportColumns, >+ format: export_format >+ }, > } > ]; >- var table = $(selector).dataTable($.extend(true, {}, dataTablesDefaults, dt_parameters)); > >- $(hidden_ids).each(function(index, value) { >- table.fnSetColumnVis( value, false ); >- }); >+ if( included_ids.length > 0 ){ >+ dt_parameters[ "buttons" ].push( >+ { >+ extend: 'colvis', >+ fade: 100, >+ columns: included_ids, >+ className: "columns_controls", >+ titleAttr: _("Columns settings"), >+ text: '<i class="fa fa-lg fa-gear"></i> <span class="dt-button-text">' + _("Columns") + '</span>', >+ exportOptions: { >+ columns: exportColumns >+ } >+ } >+ ); >+ } >+ >+ var table = $(selector); >+ var new_parameters = {} >+ $.extend(true, new_parameters, dataTablesDefaults, dt_parameters); >+ var default_column_defs = [ >+ { "aTargets": ["title-string"], "sType": "title-string" }, >+ { "aTargets": ["string-sort"], "sType": "string" }, >+ { "aTargets": ["anti-the"], "sType": "anti-the" }, >+ { "aTargets": ["NoSort"], "bSortable": false, "bSearchable": false }, >+ ]; >+ if (new_parameters["aoColumnDefs"] === undefined) { >+ new_parameters["aoColumnDefs"] = default_column_defs; >+ } else { >+ $.extend(true, new_parameters, default_column_defs); >+ } >+ >+ table.dataTable(new_parameters); >+ table.DataTable().on("column-visibility.dt", function () { >+ if (typeof columnsInit == 'function') { >+ // This function can be created separately and used to trigger >+ // an event after the DataTable has loaded AND column visibility >+ // has been updated according to the table's configuration >+ columnsInit(); >+ } >+ }).columns(hidden_ids).visible(false); >+ >+ $(".dt_button_clear_filter, .columns_controls, .export_controls").tooltip(); > > return table; > } >diff --git a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-readingrecord.tt b/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-readingrecord.tt >index 5cabd8f6a6..668e8680b9 100644 >--- a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-readingrecord.tt >+++ b/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-readingrecord.tt >@@ -1,6 +1,7 @@ > [% USE raw %] > [% USE Koha %] > [% USE KohaDates %] >+[% USE TablesSettings %] > [% INCLUDE 'doc-head-open.inc' %] > <title>[% IF ( LibraryNameTitle ) %][% LibraryNameTitle | html %][% ELSE %]Koha online[% END %] catalog › Your checkout history</title> > [% INCLUDE 'doc-head-close.inc' %] >@@ -85,8 +86,8 @@ > <table id="readingrec" class="table table-bordered table-striped"> > <thead> > <tr> >- <th style="display:none;">Type</th> >- <th class="nosort"></th> >+ <th style="display:none;" class="noExport">Type</th> >+ <th class="NoSort noExport"></th> > <th class="anti-the">Title</th> > <th>Item type</th> > <th>Call no.</th> >@@ -202,6 +203,7 @@ > [% INCLUDE 'opac-bottom.inc' %] > [% BLOCK jsinclude %] > [% INCLUDE 'datatables.inc' %] >+[% INCLUDE 'columns_settings.inc' %] > <script> > $(document).ready(function(){ > [% IF ( GoogleJackets ) %]KOHA.Google.GetCoverFromIsbn();[% END %] >@@ -209,21 +211,15 @@ > $('#sortform').submit(); > }); > >- var table = $("#readingrec").dataTable($.extend(true, {}, dataTablesDefaults, { >+ var columns_settings = []; // Empty because there are no columns we want to be configurable >+ var table = KohaTable("#readingrec", { > "dom": '<"top"<"table_entries"i><"table_controls"fB>>t', >- "sorting": [[ 1, "asc" ]], > "autoWidth": false, >- >- "columnDefs": [ >- { "targets": [ "nosort" ],"sortable": false,"searchable": false }, >- { "type": "anti-the", "targets" : [ "anti-the" ] }, >- { "type": "title-string", "targets" : [ "title-string" ] } >- ], > "language": { > "search": "_INPUT_", > "searchPlaceholder": _("Search") > } >- })); >+ }, columns_settings); > > var tabs = $("#tabs").tabs({ > activate: function(e, ui) { >-- >2.11.0
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 27005
:
113570
|
115683
|
115737
|
115877
|
115878
|
115928
|
115929
|
115930
|
116020
|
116199
|
116200
|
116201
|
116202