Skip to content

Commit

Permalink
Improved: Improvement of the Check xml tag (OFBIZ-12821)
Browse files Browse the repository at this point in the history
The approach for pre-checking variables is as follows: if a variable with the
same name as the field exists, its value will be used to determine the pre-check
status. There is an example in QuoteForms.xml

Thanks: Maxime Flammang and Nereide team
  • Loading branch information
JacquesLeRoux committed Feb 16, 2024
1 parent 96bf009 commit 3b923ad
Show file tree
Hide file tree
Showing 7 changed files with 121 additions and 65 deletions.
14 changes: 9 additions & 5 deletions applications/order/widget/ordermgr/QuoteForms.xml
Original file line number Diff line number Diff line change
Expand Up @@ -17,17 +17,21 @@ KIND, either express or implied. See the License for the
specific language governing permissions and limitations
under the License.
-->
<forms xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
<forms xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://ofbiz.apache.org/Widget-Form" xsi:schemaLocation="http://ofbiz.apache.org/Widget-Form http://ofbiz.apache.org/dtds/widget-form.xsd">

<form name="FindQuotes" target="FindQuote" title="" type="single" default-map-name="parameters"
header-row-style="header-row" default-table-style="basic-table">
<actions>
<set field="quoteTypeId[]" value="OTHER_QUOTE"/>
<set field="quoteTypeId[]" value="PROPOSAL"/>
</actions>
<auto-fields-entity entity-name="Quote" default-field-type="find"/>
<field name="quoteId" title="${uiLabelMap.OrderOrderQuoteId}"></field>
<field name="quoteTypeId" title="${uiLabelMap.OrderOrderQuoteTypeId}">
<drop-down allow-empty="true">
<check>
<entity-options entity-name="QuoteType" key-field-name="quoteTypeId"/>
</drop-down>
</check>
</field>
<field name="salesChannelEnumId" title="${uiLabelMap.OrderSalesChannel}">
<drop-down allow-empty="true">
Expand Down Expand Up @@ -134,7 +138,7 @@ under the License.
<entity-constraint name="statusTypeId" value="QUOTE_STATUS"/>
</entity-options>
</drop-down>
</field>
</field>
<field name="statusId" use-when="quote!=null" title="${uiLabelMap.CommonStatus}">
<drop-down allow-empty="false" current="first-in-list" current-description="${currentStatus.description}">
<entity-options entity-name="StatusValidChangeToDetail" key-field-name="statusIdTo" description="${transitionName} (${description})">
Expand Down Expand Up @@ -545,7 +549,7 @@ under the License.
<display-entity entity-name="TermType" description="${description} [${termTypeId}]" key-field-name="termTypeId"/>
</field>
<field name="quoteId"><hidden/></field>

<field name="uomId">
<drop-down current-description="">
<entity-options entity-name="Uom" key-field-name="uomId"/>
Expand Down
66 changes: 33 additions & 33 deletions applications/product/widget/catalog/ImageManagementForms.xml
Original file line number Diff line number Diff line change
Expand Up @@ -62,13 +62,13 @@ under the License.
<hyperlink description="${uiLabelMap.CommonView}" target="${origContentDataResourceViews[0].drObjectInfo}" target-window="_blank" also-hidden="false" target-type="content"/>
</field>
</grid>
<form name="ImageGallery" type="single" title="" header-row-style="header-row" default-table-style="basic-table" target="ListImageGallery">

<form name="ImageGallery" type="single" title="" header-row-style="header-row" default-table-style="basic-table" target="ListImageGallery">
<field name="productId" title="${uiLabelMap.ImageManagementChooseProductID}"><lookup target-form-name="LookupProduct"/></field>
<field name="submitButton" title="${uiLabelMap.CommonSubmit}" widget-style="smallSubmit"><submit button-type="button"/></field>
</form>
<form name="ImageApprove" type="multi" title="" list-name="contentApprovalProductContentAndInfos" odd-row-style="alternate-row" default-table-style="basic-table"

<form name="ImageApprove" type="multi" title="" list-name="contentApprovalProductContentAndInfos" odd-row-style="alternate-row" default-table-style="basic-table"
use-row-submit="true" separate-columns="true" target="updateStatusImageManagement">
<row-actions>
<entity-and entity-name="ContentDataResourceView" list="contentDataResourceViews">
Expand Down Expand Up @@ -123,8 +123,8 @@ under the License.
</field>
<field name="submitButton" title="${uiLabelMap.CommonSubmit}" widget-style="smallSubmit"><submit button-type="button"/></field>
</form>
<grid name="ListPeopleApproved" title="" list-name="contentApprovalProductContentAndInfos" odd-row-style="alternate-row" default-table-style="basic-table"

