From a6709dcb05475e2768a2b829147aa4b6148a9a12 Mon Sep 17 00:00:00 2001 From: Martin Renvoize Date: Tue, 28 Jan 2020 17:18:44 +0000 Subject: [PATCH] Bug 24533: 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. When sorting by due date you are much more likely to want the true date sorting without forcing a primary sort on the grouping column. We achieve that by removing the primary sort on checkout date and disable rowGrouping in such a case. --- koha-tmpl/intranet-tmpl/prog/js/checkouts.js | 45 ++++++++++++++------ 1 file changed, 33 insertions(+), 12 deletions(-) diff --git a/koha-tmpl/intranet-tmpl/prog/js/checkouts.js b/koha-tmpl/intranet-tmpl/prog/js/checkouts.js index 31589a396d..99475a112f 100644 --- a/koha-tmpl/intranet-tmpl/prog/js/checkouts.js +++ b/koha-tmpl/intranet-tmpl/prog/js/checkouts.js @@ -345,68 +345,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 ? oObj.homebranch.escapeHtml() : '' ); - } + }, + "aDataSort": [1,8] }, { "mDataProp": "issuedate", "bVisible": false, }, { - "iDataSort": 10, // Sort on hidden unformatted issuedate column + "aDataSort": [1,10], // Sort on hidden unformatted issuedate column "mDataProp": "issuedate_formatted", }, { "mDataProp": function ( oObj ) { return (oObj.branchname ? 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 '' + parseFloat(oObj.charge).toFixed(2) + ''; - } + }, + "aDataSort": [1,13] }, { "mDataProp": function ( oObj ) { if ( ! oObj.fine ) oObj.fine = 0; return '' + parseFloat(oObj.fine).toFixed(2) + ''; - } + }, + "aDataSort": [1,14] }, { "mDataProp": function ( oObj ) { if ( ! oObj.price ) oObj.price = 0; return '' + parseFloat(oObj.price).toFixed(2) + ''; - } + }, + "aDataSort": [1,15] }, { "bSortable": false, @@ -634,6 +645,16 @@ $(document).ready(function() { collision: "none" }); } + + // Disable rowGroup when sorting on due date + $("#issues-table").on( 'order.dt', function(){ + var order = issuesTable.api().order(); + if ( order[0][0] === 3 ) { + issuesTable.api().rowGroup().disable(); + } else { + issuesTable.api().rowGroup().enable(); + } + }); } // Don't load relatives' issues table unless it is clicked on -- 2.20.1