Lines 523-529
jQuery.fn.dataTable.ext.errMode = function(settings, note, message) {
Link Here
|
523 |
* details |
523 |
* details |
524 |
* @param {string} [options.criteria=contains] A koha specific extension to the dataTables settings block that |
524 |
* @param {string} [options.criteria=contains] A koha specific extension to the dataTables settings block that |
525 |
* allows setting the 'comparison operator' used in searches |
525 |
* allows setting the 'comparison operator' used in searches |
526 |
* Supports `contains`, `starts_with`, `ends_with` and `exact` match |
526 |
* Supports `contains`, `starts_with`, `ends_with` and `exact` string |
|
|
527 |
* matches and `before`, `after` and `between` date matches. `between` |
528 |
* expects a string of the form `start:end` in ISO date format and if |
529 |
* only `start` is passed will fall back to act as an `after` match. |
527 |
* @param {string} [options.columns.*.criteria] As above, but at the column definition level |
530 |
* @param {string} [options.columns.*.criteria] As above, but at the column definition level |
528 |
* @param {Object} column_settings The arrayref as returned by TableSettings.GetColums function |
531 |
* @param {Object} column_settings The arrayref as returned by TableSettings.GetColums function |
529 |
* available from the columns_settings template toolkit include |
532 |
* available from the columns_settings template toolkit include |
Lines 539-545
jQuery.fn.dataTable.ext.errMode = function(settings, note, message) {
Link Here
|
539 |
} |
542 |
} |
540 |
|
543 |
|
541 |
if(options) { |
544 |
if(options) { |
542 |
if(!options.criteria || ['contains', 'starts_with', 'ends_with', 'exact'].indexOf(options.criteria.toLowerCase()) === -1) options.criteria = 'contains'; |
545 |
if(!options.criteria || ['contains', 'starts_with', 'ends_with', 'exact', 'before', 'after', 'between'].indexOf(options.criteria.toLowerCase()) === -1) options.criteria = 'contains'; |
543 |
options.criteria = options.criteria.toLowerCase(); |
546 |
options.criteria = options.criteria.toLowerCase(); |
544 |
settings = $.extend(true, {}, dataTablesDefaults, { |
547 |
settings = $.extend(true, {}, dataTablesDefaults, { |
545 |
'deferRender': true, |
548 |
'deferRender': true, |
Lines 585-590
jQuery.fn.dataTable.ext.errMode = function(settings, note, message) {
Link Here
|
585 |
_per_page: length |
588 |
_per_page: length |
586 |
}; |
589 |
}; |
587 |
|
590 |
|
|
|
591 |
function build_between(value) { |
592 |
var [start, end] = value.split(':'); |
593 |
if (typeof end !== 'undefined') { |
594 |
return {'>=': start, '<=': end}; |
595 |
} else { |
596 |
return { '>=': start }; |
597 |
} |
598 |
} |
588 |
|
599 |
|
589 |
function build_query(col, value){ |
600 |
function build_query(col, value){ |
590 |
var parts = []; |
601 |
var parts = []; |
Lines 595-600
jQuery.fn.dataTable.ext.errMode = function(settings, note, message) {
Link Here
|
595 |
var criteria = col.criteria || options.criteria; |
606 |
var criteria = col.criteria || options.criteria; |
596 |
part[!attr.includes('.')?'me.'+attr:attr] = criteria === 'exact' |
607 |
part[!attr.includes('.')?'me.'+attr:attr] = criteria === 'exact' |
597 |
? value |
608 |
? value |
|
|
609 |
: criteria === 'before' |
610 |
? { '<=': value } |
611 |
: criteria === 'after' |
612 |
? { '>=': value } |
613 |
: criteria === 'between' |
614 |
? build_between(value) |
598 |
: {like: (['contains', 'ends_with'].indexOf(criteria) !== -1?'%':'') + value + (['contains', 'starts_with'].indexOf(criteria) !== -1?'%':'')}; |
615 |
: {like: (['contains', 'ends_with'].indexOf(criteria) !== -1?'%':'') + value + (['contains', 'starts_with'].indexOf(criteria) !== -1?'%':'')}; |
599 |
parts.push(part); |
616 |
parts.push(part); |
600 |
} |
617 |
} |
601 |
- |
|
|