<grid name="ListPeopleApproved" title="" list-name="contentApprovalProductContentAndInfos" odd-row-style="alternate-row" default-table-style="basic-table"
use-row-submit="true" separate-columns="true" target="">
<row-actions>
<entity-one entity-name="ContentDataResourceView" value-field="contentDataResourceView">
Expand Down Expand Up @@ -162,8 +162,8 @@ under the License.
<hyperlink description="${uiLabelMap.CommonView}" target="${origContentDataResourceViews[0].drObjectInfo}" target-window="_blank" also-hidden="false" target-type="content"/>
</field>
</grid>
<form name="ListPeopleRejected" type="multi" title="" list-name="productContentAndInfos" odd-row-style="alternate-row" default-table-style="basic-table"

<form name="ListPeopleRejected" type="multi" title="" list-name="productContentAndInfos" odd-row-style="alternate-row" default-table-style="basic-table"
use-row-submit="true" separate-columns="true" target="addRejectedReasonImageManagement">
<row-actions>
<entity-one entity-name="ContentDataResourceView" value-field="contentDataResourceView">
Expand Down Expand Up @@ -192,7 +192,7 @@ under the License.
<field name="productId" title="${uiLabelMap.ProductProductName} [${uiLabelMap.ProductProductId}] - ${uiLabelMap.FormFieldTitle_categoryName}" entry-name="productId" position="1" use-when="${groovy:String prev=(String)previousItem.get(&quot;productId&quot;);return new Boolean(!(prev!=null&amp;&amp;prev.equals(productId)));}">
<display-entity entity-name="Product" key-field-name="productId" description="${internalName} [${productId}] - ${productCategory.categoryName}" also-hidden="false"/>
</field>
<field name="_rowSubmit" position="2" title=" " widget-style="hidden"><check all-checked="trueThumb"/></field>
<field name="_rowSubmit" position="2" title=" " widget-style="hidden"><check all-checked="true"/></field>
<field name="drDataResourceName" position="2" title="${uiLabelMap.ImageManagementImageName}"><display/></field>
<field name="contentId" position="2"><display/></field>
<field name="dataResourceId" title="${uiLabelMap.ContentDataResourceId}" position="2"><display/></field>
Expand All @@ -212,8 +212,8 @@ under the License.
</field>
<field name="submitButton" title="${uiLabelMap.CommonSubmit}" widget-style="smallSubmit"><submit button-type="button"/></field>
</form>
<form name="ImageRejected" type="multi" title="" list-name="productContentAndInfos" odd-row-style="alternate-row" default-table-style="basic-table"

<form name="ImageRejected" type="multi" title="" list-name="productContentAndInfos" odd-row-style="alternate-row" default-table-style="basic-table"
use-row-submit="true" separate-columns="true" target="">
<row-actions>
<entity-one entity-name="ContentDataResourceView" value-field="contentDataResourceView">
Expand Down Expand Up @@ -261,12 +261,12 @@ under the License.
<hyperlink description="${uiLabelMap.CommonView}" target="${origContentDataResourceViews[0].drObjectInfo}" target-window="_blank" also-hidden="false" target-type="content"/>
</field>
</form>
<form name="ImageManage" type="single" title="" header-row-style="header-row" default-table-style="basic-table" target="ListImageManage">

<form name="ImageManage" type="single" title="" header-row-style="header-row" default-table-style="basic-table" target="ListImageManage">
<field name="productId" title="${uiLabelMap.ImageManagementChooseProductID}"><lookup target-form-name="LookupProduct"/></field>
<field name="submitButton" title="${uiLabelMap.CommonSubmit}" widget-style="smallSubmit"><submit button-type="button"/></field>
</form>

<form name="ListImageManage" type="multi" title="" odd-row-style="alternate-row" default-table-style="basic-table" list-name="productContentAndInfoList"
use-row-submit="true" separate-columns="true" target="setImageDetail?productId=${parameters.productId}">
<actions>
Expand Down Expand Up @@ -306,7 +306,7 @@ under the License.
<field name="_rowSubmit" title=" " widget-style="hidden"><check all-checked="true"/></field>
<field name="drObjectInfo" title="${uiLabelMap.CommonImage}"><image style="cssImgThumb"/></field>
<field name="action" use-when="${groovy: return context.drMimeTypeId == 'image/jpeg';}" title="${uiLabelMap.ImageManagementAction}" event="onChange" action="javascript:
document.ListImageManage.action='checkAction?productId=${productId}&amp;contentId=${contentId}&amp;dataResourceId=${dataResourceId}';
document.ListImageManage.action='checkAction?productId=${productId}&amp;contentId=${contentId}&amp;dataResourceId=${dataResourceId}';
document.ListImageManage.submit();">
<drop-down allow-empty="true">
<option key="frame" description="${uiLabelMap.ImageManagementFrame}"/>
Expand Down Expand Up @@ -359,8 +359,8 @@ under the License.
<sort-field name="statusId"/>
</sort-order>
</form>
<form name="ShowDefaultImage" type="single" title="" header-row-style="header-row" default-table-style="basic-table">

