|
Author: erwan
Date: Mon Feb 14 16:57:31 2011 New Revision: 1070570 URL: http://svn.apache.org/viewvc?rev=1070570&view=rev Log: Adding a new feature for date-time fields: step, which will format the minutes drop-down with or a 1, 5, 10, 15 or 30 step-size Modified: ofbiz/trunk/framework/example/config/ExampleUiLabels.xml ofbiz/trunk/framework/example/widget/example/FormWidgetExampleForms.xml ofbiz/trunk/framework/widget/dtd/widget-form.xsd ofbiz/trunk/framework/widget/src/org/ofbiz/widget/form/MacroFormRenderer.java ofbiz/trunk/framework/widget/src/org/ofbiz/widget/form/ModelFormField.java ofbiz/trunk/framework/widget/templates/csvFormMacroLibrary.ftl ofbiz/trunk/framework/widget/templates/foFormMacroLibrary.ftl ofbiz/trunk/framework/widget/templates/htmlFormMacroLibrary.ftl Modified: ofbiz/trunk/framework/example/config/ExampleUiLabels.xml URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/example/config/ExampleUiLabels.xml?rev=1070570&r1=1070569&r2=1070570&view=diff ============================================================================== --- ofbiz/trunk/framework/example/config/ExampleUiLabels.xml (original) +++ ofbiz/trunk/framework/example/config/ExampleUiLabels.xml Mon Feb 14 16:57:31 2011 @@ -131,6 +131,14 @@ <value xml:lang="en">Uses the \${date:dayStart(nowTimestamp, timeZone, locale)} UEL expression to set the default value to the start of today</value> <value xml:lang="zh">使ç¨\${date:dayStart(nowTimestamp, timeZone, locale)}è¡¨è¾¾å¼æ¥æç¼ºçå¼è®¾ç½®ä¸ºä»å¤©çå¼å§æ¶é´</value> </property> + <property key="ExampleDateField12Title"> + <value xml:lang="en">Field12: advanced date time selection with a step value for minutes</value> + <value xml:lang="fr">Champ 12 : Sélection avancée date et temps avec la possibilité de choisir un pas pour les minutes</value> + </property> + <property key="ExampleDateField12Tooltip"> + <value xml:lang="en">Use step=1 (default), 5, 10, 15, 30</value> + <value xml:lang="fr">Utiliser 1 (valeur par défaut), 5, 10, 15, 30 pour la valeur du pas</value> + </property> <property key="ExampleDateField1Title"> <value xml:lang="en">Field1: date and time selection field</value> <value xml:lang="fr">Champ 1 : sélection de date et temps</value> Modified: ofbiz/trunk/framework/example/widget/example/FormWidgetExampleForms.xml URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/example/widget/example/FormWidgetExampleForms.xml?rev=1070570&r1=1070569&r2=1070570&view=diff ============================================================================== --- ofbiz/trunk/framework/example/widget/example/FormWidgetExampleForms.xml (original) +++ ofbiz/trunk/framework/example/widget/example/FormWidgetExampleForms.xml Mon Feb 14 16:57:31 2011 @@ -116,6 +116,14 @@ under the License. tooltip="${uiLabelMap.ExampleDateField8Tooltip}"> <display description="${groovy:org.ofbiz.base.util.UtilDateTime.toDateString(exampleDateField, "MMMM,dd,yyyy");}"/> </field> + <!-- ***************** --> + <!-- *** field12 *** --> + <!-- ***************** --> + <field name="field12" + title="${uiLabelMap.ExampleDateField12Title}" + tooltip="${uiLabelMap.ExampleDateField12Tooltip}"> + <date-time input-method="time-dropdown" clock="24" default-value="${exampleDateField}" step="5"/> + </field> </form> <form name="DropDownFieldsExampleForm" type="single" title=""> Modified: ofbiz/trunk/framework/widget/dtd/widget-form.xsd URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/widget/dtd/widget-form.xsd?rev=1070570&r1=1070569&r2=1070570&view=diff ============================================================================== --- ofbiz/trunk/framework/widget/dtd/widget-form.xsd (original) +++ ofbiz/trunk/framework/widget/dtd/widget-form.xsd Mon Feb 14 16:57:31 2011 @@ -645,6 +645,17 @@ under the License. </xs:restriction> </xs:simpleType> </xs:attribute> + <xs:attribute name="step" default="1"> + <xs:simpleType> + <xs:restriction base="xs:token"> + <xs:enumeration value="1"/> + <xs:enumeration value="5"/> + <xs:enumeration value="10"/> + <xs:enumeration value="15"/> + <xs:enumeration value="30"/> + </xs:restriction> + </xs:simpleType> + </xs:attribute> </xs:attributeGroup> <xs:element name="display" substitutionGroup="AllFields"> <xs:complexType> Modified: ofbiz/trunk/framework/widget/src/org/ofbiz/widget/form/MacroFormRenderer.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/widget/src/org/ofbiz/widget/form/MacroFormRenderer.java?rev=1070570&r1=1070569&r2=1070570&view=diff ============================================================================== --- ofbiz/trunk/framework/widget/src/org/ofbiz/widget/form/MacroFormRenderer.java (original) +++ ofbiz/trunk/framework/widget/src/org/ofbiz/widget/form/MacroFormRenderer.java Mon Feb 14 16:57:31 2011 @@ -482,6 +482,26 @@ public class MacroFormRenderer implement 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<String, String> 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 implement 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=\""); Modified: ofbiz/trunk/framework/widget/src/org/ofbiz/widget/form/ModelFormField.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/widget/src/org/ofbiz/widget/form/ModelFormField.java?rev=1070570&r1=1070569&r2=1070570&view=diff ============================================================================== --- ofbiz/trunk/framework/widget/src/org/ofbiz/widget/form/ModelFormField.java (original) +++ ofbiz/trunk/framework/widget/src/org/ofbiz/widget/form/ModelFormField.java Mon Feb 14 16:57:31 2011 @@ -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 */ Modified: ofbiz/trunk/framework/widget/templates/csvFormMacroLibrary.ftl URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/widget/templates/csvFormMacroLibrary.ftl?rev=1070570&r1=1070569&r2=1070570&view=diff ============================================================================== --- ofbiz/trunk/framework/widget/templates/csvFormMacroLibrary.ftl (original) +++ ofbiz/trunk/framework/widget/templates/csvFormMacroLibrary.ftl Mon Feb 14 16:57:31 2011 @@ -28,7 +28,7 @@ under the License. <#macro renderTextareaField name className alert cols rows id readonly value visualEditorEnable language buttons><@renderField value /></#macro> -<#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> +<#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> <#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> Modified: ofbiz/trunk/framework/widget/templates/foFormMacroLibrary.ftl URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/widget/templates/foFormMacroLibrary.ftl?rev=1070570&r1=1070569&r2=1070570&view=diff ============================================================================== --- ofbiz/trunk/framework/widget/templates/foFormMacroLibrary.ftl (original) +++ ofbiz/trunk/framework/widget/templates/foFormMacroLibrary.ftl Mon Feb 14 16:57:31 2011 @@ -52,7 +52,7 @@ under the License. <#macro renderTextareaField name className alert cols rows id readonly value visualEditorEnable language buttons><@makeBlock className value /></#macro> -<#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> +<#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> <#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> Modified: ofbiz/trunk/framework/widget/templates/htmlFormMacroLibrary.ftl URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/widget/templates/htmlFormMacroLibrary.ftl?rev=1070570&r1=1070569&r2=1070570&view=diff ============================================================================== --- ofbiz/trunk/framework/widget/templates/htmlFormMacroLibrary.ftl (original) +++ ofbiz/trunk/framework/widget/templates/htmlFormMacroLibrary.ftl Mon Feb 14 16:57:31 2011 @@ -94,7 +94,7 @@ under the License. </#if> </#macro> -<#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=""> <span class="view-calendar"> <input type="text" name="${name}" <#if event?has_content && action?has_content> ${event}="${action}"</#if> <@renderClass className alert /><#rt/> <#if title?has_content> title="${title}"</#if> @@ -136,9 +136,9 @@ under the License. </#list> </#if> </select>:<select name="${timeMinutesName}" <#if classString?has_content>class="${classString}"</#if>><#rt/> - <#assign x=59> - <#list 0..x as i> - <option value="${i}"<#if minutes?has_content><#if i=minutes> selected="selected"</#if></#if>>${i}</option><#rt/> + <#assign values = Static["org.ofbiz.base.util.StringUtil"].toList(timeValues)> + <#list values as i> + <option value="${i}"<#if minutes?has_content><#if i?number== minutes || ((minutes > i?number )&& (minutes < i?number+(step?number/2))) || ((minutes < i?number )&& (minutes > i?number-(step?number/2)))> selected="selected"</#if></#if>>${i}</option><#rt/> </#list> </select> <#rt/> |
| Free forum by Nabble | Edit this page |
