Bug 23493: (follow-up) Switch to aDataSort for multi-column sorting

This patch adds aDataSort configurations for each sortable column such
that we always maintain the group sorting primarily and apply a
secondary sort using the column in question.

Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
This commit is contained in:
Martin Renvoize 2020-01-28 17:18:44 +00:00
parent c35b997c93
commit 930fedd462
No known key found for this signature in database
GPG Key ID: 422B469130441A0F
1 changed files with 24 additions and 17 deletions

View File

@ -260,7 +260,7 @@ $(document).ready(function() {
"bVisible": false,
},
{
"iDataSort": 2, // Sort on hidden unformatted date due column
"aDataSort": [1,2], // Sort on hidden unformatted date due column
"mDataProp": function( oObj ) {
var due = oObj.date_due_formatted;
@ -344,68 +344,79 @@ $(document).ready(function() {
return title;
},
"sType": "anti-the"
"sType": "anti-the",
"aDataSort": [1, 3]
},
{
"mDataProp": function ( oObj ) {
return oObj.recordtype_description.escapeHtml();
}
},
"aDataSort": [1, 4]
},
{
"mDataProp": function ( oObj ) {
return oObj.itemtype_description.escapeHtml();
}
},
"aDataSort": [1, 5]
},
{
"mDataProp": function ( oObj ) {
return ( oObj.collection ? oObj.collection.escapeHtml() : '' );
}
},
"aDataSort": [1,6]
},
{
"mDataProp": function ( oObj ) {
return ( oObj.location ? oObj.location.escapeHtml() : '' );
}
},
"aDataSort": [1,7]
},
{
"mDataProp": function ( oObj ) {
return oObj.homebranch.escapeHtml();
}
},
"aDataSort": [1,8]
},
{
"mDataProp": "issuedate",
"bVisible": false,
},
{
"iDataSort": 9, // Sort on hidden unformatted issuedate column
"aDataSort": [1,9], // Sort on hidden unformatted issuedate column
"mDataProp": "issuedate_formatted",
},
{
"mDataProp": function ( oObj ) {
return oObj.branchname.escapeHtml();
}
},
"aDataSort": [1,11]
},
{
"mDataProp": function ( oObj ) {
return ( oObj.itemcallnumber ? oObj.itemcallnumber.escapeHtml() : '' );
}
},
"aDataSort": [1,12]
},
{
"mDataProp": function ( oObj ) {
if ( ! oObj.charge ) oObj.charge = 0;
return '<span style="text-align: right; display: block;">' + parseFloat(oObj.charge).toFixed(2) + '<span>';
}
},
"aDataSort": [1,13]
},
{
"mDataProp": function ( oObj ) {
if ( ! oObj.fine ) oObj.fine = 0;
return '<span style="text-align: right; display: block;">' + parseFloat(oObj.fine).toFixed(2) + '<span>';
}
},
"aDataSort": [1,14]
},
{
"mDataProp": function ( oObj ) {
if ( ! oObj.price ) oObj.price = 0;
return '<span style="text-align: right; display: block;">' + parseFloat(oObj.price).toFixed(2) + '<span>';
}
},
"aDataSort": [1,15]
},
{
"bSortable": false,
@ -607,10 +618,6 @@ $(document).ready(function() {
}
},
"fnInitComplete": function(oSettings, json) {
// Disable rowGrouping plugin after first use
// so any sorting on the table doesn't use it
//var oSettings = issuesTable.fnSettings();
// Build a summary of checkouts grouped by itemtype
var checkoutsByItype = json.aaData.reduce(function (obj, row) {
obj[row.type_for_stat] = (obj[row.type_for_stat] || 0) + 1;