svn commit: r1209250 - /ofbiz/trunk/framework/widget/templates/htmlFormMacroLibrary.ftl

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

svn commit: r1209250 - /ofbiz/trunk/framework/widget/templates/htmlFormMacroLibrary.ftl

jleroux@apache.org
Author: jleroux
Date: Thu Dec  1 21:26:32 2011
New Revision: 1209250

URL: http://svn.apache.org/viewvc?rev=1209250&view=rev
Log:
A patch from Manuela Gruendlinger "renderDateTimeField does not allow to clear input field" https://issues.apache.org/jira/browse/OFBIZ-4595

Input fields rendered with renderDateTimeField cannot be cleared, the old value is always restored.


Modified:
    ofbiz/trunk/framework/widget/templates/htmlFormMacroLibrary.ftl

Modified: ofbiz/trunk/framework/widget/templates/htmlFormMacroLibrary.ftl
URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/widget/templates/htmlFormMacroLibrary.ftl?rev=1209250&r1=1209249&r2=1209250&view=diff
==============================================================================
--- ofbiz/trunk/framework/widget/templates/htmlFormMacroLibrary.ftl (original)
+++ ofbiz/trunk/framework/widget/templates/htmlFormMacroLibrary.ftl Thu Dec  1 21:26:32 2011
@@ -137,17 +137,23 @@ under the License.
 
                   jQuery("#${id}").change(function() {
                       var ofbizTime = "<#if shortDateInput?exists && shortDateInput>yyyy-MM-dd<#else>yyyy-MM-dd HH:mm:ss</#if>";
-                      var dateObj = Date.parseExact(this.value, ofbizTime);
-                      var dateFormat = Date.CultureInfo.formatPatterns.shortDate<#if shortDateInput?exists && !shortDateInput> + " " + Date.CultureInfo.formatPatterns.longTime</#if>;
-                      var formatedObj = dateObj.toString(dateFormat);
-                      jQuery("#${id}_i18n").val(formatedObj);
+                      var newValue = ""
+                      if (this.value != "") {
+                          var dateObj = Date.parseExact(this.value, ofbizTime);
+                          var dateFormat = Date.CultureInfo.formatPatterns.shortDate<#if shortDateInput?exists && !shortDateInput> + " " + Date.CultureInfo.formatPatterns.longTime</#if>;
+                          newValue = dateObj.toString(dateFormat);
+                      }
+                      jQuery("#${id}_i18n").val(newValue);
                   });
                   jQuery("#${id}_i18n").change(function() {
                       var dateFormat = Date.CultureInfo.formatPatterns.shortDate<#if shortDateInput?exists && !shortDateInput> + " " + Date.CultureInfo.formatPatterns.longTime</#if>;
-                      var dateObj = Date.parseExact(this.value, dateFormat);
-                      var ofbizTime = "<#if shortDateInput?exists && shortDateInput>yyyy-MM-dd<#else>yyyy-MM-dd HH:mm:ss</#if>";
-                      var formatedObj = dateObj.toString(ofbizTime);
-                      jQuery("#${id}").val(formatedObj);
+                      var newValue = ""
+                      if (this.value != "") {
+                          var dateObj = Date.parseExact(this.value, dateFormat);
+                          var ofbizTime = "<#if shortDateInput?exists && shortDateInput>yyyy-MM-dd<#else>yyyy-MM-dd HH:mm:ss</#if>";
+                          newValue = dateObj.toString(ofbizTime);
+                      }
+                      jQuery("#${id}").val(newValue);
                   });
               } else {
                   <#-- fallback if no language specific js date file is found -->