You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@ofbiz.apache.org by Taher Alkhateeb <sl...@gmail.com> on 2018/06/09 13:43:50 UTC

Re: svn commit: r1833231 - in /ofbiz/ofbiz-framework/trunk: framework/widget/dtd/ framework/widget/src/main/java/org/apache/ofbiz/widget/model/ framework/widget/src/main/java/org/apache/ofbiz/widget/renderer/macro/ themes/common-theme/template/macro/

Hi Rishi, Thank you for the work on this.

I'm wondering, why not apply this to all form fields? I mean why apply
it in the XSD on check boxes only? It seems like a useful feature to
have in all form widgets no? For example, a text box could be disabled
because X field is not yet filled, and so on.

The reason I am raising this point is that if we want to add "disable"
to more form field types, then we can simply apply the XSD on the
field level, not the field type level. WDYT?

On Sat, Jun 9, 2018 at 3:34 PM,  <ri...@apache.org> wrote:
> Author: rishi
> Date: Sat Jun  9 12:34:49 2018
> New Revision: 1833231
>
> URL: http://svn.apache.org/viewvc?rev=1833231&view=rev
> Log:
> Improved: Add Support for Disable attribute in CheckBox Form Widget. Disabled attrivute can be used as
>
> <field><check disabled=true/></field>
>
> and default value for attribute will be false.
> (OFBIZ-10367)
> Thanks Pawan Verma for reporting the improvement and providing patch for that.
> Thanks James Yong for testing the work.
>
> Modified:
>     ofbiz/ofbiz-framework/trunk/framework/widget/dtd/widget-form.xsd
>     ofbiz/ofbiz-framework/trunk/framework/widget/src/main/java/org/apache/ofbiz/widget/model/ModelFormField.java
>     ofbiz/ofbiz-framework/trunk/framework/widget/src/main/java/org/apache/ofbiz/widget/model/XmlWidgetFieldVisitor.java
>     ofbiz/ofbiz-framework/trunk/framework/widget/src/main/java/org/apache/ofbiz/widget/renderer/macro/MacroFormRenderer.java
>     ofbiz/ofbiz-framework/trunk/themes/common-theme/template/macro/CsvFormMacroLibrary.ftl
>     ofbiz/ofbiz-framework/trunk/themes/common-theme/template/macro/FoFormMacroLibrary.ftl
>     ofbiz/ofbiz-framework/trunk/themes/common-theme/template/macro/HtmlFormMacroLibrary.ftl
>     ofbiz/ofbiz-framework/trunk/themes/common-theme/template/macro/TextFormMacroLibrary.ftl
>     ofbiz/ofbiz-framework/trunk/themes/common-theme/template/macro/XlsFormMacroLibrary.ftl
>     ofbiz/ofbiz-framework/trunk/themes/common-theme/template/macro/XmlFormMacroLibrary.ftl
>
> Modified: ofbiz/ofbiz-framework/trunk/framework/widget/dtd/widget-form.xsd
> URL: http://svn.apache.org/viewvc/ofbiz/ofbiz-framework/trunk/framework/widget/dtd/widget-form.xsd?rev=1833231&r1=1833230&r2=1833231&view=diff
> ==============================================================================
> --- ofbiz/ofbiz-framework/trunk/framework/widget/dtd/widget-form.xsd (original)
> +++ ofbiz/ofbiz-framework/trunk/framework/widget/dtd/widget-form.xsd Sat Jun  9 12:34:49 2018
> @@ -956,6 +956,14 @@ under the License.
>                      </xs:restriction>
>                  </xs:simpleType>
>              </xs:attribute>
> +            <xs:attribute name="disabled" default="false">
> +                <xs:simpleType>
> +                    <xs:restriction base="xs:token">
> +                        <xs:enumeration value="true" />
> +                        <xs:enumeration value="false" />
> +                    </xs:restriction>
> +                </xs:simpleType>
> +            </xs:attribute>
>          </xs:complexType>
>      </xs:element>
>      <xs:element name="container" substitutionGroup="AllFields">
>
> Modified: ofbiz/ofbiz-framework/trunk/framework/widget/src/main/java/org/apache/ofbiz/widget/model/ModelFormField.java
> URL: http://svn.apache.org/viewvc/ofbiz/ofbiz-framework/trunk/framework/widget/src/main/java/org/apache/ofbiz/widget/model/ModelFormField.java?rev=1833231&r1=1833230&r2=1833231&view=diff
> ==============================================================================
> --- ofbiz/ofbiz-framework/trunk/framework/widget/src/main/java/org/apache/ofbiz/widget/model/ModelFormField.java (original)
> +++ ofbiz/ofbiz-framework/trunk/framework/widget/src/main/java/org/apache/ofbiz/widget/model/ModelFormField.java Sat Jun  9 12:34:49 2018
> @@ -980,25 +980,30 @@ public class ModelFormField {
>      public static class CheckField extends FieldInfoWithOptions {
>          public final static String ROW_SUBMIT_FIELD_NAME = "_rowSubmit";
>          private final FlexibleStringExpander allChecked;
> +        private final boolean disabled;
>
>          private CheckField(CheckField original, ModelFormField modelFormField) {
>              super(original, modelFormField);
>              this.allChecked = original.allChecked;
> +            this.disabled = original.disabled;
>          }
>
>          public CheckField(Element element, ModelFormField modelFormField) {
>              super(element, modelFormField);
>              allChecked = FlexibleStringExpander.getInstance(element.getAttribute("all-checked"));
> +            this.disabled = "true".equals(element.getAttribute("disabled"));
>          }
>
>          public CheckField(int fieldSource, ModelFormField modelFormField) {
>              super(fieldSource, FieldInfo.CHECK, modelFormField);
>              this.allChecked = FlexibleStringExpander.getInstance("");
> +            this.disabled = false;
>          }
>
>          public CheckField(ModelFormField modelFormField) {
>              super(FieldInfo.SOURCE_EXPLICIT, FieldInfo.CHECK, modelFormField);
>              this.allChecked = FlexibleStringExpander.getInstance("");
> +            this.disabled = false;
>          }
>
>          @Override
> @@ -1023,6 +1028,10 @@ public class ModelFormField {
>              return null;
>          }
>
> +        public boolean getDisabled() {
> +            return this.disabled;
> +        }
> +
>          @Override
>          public void renderFieldString(Appendable writer, Map<String, Object> context, FormStringRenderer formStringRenderer)
>                  throws IOException {
> @@ -4335,4 +4344,4 @@ public class ModelFormField {
>              formStringRenderer.renderTextFindField(writer, context, this);
>          }
>      }
> -}
> +}
> \ No newline at end of file
>
> Modified: ofbiz/ofbiz-framework/trunk/framework/widget/src/main/java/org/apache/ofbiz/widget/model/XmlWidgetFieldVisitor.java
> URL: http://svn.apache.org/viewvc/ofbiz/ofbiz-framework/trunk/framework/widget/src/main/java/org/apache/ofbiz/widget/model/XmlWidgetFieldVisitor.java?rev=1833231&r1=1833230&r2=1833231&view=diff
> ==============================================================================
> --- ofbiz/ofbiz-framework/trunk/framework/widget/src/main/java/org/apache/ofbiz/widget/model/XmlWidgetFieldVisitor.java (original)
> +++ ofbiz/ofbiz-framework/trunk/framework/widget/src/main/java/org/apache/ofbiz/widget/model/XmlWidgetFieldVisitor.java Sat Jun  9 12:34:49 2018
> @@ -68,6 +68,7 @@ public class XmlWidgetFieldVisitor exten
>          visitModelField(checkField.getModelFormField());
>          writer.append("<check");
>          visitAttribute("all-checked", checkField.getAllChecked());
> +        visitAttribute("disabled", checkField.getDisabled());
>          visitFieldInfoWithOptions(checkField);
>          writer.append("</check></field>");
>      }
>
> Modified: ofbiz/ofbiz-framework/trunk/framework/widget/src/main/java/org/apache/ofbiz/widget/renderer/macro/MacroFormRenderer.java
> URL: http://svn.apache.org/viewvc/ofbiz/ofbiz-framework/trunk/framework/widget/src/main/java/org/apache/ofbiz/widget/renderer/macro/MacroFormRenderer.java?rev=1833231&r1=1833230&r2=1833231&view=diff
> ==============================================================================
> --- ofbiz/ofbiz-framework/trunk/framework/widget/src/main/java/org/apache/ofbiz/widget/renderer/macro/MacroFormRenderer.java (original)
> +++ ofbiz/ofbiz-framework/trunk/framework/widget/src/main/java/org/apache/ofbiz/widget/renderer/macro/MacroFormRenderer.java Sat Jun  9 12:34:49 2018
> @@ -1019,6 +1019,7 @@ public final class MacroFormRenderer imp
>          String currentValue = modelFormField.getEntry(context);
>          String conditionGroup = modelFormField.getConditionGroup();
>          Boolean allChecked = checkField.isAllChecked(context);
> +        boolean disabled = checkField.getDisabled();
>          String id = modelFormField.getCurrentContainerId(context);
>          String className = "";
>          String alert = "false";
> @@ -1073,7 +1074,9 @@ public final class MacroFormRenderer imp
>          }
>          sr.append("\" tabindex=\"");
>          sr.append(tabindex);
> -        sr.append("\" />");
> +        sr.append("\" disabled=");
> +        sr.append(Boolean.toString(disabled));
> +        sr.append(" />");
>          executeMacro(writer, sr.toString());
>          this.appendTooltip(writer, context, modelFormField);
>      }
>
> Modified: ofbiz/ofbiz-framework/trunk/themes/common-theme/template/macro/CsvFormMacroLibrary.ftl
> URL: http://svn.apache.org/viewvc/ofbiz/ofbiz-framework/trunk/themes/common-theme/template/macro/CsvFormMacroLibrary.ftl?rev=1833231&r1=1833230&r2=1833231&view=diff
> ==============================================================================
> --- ofbiz/ofbiz-framework/trunk/themes/common-theme/template/macro/CsvFormMacroLibrary.ftl (original)
> +++ ofbiz/ofbiz-framework/trunk/themes/common-theme/template/macro/CsvFormMacroLibrary.ftl Sat Jun  9 12:34:49 2018
> @@ -41,7 +41,7 @@ under the License.
>  </#macro>
>
>  <#macro renderTooltip tooltip tooltipStyle></#macro>
> -<#macro renderCheckField items className alert id allChecked currentValue name event action conditionGroup tabindex></#macro>
> +<#macro renderCheckField items className alert id allChecked currentValue name event action conditionGroup tabindex disabled></#macro>
>  <#macro renderRadioField items className alert currentValue noCurrentSelectedKey name event action conditionGroup tabindex></#macro>
>
>  <#macro renderSubmitField buttonType className alert formName title name event action imgSrc confirmation containerId ajaxUrl tabindex></#macro>
>
> Modified: ofbiz/ofbiz-framework/trunk/themes/common-theme/template/macro/FoFormMacroLibrary.ftl
> URL: http://svn.apache.org/viewvc/ofbiz/ofbiz-framework/trunk/themes/common-theme/template/macro/FoFormMacroLibrary.ftl?rev=1833231&r1=1833230&r2=1833231&view=diff
> ==============================================================================
> --- ofbiz/ofbiz-framework/trunk/themes/common-theme/template/macro/FoFormMacroLibrary.ftl (original)
> +++ ofbiz/ofbiz-framework/trunk/themes/common-theme/template/macro/FoFormMacroLibrary.ftl Sat Jun  9 12:34:49 2018
> @@ -67,7 +67,7 @@ under the License.
>  </#if>
>  </#macro>
>
> -<#macro renderCheckField items className alert id allChecked currentValue name event action conditionGroup tabindex><@makeBlock "" "" /></#macro>
> +<#macro renderCheckField items className alert id allChecked currentValue name event action conditionGroup tabindex disabled><@makeBlock "" "" /></#macro>
>  <#macro renderRadioField items className alert currentValue noCurrentSelectedKey name event action conditionGroup tabindex><@makeBlock "" "" /></#macro>
>
>  <#macro renderSubmitField buttonType className alert formName title name event action imgSrc confirmation containerId ajaxUrl tabindex><@makeBlock "" "" /></#macro>
>
> Modified: ofbiz/ofbiz-framework/trunk/themes/common-theme/template/macro/HtmlFormMacroLibrary.ftl
> URL: http://svn.apache.org/viewvc/ofbiz/ofbiz-framework/trunk/themes/common-theme/template/macro/HtmlFormMacroLibrary.ftl?rev=1833231&r1=1833230&r2=1833231&view=diff
> ==============================================================================
> --- ofbiz/ofbiz-framework/trunk/themes/common-theme/template/macro/HtmlFormMacroLibrary.ftl (original)
> +++ ofbiz/ofbiz-framework/trunk/themes/common-theme/template/macro/HtmlFormMacroLibrary.ftl Sat Jun  9 12:34:49 2018
> @@ -252,13 +252,14 @@ under the License.
>    </#if>
>  </#macro>
>
> -<#macro renderCheckField items className alert id name action conditionGroup="" allChecked="" currentValue=""  event="" tabindex="">
> +<#macro renderCheckField items className alert id name action conditionGroup="" allChecked="" currentValue=""  event="" tabindex="" disabled="">
>    <#if conditionGroup?has_content>
>      <input type="hidden" name="${name}_grp" value="${conditionGroup}"/>
>    </#if>
>    <#list items as item>
>      <span <@renderClass className alert />><#rt/>
>        <input type="checkbox"<#if (item_index == 0)> id="${id}"</#if><#rt/><#if tabindex?has_content> tabindex="${tabindex}"</#if><#rt/>
> +        <#if disabled?has_content && disabled> disabled="disabled"</#if><#rt/>
>          <#if allChecked?has_content && allChecked> checked="checked" <#elseif allChecked?has_content && !allChecked>
>            <#elseif currentValue?has_content && currentValue==item.value> checked="checked"</#if>
>            name="${name?default("")?html}" value="${item.value?default("")?html}"<#if event?has_content> ${event}="${action}"</#if>/><#rt/>
>
> Modified: ofbiz/ofbiz-framework/trunk/themes/common-theme/template/macro/TextFormMacroLibrary.ftl
> URL: http://svn.apache.org/viewvc/ofbiz/ofbiz-framework/trunk/themes/common-theme/template/macro/TextFormMacroLibrary.ftl?rev=1833231&r1=1833230&r2=1833231&view=diff
> ==============================================================================
> --- ofbiz/ofbiz-framework/trunk/themes/common-theme/template/macro/TextFormMacroLibrary.ftl (original)
> +++ ofbiz/ofbiz-framework/trunk/themes/common-theme/template/macro/TextFormMacroLibrary.ftl Sat Jun  9 12:34:49 2018
> @@ -41,7 +41,7 @@ under the License.
>  </#macro>
>
>  <#macro renderTooltip tooltip tooltipStyle></#macro>
> -<#macro renderCheckField items className alert id allChecked currentValue name event action conditionGroup tabindex></#macro>
> +<#macro renderCheckField items className alert id allChecked currentValue name event action conditionGroup tabindex disabled></#macro>
>  <#macro renderRadioField items className alert currentValue noCurrentSelectedKey name event action conditionGroup tabindex></#macro>
>
>  <#macro renderSubmitField buttonType className alert formName title name event action imgSrc confirmation containerId ajaxUrl tabindex></#macro>
>
> Modified: ofbiz/ofbiz-framework/trunk/themes/common-theme/template/macro/XlsFormMacroLibrary.ftl
> URL: http://svn.apache.org/viewvc/ofbiz/ofbiz-framework/trunk/themes/common-theme/template/macro/XlsFormMacroLibrary.ftl?rev=1833231&r1=1833230&r2=1833231&view=diff
> ==============================================================================
> --- ofbiz/ofbiz-framework/trunk/themes/common-theme/template/macro/XlsFormMacroLibrary.ftl (original)
> +++ ofbiz/ofbiz-framework/trunk/themes/common-theme/template/macro/XlsFormMacroLibrary.ftl Sat Jun  9 12:34:49 2018
> @@ -42,7 +42,7 @@ under the License.
>
>  <#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 conditionGroup tabindex><@renderItemField explicitDescription "txf" className/></#macro>
>
> -<#macro renderCheckField items className alert id allChecked currentValue name event action conditionGroup tabindex><@renderItemField currentValue "txf" className/></#macro>
> +<#macro renderCheckField items className alert id allChecked currentValue name event action conditionGroup tabindex disabled><@renderItemField currentValue "txf" className/></#macro>
>
>  <#macro renderRadioField items className alert currentValue noCurrentSelectedKey name event action conditionGroup tabindex><@renderItemField currentValue "txf" className/></#macro>
>
>
> Modified: ofbiz/ofbiz-framework/trunk/themes/common-theme/template/macro/XmlFormMacroLibrary.ftl
> URL: http://svn.apache.org/viewvc/ofbiz/ofbiz-framework/trunk/themes/common-theme/template/macro/XmlFormMacroLibrary.ftl?rev=1833231&r1=1833230&r2=1833231&view=diff
> ==============================================================================
> --- ofbiz/ofbiz-framework/trunk/themes/common-theme/template/macro/XmlFormMacroLibrary.ftl (original)
> +++ ofbiz/ofbiz-framework/trunk/themes/common-theme/template/macro/XmlFormMacroLibrary.ftl Sat Jun  9 12:34:49 2018
> @@ -49,7 +49,7 @@ under the License.
>  <#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 conditionGroup tabindex>
>  </#macro>
>
> -<#macro renderCheckField items className alert id allChecked currentValue name event action conditionGroup tabindex></#macro>
> +<#macro renderCheckField items className alert id allChecked currentValue name event action conditionGroup tabindex disabled></#macro>
>  <#macro renderRadioField items className alert currentValue noCurrentSelectedKey name event action conditionGroup tabindex></#macro>
>
>  <#macro renderSubmitField buttonType className alert formName title name event action imgSrc confirmation containerId ajaxUrl tabindex></#macro>
>
>