Bugzilla – Attachment 145135 Details for
Bug 32505
Cannot search by dateofbirth in specified dateformat
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 32505: [ALT] Use column 'type' to pre-process search patterns
Bug-32505-ALT-Use-column-type-to-pre-process-searc.patch (text/plain), 5.56 KB, created by
Martin Renvoize
on 2023-01-09 10:03:00 UTC
(
hide
)
Description:
Bug 32505: [ALT] Use column 'type' to pre-process search patterns
Filename:
MIME Type:
Creator:
Martin Renvoize
Created:
2023-01-09 10:03:00 UTC
Size:
5.56 KB
patch
obsolete
>From 500d8da48640e0f729d36b4ceff1a251091f0d30 Mon Sep 17 00:00:00 2001 >From: Martin Renvoize <martin.renvoize@ptfs-europe.com> >Date: Thu, 21 Oct 2021 18:00:57 +0100 >Subject: [PATCH] Bug 32505: [ALT] Use column 'type' to pre-process search > patterns > >This patch adds the option to pass 'type' at the 'column' definition >level and then binds on that type to add date parsing to queries. >--- > .../prog/en/includes/patron-search.inc | 2 ++ > koha-tmpl/intranet-tmpl/prog/js/datatables.js | 33 ++++++++++++++----- > 2 files changed, 26 insertions(+), 9 deletions(-) > >diff --git a/koha-tmpl/intranet-tmpl/prog/en/includes/patron-search.inc b/koha-tmpl/intranet-tmpl/prog/en/includes/patron-search.inc >index de4ba90c0de..fc587121cea 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/includes/patron-search.inc >+++ b/koha-tmpl/intranet-tmpl/prog/en/includes/patron-search.inc >@@ -431,6 +431,7 @@ > [% CASE 'dateofbirth' %] > { > "data": "date_of_birth", >+ "type": "date", > "searchable": true, > "orderable": true, > "render": function( data, type, row, meta ) { >@@ -552,6 +553,7 @@ > [% CASE 'dateexpiry' %] > { > "data": "expiry_date", >+ "type": "date", > "searchable": true, > "orderable": true, > "render": function( data, type, row, meta ) { >diff --git a/koha-tmpl/intranet-tmpl/prog/js/datatables.js b/koha-tmpl/intranet-tmpl/prog/js/datatables.js >index 0fbb9b625cb..9d328484795 100644 >--- a/koha-tmpl/intranet-tmpl/prog/js/datatables.js >+++ b/koha-tmpl/intranet-tmpl/prog/js/datatables.js >@@ -508,15 +508,18 @@ jQuery.fn.dataTable.ext.errMode = function(settings, note, message) { > > /** > * Create a new dataTables instance that uses the Koha RESTful API's as a data source >- * @param {Object} options Please see the dataTables documentation for further details >- * We extend the options set with the `criteria` key which allows >- * the developer to select the match type to be applied during searches >- * Valid keys are: `contains`, `starts_with`, `ends_with` and `exact` >- * @param {Object} table_settings The arrayref as returned by TableSettings.GetTableSettings function available >- * from the columns_settings template toolkit include >- * @param {Boolean} add_filters Add a filters row as the top row of the table >- * @param {Object} default_filters Add a set of default search filters to apply at table initialisation >- * @return {Object} The dataTables instance >+ * @param {Object} options Please see the dataTables settings documentation for further >+ * details >+ * @param {string} [options.criteria=contains] A koha specific extension to the dataTables settings block that >+ * allows setting the 'comparison operator' used in searches >+ * Supports `contains`, `starts_with`, `ends_with` and `exact` match >+ * @param {string} [options.columns.*.type Data type the field is stored in so we may impose some additional >+ * manipulation to search strings. Supported types are currenlty 'date' >+ * @param {Object} table_settings The arrayref as returned by TableSettings.GetTableSettings function >+ * available from the columns_settings template toolkit include >+ * @param {Boolean} add_filters Add a filters row as the top row of the table >+ * @param {Object} default_filters Add a set of default search filters to apply at table initialisation >+ * @return {Object} The dataTables instance > */ > $.fn.kohaTable = function(options, table_settings, add_filters, default_filters) { > var settings = null; >@@ -601,6 +604,18 @@ jQuery.fn.dataTable.ext.errMode = function(settings, note, message) { > ? value > : {like: (['contains', 'ends_with'].indexOf(criteria) !== -1?'%':'') + value + (['contains', 'starts_with'].indexOf(criteria) !== -1?'%':'')}; > parts.push(part); >+ >+ // Alternate manipulated query based on type >+ let type = col.type; >+ if ( type === 'date' ) { >+ try { >+ let d = $date_to_rfc3339(value); >+ parts.push({[!attr.includes('.')?'me.'+attr:attr]:d}); >+ } >+ catch { >+ // Hide the warning if the date is not correct >+ }; >+ } > } > return parts; > } >-- >2.39.0
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 32505
:
144922
|
144937
|
145096
|
145135
|
147377