Bug 30394: Make datatables.js aware of x-koha-request-id
This patch makes the wrapper handle the data.draw parameter (from DataTables) translating it into the x-koha-request-id header for making the Koha request, and then translates the received header into data.draw for proper use in DataTables. Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io> Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org> Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com> Signed-off-by: Fridolin Somers <fridolin.somers@biblibre.com>
This commit is contained in:
parent
b25f6f1c30
commit
91c248adec
|
|
@ -538,13 +538,17 @@ jQuery.fn.dataTable.ext.errMode = function(settings, note, message) {
|
|||
},
|
||||
'dataFilter': function(data, type) {
|
||||
var json = {data: JSON.parse(data)};
|
||||
if(total = this._xhr.getResponseHeader('x-total-count')) {
|
||||
if (total = this._xhr.getResponseHeader('x-total-count')) {
|
||||
json.recordsTotal = total;
|
||||
json.recordsFiltered = total;
|
||||
}
|
||||
if(total = this._xhr.getResponseHeader('x-base-total-count')) {
|
||||
if (total = this._xhr.getResponseHeader('x-base-total-count')) {
|
||||
json.recordsTotal = total;
|
||||
}
|
||||
if (draw = this._xhr.getResponseHeader('x-koha-request-id')) {
|
||||
json.draw = draw;
|
||||
}
|
||||
|
||||
return JSON.stringify(json);
|
||||
},
|
||||
'data': function( data, settings ) {
|
||||
|
|
@ -652,6 +656,10 @@ jQuery.fn.dataTable.ext.errMode = function(settings, note, message) {
|
|||
|
||||
dataSet._match = options.criteria;
|
||||
|
||||
if ( data["draw"] !== undefined ) {
|
||||
settings.ajax.headers = { 'x-koha-request-id': data.draw }
|
||||
}
|
||||
|
||||
if(options.columns) {
|
||||
var order = data.order;
|
||||
var orderArray = new Array();
|
||||
|
|
|
|||
Loading…
Reference in New Issue