<form name="ShowDefaultImage" type="single" title="" header-row-style="header-row" default-table-style="basic-table">
<actions>
<entity-and entity-name="ProductContentAndInfo" list="productContentAndInfos">
<field-map field-name="productId" from-field="parameters.productId"/>
Expand All @@ -381,7 +381,7 @@ under the License.
</actions>
<field name="drObjectInfo" title=" "><image style="cssImgThumb"/></field>
</form>

<form name="ImageFrames" type="single" title="" target="uploadFrame" header-row-style="header-row" default-table-style="basic-table" target-window="_self">
<actions>
<script location="component://product/src/main/groovy/org/apache/ofbiz/product/catalog/imagemanagement/ImageFrame.groovy"/>
Expand All @@ -394,7 +394,7 @@ under the License.
<field-map field-name="contentId" from-field="frameContentId"/>
<field-map field-name="drDataResourceId" from-field="frameDataResourceId"/>
</entity-one>

<set field="frameURL" from-field="contentDataResource2.drObjectInfo"/>
<set field="previewURL" from-field="contentFrameDataResource.drDataResourceName"/>
</actions>
Expand Down Expand Up @@ -427,7 +427,7 @@ under the License.
</field>
</form>

<form name="ImageCropping" type="single" title="" header-row-style="header-row" default-table-style="basic-table" target="CropImage">
<form name="ImageCropping" type="single" title="" header-row-style="header-row" default-table-style="basic-table" target="CropImage">
<actions>
<entity-one entity-name="ContentDataResourceView" value-field="contentDataResource">
<field-map field-name="contentId" from-field="parameters.contentId"/>
Expand All @@ -445,7 +445,7 @@ under the License.
<field name="imageCropp" widget-area-style="cropbox" use-when="imageURL != null" title="${uiLabelMap.CommonImage}" ><image value="${imageURL}"/></field>
<field name="imageCropp" use-when="imageURL == null" title="${uiLabelMap.CommonImage}" ><image value="/images/defaultImage.jpg" style="cssImgXLarge"/></field>
</form>

<form name="ImageRotating" type="single" target="RotateImage" title="" header-row-style="header-row" default-table-style="basic-table">
<actions>
<entity-one entity-name="ContentDataResourceView" value-field="contentDataResource">
Expand Down Expand Up @@ -475,7 +475,7 @@ under the License.
</hyperlink>
</field>
</form>

<form name="ImageShare" type="single" title="" header-row-style="header-row" default-table-style="basic-table">
<actions>
<entity-one entity-name="ContentDataResourceView" value-field="contentDataResource">
Expand Down Expand Up @@ -508,7 +508,7 @@ under the License.
<field name="html" title="${uiLabelMap.ImageManagementHTMLCode}" event="onClick" action="javascript:select();"><text/></field>
<field name="htmlThumbnail" title="${uiLabelMap.ImageManagementHTMLThumbnail}" event="onClick" action="javascript:select();"><text/></field>
</form>

<form name="ImageReplace" type="single" target="replaceImageToExistImage" title="" header-row-style="header-row" default-table-style="basic-table">
<actions>
<entity-one entity-name="ContentDataResourceView" value-field="contentDataResourceExist">
Expand All @@ -531,7 +531,7 @@ under the License.
<field name="imageReplace" position="2" use-when="imageURLReplace != null&amp;&amp;imageURLExist != null" title="${uiLabelMap.ImageManagementImageToReplace}"><image value="${imageURLReplace}" style="cssImgXLarge"/></field>
<field name="submitButton" title="${uiLabelMap.CommonSubmit}" widget-style="smallSubmit"><submit button-type="button"/></field>
</form>

<grid name="ListImageUpload" title="" list-name="productContent" odd-row-style="alternate-row" default-table-style="basic-table" use-row-submit="true" separate-columns="true">
<actions>
<set field="dateNow" type="Timestamp" value="${groovy:import org.apache.ofbiz.base.util.UtilDateTime;UtilDateTime.nowTimestamp().getTime() - 18000;}"/>
Expand Down Expand Up @@ -568,7 +568,7 @@ under the License.
</hyperlink>
</field>
</grid>

