diff --git a/framework/example/config/ExampleUiLabels.xml b/framework/example/config/ExampleUiLabels.xml index 1e55b8c175..49f3f9ff04 100644 --- a/framework/example/config/ExampleUiLabels.xml +++ b/framework/example/config/ExampleUiLabels.xml @@ -131,6 +131,14 @@ Uses the \${date:dayStart(nowTimestamp, timeZone, locale)} UEL expression to set the default value to the start of today 使用\${date:dayStart(nowTimestamp, timeZone, locale)}表达式来把缺省值设置为今天的开始时间 + + Field12: advanced date time selection with a step value for minutes + Champ 12 : Sélection avancée date et temps avec la possibilité de choisir un pas pour les minutes + + + Use step=1 (default), 5, 10, 15, 30 + Utiliser 1 (valeur par défaut), 5, 10, 15, 30 pour la valeur du pas + Field1: date and time selection field Champ 1 : sélection de date et temps diff --git a/framework/example/widget/example/FormWidgetExampleForms.xml b/framework/example/widget/example/FormWidgetExampleForms.xml index f9dd23c117..2f2af497b0 100644 --- a/framework/example/widget/example/FormWidgetExampleForms.xml +++ b/framework/example/widget/example/FormWidgetExampleForms.xml @@ -116,6 +116,14 @@ under the License. tooltip="${uiLabelMap.ExampleDateField8Tooltip}"> + + + + + +
diff --git a/framework/widget/dtd/widget-form.xsd b/framework/widget/dtd/widget-form.xsd index c33ab8caa1..a3f28cda6c 100644 --- a/framework/widget/dtd/widget-form.xsd +++ b/framework/widget/dtd/widget-form.xsd @@ -645,6 +645,17 @@ under the License. + + + + + + + + + + + diff --git a/framework/widget/src/org/ofbiz/widget/form/MacroFormRenderer.java b/framework/widget/src/org/ofbiz/widget/form/MacroFormRenderer.java index cff010ff5a..4be7342c98 100644 --- a/framework/widget/src/org/ofbiz/widget/form/MacroFormRenderer.java +++ b/framework/widget/src/org/ofbiz/widget/form/MacroFormRenderer.java @@ -482,6 +482,26 @@ public class MacroFormRenderer implements FormStringRenderer { alert = "true"; } } + String stepString = dateTimeField.getStep(); + int step = 1; + StringBuilder timeValues = new StringBuilder(); + if ( "time-dropdown".equals(dateTimeField.getInputMethod()) && UtilValidate.isNotEmpty(step)) { + try { + step = Integer.valueOf(stepString).intValue(); + } catch (IllegalArgumentException e) { + Debug.logWarning("Inavalid value for step property for field[" + paramName + "] with input-method=\"time-dropdown\" " + + " Found Value ["+ stepString + "] " + e.getMessage(), module); + } + timeValues.append("["); + for(int i =0; i<=59;) { + if(i != 0) { + timeValues.append(", "); + } + timeValues.append(i); + i += step; + } + timeValues.append("]"); + } Map uiLabelMap = UtilGenerics.checkMap(context.get("uiLabelMap")); if (uiLabelMap == null) { Debug.logWarning("Could not find uiLabelMap in context", module); @@ -610,6 +630,10 @@ public class MacroFormRenderer implements FormStringRenderer { sr.append(Integer.toString(maxlength)); sr.append("\" value=\""); sr.append(value); + sr.append("\" step=\""); + sr.append(Integer.toString(step)); + sr.append("\" timeValues=\""); + sr.append(timeValues.toString()); sr.append("\" id=\""); sr.append(id); sr.append("\" event=\""); diff --git a/framework/widget/src/org/ofbiz/widget/form/ModelFormField.java b/framework/widget/src/org/ofbiz/widget/form/ModelFormField.java index 125c049ee1..2c197bf7f5 100644 --- a/framework/widget/src/org/ofbiz/widget/form/ModelFormField.java +++ b/framework/widget/src/org/ofbiz/widget/form/ModelFormField.java @@ -3025,6 +3025,7 @@ public class ModelFormField { protected FlexibleStringExpander defaultValue; protected String inputMethod; protected String clock; + protected String step; protected DateTimeField() { super(); @@ -3044,6 +3045,12 @@ public class ModelFormField { type = element.getAttribute("type"); inputMethod = element.getAttribute("input-method"); clock = element.getAttribute("clock"); + if (UtilValidate.isNotEmpty(element.getAttribute("step"))) { + this.setStep(element.getAttribute("step")); + } + else { + this.setStep("1"); + } } @Override @@ -3071,6 +3078,13 @@ public class ModelFormField { return this.clock; } + public String getStep() { + return this.step; + } + public void setStep(String step) { + this.step = step; + } + /** * @param string */ diff --git a/framework/widget/templates/csvFormMacroLibrary.ftl b/framework/widget/templates/csvFormMacroLibrary.ftl index b3176b02bb..2a752b4d2c 100644 --- a/framework/widget/templates/csvFormMacroLibrary.ftl +++ b/framework/widget/templates/csvFormMacroLibrary.ftl @@ -28,7 +28,7 @@ under the License. <#macro renderTextareaField name className alert cols rows id readonly value visualEditorEnable language buttons><@renderField value /> -<#macro renderDateTimeField name className alert title value size maxlength id dateType shortDateInput timeDropdownParamName defaultDateTimeString localizedIconTitle timeDropdown timeHourName classString hour1 hour2 timeMinutesName minutes isTwelveHour ampmName amSelected pmSelected compositeType formName><@renderField value /> +<#macro renderDateTimeField name className alert title value size maxlength step timeValues id dateType shortDateInput timeDropdownParamName defaultDateTimeString localizedIconTitle timeDropdown timeHourName classString hour1 hour2 timeMinutesName minutes isTwelveHour ampmName amSelected pmSelected compositeType formName><@renderField value /> <#macro renderDropDownField name className alert id multiple formName otherFieldName event action size firstInList currentValue explicitDescription allowEmpty options fieldName otherFieldName otherValue otherFieldSize dDFCurrent ajaxEnabled noCurrentSelectedKey ajaxOptions frequency minChars choices autoSelect partialSearch partialChars ignoreCase fullSearch> <#if currentValue?has_content && firstInList?has_content> diff --git a/framework/widget/templates/foFormMacroLibrary.ftl b/framework/widget/templates/foFormMacroLibrary.ftl index d2808e1e4c..d642254478 100644 --- a/framework/widget/templates/foFormMacroLibrary.ftl +++ b/framework/widget/templates/foFormMacroLibrary.ftl @@ -52,7 +52,7 @@ under the License. <#macro renderTextareaField name className alert cols rows id readonly value visualEditorEnable language buttons><@makeBlock className value /> -<#macro renderDateTimeField name className alert title value size maxlength id event action dateType shortDateInput timeDropdownParamName defaultDateTimeString localizedIconTitle timeDropdown timeHourName classString hour1 hour2 timeMinutesName minutes isTwelveHour ampmName amSelected pmSelected compositeType formName><@makeBlock className value /> +<#macro renderDateTimeField name className alert title value size maxlength step timeValues id event action dateType shortDateInput timeDropdownParamName defaultDateTimeString localizedIconTitle timeDropdown timeHourName classString hour1 hour2 timeMinutesName minutes isTwelveHour ampmName amSelected pmSelected compositeType formName><@makeBlock className value /> <#macro renderDropDownField name className alert id multiple formName otherFieldName event action size firstInList currentValue explicitDescription allowEmpty options fieldName otherFieldName otherValue otherFieldSize dDFCurrent ajaxEnabled noCurrentSelectedKey ajaxOptions frequency minChars choices autoSelect partialSearch partialChars ignoreCase fullSearch> <#if currentValue?has_content && firstInList?has_content> diff --git a/framework/widget/templates/htmlFormMacroLibrary.ftl b/framework/widget/templates/htmlFormMacroLibrary.ftl index 7bd738981d..ad1c3d3525 100644 --- a/framework/widget/templates/htmlFormMacroLibrary.ftl +++ b/framework/widget/templates/htmlFormMacroLibrary.ftl @@ -94,7 +94,7 @@ under the License. -<#macro renderDateTimeField name className alert title value size maxlength id dateType shortDateInput timeDropdownParamName defaultDateTimeString localizedIconTitle timeDropdown timeHourName classString hour1 hour2 timeMinutesName minutes isTwelveHour ampmName amSelected pmSelected compositeType formName event="" action=""> +<#macro renderDateTimeField name className alert title value size maxlength step timeValues id dateType shortDateInput timeDropdownParamName defaultDateTimeString localizedIconTitle timeDropdown timeHourName classString hour1 hour2 timeMinutesName minutes isTwelveHour ampmName amSelected pmSelected compositeType formName event="" action=""> ${event}="${action}" <@renderClass className alert /><#rt/> <#if title?has_content> title="${title}" @@ -136,9 +136,9 @@ under the License. : <#rt/>