From 582231ecfcb5f4657e5ba9803f1443557408e46b Mon Sep 17 00:00:00 2001 From: Ralf Becker Date: Thu, 28 Mar 2019 19:12:29 +0100 Subject: [PATCH] * All apps: fix custom-field display for date-time and custom data_format like YmdHi --- api/js/etemplate/et2_extension_customfields.js | 4 ++-- api/js/etemplate/et2_widget_date.js | 14 +++++++++++++- 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/api/js/etemplate/et2_extension_customfields.js b/api/js/etemplate/et2_extension_customfields.js index 3ae6fe6ecd..9c38972669 100644 --- a/api/js/etemplate/et2_extension_customfields.js +++ b/api/js/etemplate/et2_extension_customfields.js @@ -493,11 +493,11 @@ var et2_customfields_list = (function(){ "use strict"; return et2_valueWidget.ex }, _setup_date: function(field_name, field, attrs) { - attrs.data_format = 'Y-m-d'; + attrs.data_format = field.values && field.values.format ? field.values.format : 'Y-m-d'; return true; }, _setup_date_time: function(field_name, field, attrs) { - attrs.data_format = 'Y-m-d H:i:s'; + attrs.data_format = field.values && field.values.format ? field.values.format : 'Y-m-d H:i:s'; return true; }, _setup_htmlarea: function(field_name, field, attrs) { diff --git a/api/js/etemplate/et2_widget_date.js b/api/js/etemplate/et2_widget_date.js index 0716761f0f..9ae1a00fcc 100644 --- a/api/js/etemplate/et2_widget_date.js +++ b/api/js/etemplate/et2_widget_date.js @@ -1055,9 +1055,21 @@ var et2_date_ro = (function(){ "use strict"; return et2_valueWidget.extend([et2_ this.date = new Date(_value); this.date = new Date(this.date.valueOf() + (this.date.getTimezoneOffset()*60*1000)); } - else if(typeof _value == 'string' && isNaN(_value)) + else if(typeof _value == 'string' && (isNaN(_value) || + this.options.data_format && this.options.data_format.substr(0,3) === 'Ymd')) { try { + // data_format is not handled server-side for custom-fields in nextmatch + // as parseDateTime requires a separate between date and time, we fix the value here + switch (this.options.data_format) + { + case 'Ymd': + case 'YmdHi': + case 'YmdHis': + _value = _value.substr(0, 4)+'-'+_value.substr(4, 2)+'-'+_value.substr(6, 2)+' '+ + (_value.substr(8, 2) || '00')+':'+(_value.substr(10, 2) || '00')+':'+(_value.substr(12, 2) || '00'); + break; + } // parseDateTime to handle string PHP: DateTime local date/time format var parsed = (typeof jQuery.datepicker.parseDateTime("yy-mm-dd","hh:mm:ss", _value) !='undefined')? jQuery.datepicker.parseDateTime("yy-mm-dd","hh:mm:ss", _value):