<grid name="ListLookupImage" list-name="listIt" paginate-target="ListLookupImage" odd-row-style="alternate-row" default-table-style="basic-table hover-bar">
<actions>
<entity-condition entity-name="ProductContentAndInfo">
Expand Down Expand Up @@ -607,12 +607,12 @@ under the License.
<hyperlink description="${uiLabelMap.CommonView}" target="${origContentDataResourceViews[0].drObjectInfo}" target-window="_blank" also-hidden="false" target-type="content"/>
</field>
</grid>
<form name="ProductImageReplace" type="single" title="" header-row-style="header-row" default-table-style="basic-table" target="ListImageReplace">

<form name="ProductImageReplace" type="single" title="" header-row-style="header-row" default-table-style="basic-table" target="ListImageReplace">
<field name="productId" title="${uiLabelMap.ImageManagementChooseProductID}"><lookup target-form-name="LookupProduct"/></field>
<field name="submitButton" title="${uiLabelMap.CommonSubmit}" widget-style="smallSubmit"><submit button-type="button"/></field>
</form>

<grid name="ListImageRecentlyApproved" title="" odd-row-style="alternate-row" default-table-style="basic-table" use-row-submit="true" separate-columns="true" target="">
<actions>
<entity-condition entity-name="ProductContentAndInfo">
Expand Down Expand Up @@ -656,7 +656,7 @@ under the License.
<hyperlink description="${uiLabelMap.CommonView}" target="${origContentDataResourceViews[0].drObjectInfo}" target-window="_blank" also-hidden="false" target-type="content"/>
</field>
</grid>

<grid name="ListImageExist" title="" odd-row-style="alternate-row" default-table-style="basic-table" use-row-submit="true" separate-columns="true">
<actions>
<entity-condition entity-name="ProductContentAndInfo">
Expand Down Expand Up @@ -697,7 +697,7 @@ under the License.
<hyperlink description="${uiLabelMap.CommonView}" target="${origContentDataResourceViews[0].drObjectInfo}" target-window="_blank" also-hidden="false" target-type="content"/>
</field>
</grid>

<grid name="ListImageReplace" title="" odd-row-style="alternate-row" default-table-style="basic-table" use-row-submit="true" separate-columns="true">
<actions>
<entity-condition entity-name="ProductContentAndInfo">
Expand Down Expand Up @@ -740,7 +740,7 @@ under the License.
<hyperlink description="${uiLabelMap.CommonView}" target="${origContentDataResourceViews[0].drObjectInfo}" target-window="_blank" also-hidden="false" target-type="content"/>
</field>
</grid>

<grid name="ListLookupImageFrame" list-name="listIt" paginate-target="ListLookupImageFrame" odd-row-style="alternate-row" default-table-style="basic-table hover-bar">
<actions>
<entity-condition entity-name="ContentDataResourceView">
Expand All @@ -760,7 +760,7 @@ under the License.
</hyperlink>
</field>-->
</grid>

<form name="ImageResize" type="single" title="" header-row-style="header-row" default-table-style="basic-table" target="resizeImages">
<field name="resizeOption">
<drop-down >
Expand All @@ -772,7 +772,7 @@ under the License.
<field name="size" title="${uiLabelMap.ImageManagementImageWidth}"><text/></field>
<field name="submitButton" title="${uiLabelMap.CommonSubmit}" widget-style="smallSubmit"><submit button-type="button"/></field>
</form>

<grid name="SizeListOfProduct" title="" odd-row-style="alternate-row" default-table-style="basic-table" use-row-submit="true" separate-columns="true">
<actions>
<entity-condition entity-name="ContentAssoc">
Expand Down
9 changes: 8 additions & 1 deletion framework/widget/dtd/widget-form.xsd
Original file line number Diff line number Diff line change
Expand Up @@ -877,7 +877,14 @@ under the License.
<xs:element ref="list-options" />
<xs:element ref="option" />
</xs:choice>
<xs:attribute name="all-checked" type="xs:boolean"/>
<xs:attribute name="all-checked" type="xs:boolean">
<xs:annotation>
<xs:documentation>
None option is checked by default.
You may check options by setting field names as in QuoteForms.xml#FindQuotes
</xs:documentation>
</xs:annotation>
</xs:attribute>
</xs:complexType>
</xs:element>
<xs:element name="container" substitutionGroup="AllFields">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1073,6 +1073,7 @@ public static class CheckField extends FieldInfoWithOptions {
public static final String ROW_SUBMIT_FIELD_NAME = "_rowSubmit";
private final FlexibleStringExpander allChecked;


private CheckField(CheckField original, ModelFormField modelFormField) {
super(original, modelFormField);
this.allChecked = original.allChecked;
Expand Down
Loading

0 comments on commit 3b923ad

Please sign in to comment.