[ofbiz-framework] branch trunk updated: Fixed: Incorrect date format in tooltip (OFBIZ-12123)

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

[ofbiz-framework] branch trunk updated: Fixed: Incorrect date format in tooltip (OFBIZ-12123)

James Yong-2
This is an automated email from the ASF dual-hosted git repository.

jamesyong pushed a commit to branch trunk
in repository https://gitbox.apache.org/repos/asf/ofbiz-framework.git


The following commit(s) were added to refs/heads/trunk by this push:
     new d32814e  Fixed: Incorrect date format in tooltip (OFBIZ-12123)
d32814e is described below

commit d32814e5c8759c3f7aba42fe2d0d7cd390441982
Author: James Yong <[hidden email]>
AuthorDate: Tue Jan 12 12:32:53 2021 +0800

    Fixed: Incorrect date format in tooltip (OFBIZ-12123)
   
    Tooltip should show the date format used by the picker.
---
 .../webapp/common/js/util/OfbizUtil.js             | 37 ++++++----------------
 1 file changed, 10 insertions(+), 27 deletions(-)

diff --git a/themes/common-theme/webapp/common/js/util/OfbizUtil.js b/themes/common-theme/webapp/common/js/util/OfbizUtil.js
index 016a488..e90fe39 100644
--- a/themes/common-theme/webapp/common/js/util/OfbizUtil.js
+++ b/themes/common-theme/webapp/common/js/util/OfbizUtil.js
@@ -330,17 +330,18 @@ function initDateTimePicker(self) {
     importLibrary(libCultureInfo, function () {
         //If language specific lib is found, use date / time converter else just copy the value fields
         if (Date.CultureInfo != undefined) {
+            var dateFormat;
+            var ofbizTime;
+            if (shortDate) {
+                dateFormat = Date.CultureInfo.formatPatterns.shortDate;
+                ofbizTime = "yyyy-MM-dd";
+            } else {
+                dateFormat = Date.CultureInfo.formatPatterns.shortDate + " " + Date.CultureInfo.formatPatterns.longTime;
+                ofbizTime = "yyyy-MM-dd HH:mm:ss"
+            }
+            element_i18n.attr('title', dateFormat);
             var initDate = element.val();
             if (initDate != "") {
-                var dateFormat;
-                var ofbizTime;
-                if (shortDate) {
-                    dateFormat = Date.CultureInfo.formatPatterns.shortDate;
-                    ofbizTime = "yyyy-MM-dd";
-                } else {
-                    dateFormat = Date.CultureInfo.formatPatterns.shortDate + " " + Date.CultureInfo.formatPatterns.longTime;
-                    ofbizTime = "yyyy-MM-dd HH:mm:ss"
-                }
                 // The JS date parser doesn't understand the dot before ms in the date/time string. The ms here should be always 000
                 if (initDate.indexOf('.') != -1) {
                     initDate = initDate.substring(0, initDate.indexOf('.'));
@@ -353,15 +354,6 @@ function initDateTimePicker(self) {
 
             element.change(function () {
                 var value = element.val();
-                var dateFormat;
-                var ofbizTime;
-                if (shortDate) {
-                    dateFormat = Date.CultureInfo.formatPatterns.shortDate;
-                    ofbizTime = "yyyy-MM-dd";
-                } else {
-                    dateFormat = Date.CultureInfo.formatPatterns.shortDate + " " + Date.CultureInfo.formatPatterns.longTime;
-                    ofbizTime = "yyyy-MM-dd HH:mm:ss"
-                }
                 var newValue = ""
                 if (value != "") {
                     var dateObj = Date.parseExact(value, ofbizTime);
@@ -372,15 +364,6 @@ function initDateTimePicker(self) {
 
             element_i18n.change(function () {
                 var value = element_i18n.val();
-                var dateFormat;
-                var ofbizTime;
-                if (shortDate) {
-                    dateFormat = Date.CultureInfo.formatPatterns.shortDate;
-                    ofbizTime = "yyyy-MM-dd";
-                } else {
-                    dateFormat = Date.CultureInfo.formatPatterns.shortDate + " " + Date.CultureInfo.formatPatterns.longTime;
-                    ofbizTime = "yyyy-MM-dd HH:mm:ss"
-                }
                 var newValue = "";
                 var dateObj = Date.parseExact(value, dateFormat);
                 if (value != "" && dateObj !== null) {