Bugzilla – Attachment 153863 Details for
Bug 34226
Format dates from DT filters before querying the REST API
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 34226: Use 'type' at the datatable config level
Bug-34226-Use-type-at-the-datatable-config-level.patch (text/plain), 6.65 KB, created by
Martin Renvoize (ashimema)
on 2023-07-25 08:16:37 UTC
(
hide
)
Description:
Bug 34226: Use 'type' at the datatable config level
Filename:
MIME Type:
Creator:
Martin Renvoize (ashimema)
Created:
2023-07-25 08:16:37 UTC
Size:
6.65 KB
patch
obsolete
>From 1634f955475ba6aa332babb5f0aaff31e4140104 Mon Sep 17 00:00:00 2001 >From: Martin Renvoize <martin.renvoize@ptfs-europe.com> >Date: Mon, 24 Jul 2023 11:14:31 +0100 >Subject: [PATCH] Bug 34226: Use 'type' at the datatable config level > >Lets use 'type' definitions at the datatables settings level instead > >Signed-off-by: Lucas Gass <lucas@bywatersolutions.com> >Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com> >Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com> >--- > .../prog/en/includes/patron-search.inc | 2 + > koha-tmpl/intranet-tmpl/prog/js/datatables.js | 50 +++++++++---------- > 2 files changed, 27 insertions(+), 25 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 3c1ce6fe2c..8f13fa0374 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/includes/patron-search.inc >+++ b/koha-tmpl/intranet-tmpl/prog/en/includes/patron-search.inc >@@ -430,6 +430,7 @@ > [% CASE 'dateofbirth' %] > { > "data": "date_of_birth", >+ "type": "date", > "searchable": true, > "orderable": true, > "render": function( data, type, row, meta ) { >@@ -551,6 +552,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 9ee051d282..fe4fe8de97 100644 >--- a/koha-tmpl/intranet-tmpl/prog/js/datatables.js >+++ b/koha-tmpl/intranet-tmpl/prog/js/datatables.js >@@ -562,13 +562,15 @@ function _dt_default_ajax (params){ > } > > let built_value; >- let is_date_field; >+ if ( col.type == 'date' ) { >+ let rfc3339 = $date_to_rfc3339(value); >+ if ( rfc3339 != 'Invalid Date' ) { >+ built_value = rfc3339; >+ } >+ } > > if ( col.datatype !== undefined ) { >- if ( col.datatype == 'date' ) { >- is_date_field = true; >- } >- else if (col.datatype == 'related-object') { >+ if (col.datatype == 'related-object') { > let query_term = value; > > if (criteria != 'exact') { >@@ -582,15 +584,6 @@ function _dt_default_ajax (params){ > } else { > console.log("datatype %s not supported yet".format(col.datatype)); > } >- } else if (col.data && ( col.data.endsWith('_on') || col.data.endsWith('_date') ) ) { >- is_date_field = true; >- } >- >- if ( is_date_field ) { >- let rfc3339 = $date_to_rfc3339(value); >- if ( rfc3339 != 'Invalid Date' ) { >- built_value = rfc3339; >- } > } > > if (col.datatype != 'related-object') { >@@ -671,8 +664,12 @@ function _dt_default_ajax (params){ > > if(query_parameters.length) { > query_parameters = JSON.stringify(query_parameters.length === 1?query_parameters[0]:{"-and": query_parameters}); >- dataSet.q = query_parameters; >- delete options.query_parameters; >+ if(options.header_filter) { >+ options.query_parameters = query_parameters; >+ } else { >+ dataSet.q = query_parameters; >+ delete options.query_parameters; >+ } > } else { > delete options.query_parameters; > } >@@ -930,15 +927,18 @@ function _dt_add_filters(table_node, table_dt, filters_options = {}) { > > /** > * 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; >-- >2.41.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 34226
:
153180
|
153830
|
153831
|
153835
|
153862
| 153863 |
153864