+1 Gil

Jacques


Le 10/06/2018 à 08:34, Gil Portenseigne a écrit :
Hi Rishi,

In the xsd it's better to use xs:boolean type, instead of enumeration type.

Regards,

Gil


Le 9 juin 2018 14:34:49 GMT+02:00, ri...@apache.org a écrit :
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>

Reply via email to