Bugzilla – Attachment 104425 Details for
Bug 24561
Add a datatables API wrapper
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 24561: (follow-up) Set default matching criteria to 'contains' and add configuration option
Bug-24561-follow-up-Set-default-matching-criteria-.patch (text/plain), 4.95 KB, created by
Jonathan Druart
on 2020-05-06 14:12:03 UTC
(
hide
)
Description:
Bug 24561: (follow-up) Set default matching criteria to 'contains' and add configuration option
Filename:
MIME Type:
Creator:
Jonathan Druart
Created:
2020-05-06 14:12:03 UTC
Size:
4.95 KB
patch
obsolete
>From 9c7236e435b3e35cfc25c46881e076c0b04b4a8a Mon Sep 17 00:00:00 2001 >From: Agustin Moyano <agustinmoyano@theke.io> >Date: Thu, 30 Apr 2020 11:20:05 -0300 >Subject: [PATCH] Bug 24561: (follow-up) Set default matching criteria to > 'contains' and add configuration option > >This patch adds option.criteria as an option. Possible values are >'contains', 'starts_with', 'ends_with' and 'exact'. 'contains' is the >default value. > >Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org> >--- > koha-tmpl/intranet-tmpl/prog/js/datatables.js | 7 +++++-- > koha-tmpl/opac-tmpl/bootstrap/js/datatables.js | 7 +++++-- > 2 files changed, 10 insertions(+), 4 deletions(-) > >diff --git a/koha-tmpl/intranet-tmpl/prog/js/datatables.js b/koha-tmpl/intranet-tmpl/prog/js/datatables.js >index a48112eda5..055bb74b56 100644 >--- a/koha-tmpl/intranet-tmpl/prog/js/datatables.js >+++ b/koha-tmpl/intranet-tmpl/prog/js/datatables.js >@@ -512,6 +512,8 @@ jQuery.fn.dataTable.ext.errMode = function(settings, note, message) { > $.fn.api = function(options) { > var settings = null; > if(options) { >+ if(!options.criteria || ['contains', 'starts_with', 'ends_with', 'exact'].indexOf(options.criteria.toLowerCase()) === -1) options.criteria = 'contains'; >+ options.criteria = options.criteria.toLowerCase(); > settings = $.extend(true, {}, dataTablesDefaults, { > 'deferRender': true, > "paging": true, >@@ -556,7 +558,8 @@ jQuery.fn.dataTable.ext.errMode = function(settings, note, message) { > }) > .map(function(col) { > var part = {}; >- part[!col.data.includes('.')?'me.'+col.data:col.data] = {like: (data.columns[col.idx].search.value != '' ? data.columns[col.idx].search.value : filter)+'%'}; >+ var value = data.columns[col.idx].search.value != '' ? data.columns[col.idx].search.value : filter; >+ part[!col.data.includes('.')?'me.'+col.data:col.data] = options.criteria === 'exact'?value:{like: (['contains', 'ends_with'].indexOf(options.criteria) !== -1?'%':'')+value+(['contains', 'starts_with'].indexOf(options.criteria) !== -1?'%':'')}; > return part; > }); > >@@ -572,7 +575,7 @@ jQuery.fn.dataTable.ext.errMode = function(settings, note, message) { > delete options.query_parameters; > } > >- dataSet._match = 'starts_with'; >+ dataSet._match = options.criteria; > > if(options.columns) { > var order = data.order; >diff --git a/koha-tmpl/opac-tmpl/bootstrap/js/datatables.js b/koha-tmpl/opac-tmpl/bootstrap/js/datatables.js >index 10dac7cd00..047fa4c438 100644 >--- a/koha-tmpl/opac-tmpl/bootstrap/js/datatables.js >+++ b/koha-tmpl/opac-tmpl/bootstrap/js/datatables.js >@@ -133,6 +133,8 @@ jQuery.fn.dataTable.ext.errMode = function(settings, note, message) { > $.fn.api = function(options) { > var settings = null; > if(options) { >+ if(!options.criteria || ['contains', 'starts_with', 'ends_with', 'exact'].indexOf(options.criteria.toLowerCase()) === -1) options.criteria = 'contains'; >+ options.criteria = options.criteria.toLowerCase(); > settings = $.extend(true, {}, dataTablesDefaults, { > 'deferRender': true, > "paging": true, >@@ -177,7 +179,8 @@ jQuery.fn.dataTable.ext.errMode = function(settings, note, message) { > }) > .map(function(col) { > var part = {}; >- part[!col.data.includes('.')?'me.'+col.data:col.data] = {like: (data.columns[col.idx].search.value != '' ? data.columns[col.idx].search.value : filter)+'%'}; >+ var value = data.columns[col.idx].search.value != '' ? data.columns[col.idx].search.value : filter; >+ part[!col.data.includes('.')?'me.'+col.data:col.data] = options.criteria === 'exact'?value:{like: (['contains', 'ends_with'].indexOf(options.criteria) !== -1?'%':'')+value+(['contains', 'starts_with'].indexOf(options.criteria) !== -1?'%':'')}; > return part; > }); > >@@ -193,7 +196,7 @@ jQuery.fn.dataTable.ext.errMode = function(settings, note, message) { > delete options.query_parameters; > } > >- dataSet._match = 'starts_with'; >+ dataSet._match = options.criteria; > > if(options.columns) { > var order = data.order; >-- >2.20.1
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 24561
:
98612
|
98624
|
99254
|
99255
|
99723
|
100039
|
100126
|
100401
|
103727
|
104037
|
104384
|
104424
| 104425 |
104426