Bug 7547: printing a sorted cart

This patch adds a DataTables-generated print button to the OPAC cart. To
make that process easier, the DataTables plugin has been upgraded to the
latest version (1.10.18) with the Buttons plugin included.

Changes to the OPAC LESS file style the DataTables button to look like
the static version.

Other templates in the OPAC which use the DataTables plugin have been
modified to use up-to-date option names.

To test, apply the patch and add several titles to the cart.

 - Open the cart
 - Re-sort the cart using something other than the default sort
 - Click the 'Print' button.
   - A print view should open in a separate window, sorted correctly,
     and automatically show the print dialog.
 - Click the cart's 'More details' button and click the print button.
   - This should trigger the print dialog directly.

 - Test DataTables sorting on other modified pages:
    - Bibliographic detail page (holdings table)
    - Course reserves (table of courses)
      - Course details (table of titles)
    - Full subscription history
      - Detail page for a subscription -> More details -> Full history
    - Most popular
    - Purchase suggestions
    - Self checkouts
    - Tag cloud
    - Your fines
    - Your interlibrary loan requests
    - Your reading history
    - Your search history
    - Your search IDREF for ppn (I don't know how to test this)

The DataTables plugin is removed from "Your routing lists" and Self
check-in because it is unused.

Signed-off-by: Katrin Fischer <katrin.fischer.83@web.de>

Signed-off-by: Josef Moravec <josef.moravec@gmail.com>

Signed-off-by: Nick Clemens <nick@bywatersolutions.com>
This commit is contained in:
Owen Leonard 2018-06-21 17:31:44 +00:00 committed by Nick Clemens
parent f0d9383d8d
commit 96fda97c09
21 changed files with 381 additions and 258 deletions

File diff suppressed because one or more lines are too long

View file

@ -190,8 +190,8 @@
$( document ).ready(function() {
$("#finestable").dataTable($.extend(true, {}, dataTablesDefaults, {
"aoColumnDefs": [
{ "sType": "title-string", "aTargets" : [ "title-string" ] }
"columnDefs": [
{ "type": "title-string", "targets" : [ "title-string" ] }
]
} ));

View file

@ -6,7 +6,7 @@
[% INCLUDE 'doc-head-open.inc' %]
<title>[% IF ( LibraryNameTitle ) %][% LibraryNameTitle %][% ELSE %]Koha online[% END %] catalog &rsaquo; Your cart</title>
[% INCLUDE 'doc-head-close.inc' %]
[% BLOCK cssinclude %]<style type="text/css">.item-status { display: inline; } @media print { body { height: 99%; } }</style>[% END %]
[% BLOCK cssinclude %]<style type="text/css">.item-status, .dt-buttons { display: inline; } @media print { body { height: 99%; } }</style>[% END %]
</head>
[% INCLUDE 'bodytag.inc' bodyid='basket' %]
<div class="main">
@ -25,9 +25,11 @@
<a class="send" href="opac-basket.pl">Send</a>
[% END %]
<a class="download" href="opac-basket.pl">Download</a>
<a class="print-large" href="#">Print</a>
<a class="empty" href="opac-basket.pl">Empty and close</a>
<a class="hide close" href="opac-basket.pl">Hide window</a>
[% IF ( verbose ) %]
<a class="print-large" href="#">Print</a>
[% END %]
</div>
<div id="selections-toolbar" class="toolbar">
@ -425,20 +427,27 @@
return false;
});
$("#itemst").dataTable($.extend(true, {}, dataTablesDefaults, {
"aaSorting": [[ 1, "asc" ]],
"aoColumnDefs": [
{ "aTargets": [ 0,-1 ], "bSortable": false, "bSearchable": false }
var itemst = $("#itemst").dataTable($.extend(true, {}, dataTablesDefaults, {
"order": [[ 1, "asc" ]],
"columnDefs": [
{ "targets": [ 0,-1 ], "sortable": false, "searchable": false }
],
"aoColumns": [
"columns": [
null,
{ "sType": "anti-the" },
{ "type": "anti-the" },
null,
null,
null
]
],
}));
var buttons = new $.fn.dataTable.Buttons(itemst, {
buttons: [
'print'
]
}).container().appendTo($('#toolbar'));
$(".cb").change(function(){
selRecord( $(this).val(), $(this).prop("checked") );
enableCheckboxActions();

View file

@ -108,10 +108,10 @@
<script>
$(document).ready(function() {
$("#course-items-table").dataTable($.extend(true, {}, dataTablesDefaults, {
"sDom": '<"top"flp>rt<"clear">',
"aoColumnDefs": [
{ "sType": "anti-the", "aTargets" : [ "anti-the" ] },
{ "sType": "title-string", "aTargets" : [ "title-string" ] }
"dom": '<"top"flp>rt<"clear">',
"columnDefs": [
{ "type": "anti-the", "targets" : [ "anti-the" ] },
{ "type": "title-string", "targets" : [ "title-string" ] }
]
}));
});

View file

@ -65,7 +65,7 @@
<script>
$(document).ready(function() {
$("#course_reserves_table").dataTable($.extend(true, {}, dataTablesDefaults, {
"sDom": '<"top"flp>rt<"clear">',
"dom": '<"top"flp>rt<"clear">',
}));
});
</script>

View file

@ -1453,8 +1453,8 @@
KohaTable("#holdingst", {
dom: 'B<"clearfix">t',
"columnDefs": [
{ "aTargets": [ -1 ], "bSortable": false, "bSearchable": false },
{ "sType": "title-string", "aTargets" : [ "title-string" ] }
{ "targets": [ -1 ], "sortable": false, "searchable": false },
{ "type": "title-string", "targets" : [ "title-string" ] }
],
"bKohaColumnsUseNames": true
}, columns_settings);
@ -1462,8 +1462,8 @@
KohaTable("#otherholdingst", {
dom: 'B<"clearfix">t',
"columnDefs": [
{ "aTargets": [ -1 ], "bSortable": false, "bSearchable": false },
{ "sType": "title-string", "aTargets" : [ "title-string" ] }
{ "targets": [ -1 ], "sortable": false, "searchable": false },
{ "type": "title-string", "targets" : [ "title-string" ] }
],
"bKohaColumnsUseNames": true
}, columns_settings);
@ -1473,7 +1473,7 @@
KohaTable("#subscriptionst", {
dom: 'B<"clearfix">t',
"columnDefs": [
{ "sType": "title-string", "aTargets" : [ "title-string" ] }
{ "type": "title-string", "targets" : [ "title-string" ] }
],
"bKohaColumnsUseNames": true
}, serial_column_settings);

View file

@ -160,12 +160,12 @@
$(this).addClass("currentsubtab");
});
$(".subscriptionstclass").dataTable($.extend(true, {}, dataTablesDefaults, {
"aaSorting": [[ 0, "desc" ]],
"aoColumns": [
{ "sType": "title-string" },
"order": [[ 0, "desc" ]],
"columns": [
{ "type": "title-string" },
null,
null,
{ "sType": "title-string" },
{ "type": "title-string" },
null,
null,
null

View file

@ -53,9 +53,9 @@
<script>
$(document).ready(function (){
$("table").dataTable($.extend(true, {}, dataTablesDefaults, {
'bFilter': false,
'aoColumnDefs': [
{ 'aTargets': [-1, -2], 'bSortable': false }
'filter': false,
'columnDefs': [
{ 'targets': [-1, -2], 'sortable': false }
],
}));

View file

@ -222,10 +222,10 @@
<script>
//<![CDATA[
$("#illrequestlist").dataTable($.extend(true, {}, dataTablesDefaults, {
"aoColumnDefs": [
{ "aTargets": [ -1 ], "bSortable": false, "bSearchable": false }
"columnDefs": [
{ "targets": [ -1 ], "sortable": false, "searchable": false }
],
"aaSorting": [[ 3, "desc" ]],
"order": [[ 3, "desc" ]],
"deferRender": true
}));
$("#backend-dropdown-options").removeClass("nojs");

View file

@ -189,10 +189,10 @@
var table = $("#readingrec").dataTable($.extend(true, {}, dataTablesDefaults, {
"sPaginationType": "four_button",
"aoColumnDefs": [
{ "aTargets": [ "nosort" ],"bSortable": false,"bSearchable": false },
{ "sType": "anti-the", "aTargets" : [ "anti-the" ] },
{ "sType": "title-string", "aTargets" : [ "title-string" ] }
"columnDefs": [
{ "targets": [ "nosort" ],"sortable": false,"searchable": false },
{ "type": "anti-the", "targets" : [ "anti-the" ] },
{ "type": "title-string", "targets" : [ "title-string" ] }
]
}));
var tabs = $("#tabs").tabs({

View file

@ -66,7 +66,4 @@
[% INCLUDE 'opac-bottom.inc' %]
[% BLOCK jsinclude %]
[% INCLUDE 'datatables.inc' %]
<script>
</script>
[% END %]

View file

@ -224,10 +224,10 @@
// We show table ordered by descending dates by default
// (so that the more recent query is shown first)
$(".historyt").dataTable($.extend(true, {}, dataTablesDefaults, {
"aaSorting": [[ 1, "desc" ]],
"aoColumnDefs": [
{ "aTargets": [ 0 ], "bSortable": false, "bSearchable": false },
{ "aTargets": [ 1 ], "sType": "title-string" },
"order": [[ 1, "desc" ]],
"columnDefs": [
{ "targets": [ 0 ], "sortable": false, "searchable": false },
{ "targets": [ 1 ], "type": "title-string" },
]
}));

View file

@ -294,13 +294,13 @@
$(function() {
$("#suggestt").dataTable($.extend(true, {}, dataTablesDefaults, {
"aaSorting": [[ 1, "asc" ]],
"aoColumnDefs": [
[% IF ( loggedinusername ) %]{ "aTargets": [ 0 ], "bSortable": false, "bSearchable": false }[% END %]
"order": [[ 1, "asc" ]],
"columnDefs": [
[% IF ( loggedinusername ) %]{ "targets": [ 0 ], "sortable": false, "searchable": false }[% END %]
],
"aoColumns": [
"columns": [
[% IF ( loggedinusername ) %]null,[% END %]
{ "sType": "anti-the" },
{ "type": "anti-the" },
null,
null,
[% IF Koha.Preference( 'OPACViewOthersSuggestions' ) == 1 %]null,[% END %]

View file

@ -200,14 +200,14 @@
});
$("#mytagst").dataTable($.extend(true, {}, dataTablesDefaults, {
"aaSorting": [[ 2, "asc" ]],
"aoColumnDefs": [
{ "aTargets": [ 0 ], "bSortable": false, "bSearchable": false }
"sorting": [[ 2, "asc" ]],
"columnDefs": [
{ "targets": [ 0 ], "sortable": false, "searchable": false }
],
"aoColumns": [
"columns": [
null,
{ "sType": "anti-the" },
{ "sType": "title-string" },
{ "type": "anti-the" },
{ "type": "title-string" },
null
]
}));

View file

@ -101,14 +101,14 @@
//<![CDATA[
$(function() {
$("#topissuest").dataTable($.extend(true, {}, dataTablesDefaults, {
"aaSorting": [ [2, "desc"], [0, "asc"] ],
"aoColumnDefs": [
[% IF ( opacuserlogin ) %]{ "aTargets": [ -1 ], "bSortable": false, "bSearchable": false }[% END %]
"sorting": [ [2, "desc"], [0, "asc"] ],
"columnDefs": [
[% IF ( opacuserlogin ) %]{ "targets": [ -1 ], "sortable": false, "searchable": false }[% END %]
],
"aoColumns": [
{ "sType": "anti-the" },
"columns": [
{ "type": "anti-the" },
null,
{ "sType": "title-numeric" },
{ "type": "title-numeric" },
[% IF ( opacuserlogin ) %]null,[% END %]
]
}));

View file

@ -911,11 +911,11 @@
dTables.each(function(){
var thIndex = $(this).find("th.psort").index();
$(this).dataTable($.extend(true, {}, dataTablesDefaults, {
"aaSorting" : [[ thIndex, 'asc' ]],
"aoColumnDefs": [
{ "aTargets": [ "nosort" ],"bSortable": false,"bSearchable": false },
{ "sType": "anti-the", "aTargets" : [ "anti-the" ] },
{ "sType": "title-string", "aTargets" : [ "title-string" ] }
"sorting" : [[ thIndex, 'asc' ]],
"columnDefs": [
{ "targets": [ "nosort" ],"sortable": false,"searchable": false },
{ "type": "anti-the", "targets" : [ "anti-the" ] },
{ "type": "title-string", "targets" : [ "title-string" ] }
]
}));
});

View file

@ -195,7 +195,6 @@
[% INCLUDE 'opac-bottom.inc' %]
[% BLOCK jsinclude %]
[% INCLUDE 'datatables.inc' %]
<script>
function mungeHistory() {
@ -221,7 +220,7 @@
var barcode = $('#barcode_input').val();
//var result = validate_barcode( barcode );
$('#sci_barcodes_table tbody').append(
'<tr stype="font-size: initial;"><td>' +
'<tr style="font-size: initial;"><td>' +
barcode +
'<input type="hidden" name="barcode" value="' + barcode + '" />' +
'</td></tr>' );

View file

@ -392,12 +392,12 @@
dofocus();
[% IF ( patronid ) %]sco_init();[% END %]
$("#loanTable").dataTable($.extend(true, {}, dataTablesDefaults, {
"aaSorting": [ 0 ],
"aoColumnDefs": [
{ "aTargets": [ "nosort" ], "bSortable": false, "bSearchable": false },
{ "aTargets": [ "noshow" ], "bVisible": false, "bSearchable": false },
{ "sType": "anti-the", "aTargets" : [ "anti-the" ] },
{ "sType": "title-string", "aTargets" : [ "title-string" ] }
"order": [ 0 ],
"columnDefs": [
{ "targets": [ "nosort" ], "sortable": false, "searchable": false },
{ "targets": [ "noshow" ], "visible": false, "searchable": false },
{ "type": "anti-the", "targets" : [ "anti-the" ] },
{ "type": "title-string", "targets" : [ "title-string" ] }
]
}));

View file

@ -6,26 +6,26 @@
// // other settings
// } ) );
var dataTablesDefaults = {
"oLanguage": {
"oPaginate": {
"sFirst" : window.MSG_DT_FIRST || "First",
"sLast" : window.MSG_DT_LAST || "Last",
"sNext" : window.MSG_DT_NEXT || "Next",
"sPrevious" : window.MSG_DT_PREVIOUS || "Previous"
"language": {
"paginate": {
"first" : window.MSG_DT_FIRST || "First",
"last" : window.MSG_DT_LAST || "Last",
"next" : window.MSG_DT_NEXT || "Next",
"previous" : window.MSG_DT_PREVIOUS || "Previous"
},
"sEmptyTable" : window.MSG_DT_EMPTY_TABLE || "No data available in table",
"sInfo" : window.MSG_DT_INFO || "Showing _START_ to _END_ of _TOTAL_ entries",
"sInfoEmpty" : window.MSG_DT_INFO_EMPTY || "No entries to show",
"sInfoFiltered" : window.MSG_DT_INFO_FILTERED || "(filtered from _MAX_ total entries)",
"sLengthMenu" : window.MSG_DT_LENGTH_MENU || "Show _MENU_ entries",
"sLoadingRecords" : window.MSG_DT_LOADING_RECORDS || "Loading...",
"sProcessing" : window.MSG_DT_PROCESSING || "Processing...",
"sSearch" : window.MSG_DT_SEARCH || "Search:",
"sZeroRecords" : window.MSG_DT_ZERO_RECORDS || "No matching records found"
"emptyTable" : window.MSG_DT_EMPTY_TABLE || "No data available in table",
"info" : window.MSG_DT_INFO || "Showing _START_ to _END_ of _TOTAL_ entries",
"infoEmpty" : window.MSG_DT_INFO_EMPTY || "No entries to show",
"infoFiltered" : window.MSG_DT_INFO_FILTERED || "(filtered from _MAX_ total entries)",
"lengthMenu" : window.MSG_DT_LENGTH_MENU || "Show _MENU_ entries",
"loadingRecords" : window.MSG_DT_LOADING_RECORDS || "Loading...",
"processing" : window.MSG_DT_PROCESSING || "Processing...",
"search" : window.MSG_DT_SEARCH || "Search:",
"zeroRecords" : window.MSG_DT_ZERO_RECORDS || "No matching records found"
},
// "aaSorting": [$(" - select row position of th -")],
"sDom": 't',
"bPaginate": false,
// "sorting": [$(" - select row position of th -")],
"dom": 't',
"paginate": false,
// "fnHeaderCallback": function() {
// return $('th.sorting.nosort,th.sorting_desc.nosort,th.sorting_asc.nosort').removeClass("sorting sorting_desc sorting_asc").unbind("click");
// }
@ -36,12 +36,12 @@ var dataTablesDefaults = {
* Ex: <td><span title="[% ISO_date %]">[% formatted_date %]</span></td>
*
* In DataTables config:
* "aoColumns": [
* { "sType": "title-string" },
* "columns": [
* { "type": "title-string" },
* ]
* http://datatables.net/plug-ins/sorting#hidden_title_string
*/
jQuery.extend( jQuery.fn.dataTableExt.oSort, {
jQuery.extend( jQuery.fn.dataTableExt.sort, {
"title-string-pre": function ( a ) {
return a.match(/title="(.*?)"/)[1].toLowerCase();
},
@ -60,14 +60,13 @@ jQuery.extend( jQuery.fn.dataTableExt.oSort, {
* Ex: <td><span title="[% total %]">Total: [% total %]</span></td>
*
* In DataTables config:
* "aoColumns": [
* { "sType": "title-numeric" }
* "columns": [
* { "type": "title-numeric" }
* ]
* http://legacy.datatables.net/plug-ins/sorting#hidden_title
*/
jQuery.extend( jQuery.fn.dataTableExt.oSort, {
jQuery.extend( jQuery.fn.dataTableExt.sort, {
"title-numeric-pre": function ( a ) {
console.log(a);
var x = a.match(/title="*(-?[0-9\.]+)/)[1];
return parseFloat( x );
},
@ -86,8 +85,8 @@ jQuery.extend( jQuery.fn.dataTableExt.oSort, {
/* Plugin to allow text sorting to ignore articles
*
* In DataTables config:
* "aoColumns": [
* { "sType": "anti-the" },
* "columns": [
* { "type": "anti-the" },
* ]
* Based on the plugin found here:
* http://datatables.net/plug-ins/sorting#anti_the
@ -106,7 +105,7 @@ jQuery.extend( jQuery.fn.dataTableExt.oSort, {
var re = new RegExp(rpattern, "i");
}
jQuery.extend( jQuery.fn.dataTableExt.oSort, {
jQuery.extend( jQuery.fn.dataTableExt.sort, {
"anti-the-pre": function ( a ) {
var x = String(a).replace( /<[\s\S]*?>/g, "" );
var y = x.trim();

View file

@ -1336,7 +1336,8 @@ input.hold.disabled,
input.editshelf,
.newshelf,
.newshelf.disabled,
.deleteshelf {
.deleteshelf,
.buttons-print {
background-image: url("../images/sprite.png");
background-repeat: no-repeat;
}
@ -1439,8 +1440,9 @@ a.print-small {
padding-left : 30px;
}
a.print-large {
background-position : -5px -186px; /* Toolbar print */
a.print-large,
.buttons-print {
background-position : 0 -187px; /* Toolbar print */
text-decoration : none;
padding-left : 35px;
}
@ -1574,6 +1576,13 @@ input.editshelf {
}
}
.buttons-print {
background-position-y: -184px;
border: 0;
color: #0076B2;
font-size: 100%;
}
.branch-info-tooltip {
display: none;
}

File diff suppressed because one or more lines are too long