Skip to content

Commit

Permalink
Improved: slim down groovy scriptlet (OFBIZ-13146)
Browse files Browse the repository at this point in the history
Convert to groovy natural language or uel function
  • Loading branch information
nmalin committed Nov 5, 2024
1 parent 18b5ab4 commit 0fda48b
Show file tree
Hide file tree
Showing 8 changed files with 153 additions and 165 deletions.
2 changes: 1 addition & 1 deletion birt/widget/facility/FacilityForms.xml
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ under the License.
<field name="offsetQOHQty" title="${uiLabelMap.ProductQtyOffsetQOHBelow}"><text/></field>
<field name="offsetATPQty" title="${uiLabelMap.ProductQtyOffsetATPBelow}"><text/></field>
<field name="productsSoldThruTimestamp" title="${uiLabelMap.ProductShowProductsSoldThruTimestamp}">
<date-time default-value="${groovy: org.apache.ofbiz.base.util.UtilDateTime.nowTimestamp()}"/>
<date-time default-value="${date:nowTimestamps()}"/>
</field>
<field name="VIEW_SIZE" entry-name="viewSize" title="${uiLabelMap.ProductShowProductsPerPage}"><text/></field>
<field name="monthsInPastLimit" entry-name="monthsInPastLimit"><text/></field>
Expand Down
10 changes: 5 additions & 5 deletions ebay/widget/EbayForms.xml
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,8 @@ under the License.
<form name="ListOrdersFromEbay" type="multi" use-row-submit="true" list-name="orderList" target="ImportOrderFromEbay"
odd-row-style="alternate-row" default-table-style="basic-table hover-bar">
<row-actions>
<set field="canImportOrder" value="${groovy: org.apache.ofbiz.base.util.UtilValidate.isEmpty(orderId) &amp;&amp; org.apache.ofbiz.base.util.UtilValidate.isEmpty(errorMessage)}" type="Boolean"/>
<set field="allowProductIdChange" value="${groovy: org.apache.ofbiz.base.util.UtilValidate.isEmpty(orderId) &amp;&amp; org.apache.ofbiz.base.util.UtilValidate.isNotEmpty(errorMessage)}" type="Boolean"/>
<set field="canImportOrder" value="${groovy: !orderId &amp;&amp; !errorMessage}" type="Boolean"/>
<set field="allowProductIdChange" value="${groovy: !orderId &amp;&amp; errorMessage}" type="Boolean"/>
</row-actions>
<field name="productStoreId"><hidden/></field>
<field name="externalId" title="${uiLabelMap.EbayImportEbayItem}"><display/></field>
Expand Down Expand Up @@ -105,9 +105,9 @@ under the License.
<form name="ListEbayOrders" type="multi" use-row-submit="true" list-name="orderList" target="importEbayOrders"
odd-row-style="alternate-row" default-table-style="basic-table hover-bar">
<row-actions>
<set field="canImportOrder" value="${groovy: org.apache.ofbiz.base.util.UtilValidate.isEmpty(orderId)}" type="Boolean"/>
<set field="isEbayOrder" value="${groovy: org.apache.ofbiz.base.util.UtilValidate.isNotEmpty(isEbayOrder)}" type="Boolean"/>
<set field="isEbayTransaction" value="${groovy: org.apache.ofbiz.base.util.UtilValidate.isNotEmpty(isEbayTransaction)}" type="Boolean"/>
<set field="canImportOrder" value="${groovy: !orderId}" type="Boolean"/>
<set field="isEbayOrder" value="${groovy: isEbayOrder}" type="Boolean"/>
<set field="isEbayTransaction" value="${groovy: isEbayTransaction}" type="Boolean"/>
</row-actions>
<field name="productStoreId"><hidden/></field>
<field name="externalId" title="${uiLabelMap.EbayEbayOrderIdOrTransactionId}" use-when="${isEbayOrder}" tooltip="eBay Order"><display/></field>
Expand Down
2 changes: 1 addition & 1 deletion ebaystore/widget/EbayStoreForms.xml
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ under the License.
</hyperlink>
</field>
<field name="comments" title="Ebay Category Id"><display description="${ebayCategoryId}"></display></field>
<field name="subCategory"><display description="${groovy:prodCategoryRollup.size()}"></display></field>
<field name="subCategory"><display description="${util:size(prodCategoryRollup)}"></display></field>
<field name="updateButton" title="${uiLabelMap.CommonDelete}"><submit button-type="button"/></field>
</form>
<form name="NewEbayAccount" type="single" target="createEbayAccount">
Expand Down
2 changes: 1 addition & 1 deletion projectmgr/widget/TaskScreens.xml
Original file line number Diff line number Diff line change
Expand Up @@ -564,7 +564,7 @@ under the License.
<screen name="ListWorkEffortSurveyAppls">
<section>
<actions>
<set field="nowTimeStampString" default-value="${groovy: org.apache.ofbiz.base.util.UtilDateTime.nowTimestamp()}"/>
<set field="nowTimeStampString" default-value="${date:nowTimestamps()}"/>
<entity-and entity-name="WorkEffortSurveyAppl" list="workEffortSurveyAppls">
<field-map field-name="workEffortId" from-field="parameters.workEffortId"/>
<order-by field-name="workEffortId"/>
Expand Down
2 changes: 1 addition & 1 deletion scrum/minilang/ScrumEvents.xml
Original file line number Diff line number Diff line change
Expand Up @@ -683,7 +683,7 @@

<!-- Check if there are duplicate value will reorder and change it -->
<set field="custRequestIndex" type="List"/>
<set field="custRequestIndexToSet" value="${groovy: import java.util.Set; new HashSet(custRequestIndexList);}"/>
<set field="custRequestIndexToSet" value="${groovy: custRequestIndexList.unique()}"/>
<iterate list="custRequestIndexToSet" entry="custRequestIndexMap">
<set field="count" value="0" type="Integer"/>
<loop count="${custRequestListSize}" field="l">
Expand Down
2 changes: 1 addition & 1 deletion scrum/minilang/ScrumServices.xml
Original file line number Diff line number Diff line change
Expand Up @@ -1364,7 +1364,7 @@
</iterate>
</if-not-empty>
<if-not-empty field="billingItemIndexList">
<set field="billingItemIndexToSet" value="${groovy: import java.util.Set; new HashSet(billingItemIndexList);}"/>
<set field="billingItemIndexToSet" value="${groovy: billingItemIndexList.unique()}"/>
<set field="billingItemIndexList" from-field="billingItemIndexToSet" />
<iterate list="billingItemIndexList" entry="billingItemIndexMap">
<set field="inputMap" type="NewMap"/>
Expand Down
13 changes: 3 additions & 10 deletions scrum/widget/TimeSheetForms.xml
Original file line number Diff line number Diff line change
Expand Up @@ -56,13 +56,6 @@
</form>
<form name="ListTimeSheets" type="list" list-name="timesheets" paginate-target="FindTimeSheet"
odd-row-style="alternate-row" default-table-style="basic-table hover-bar">
<actions>
<set field="complete" value="${uiLabelMap.ScrumToComplete}"/>
<set field="inProcess" value="Set To In-progress"/>
</actions>
<row-actions>
<set field="completeLink" value="${groovy:&quot;TIMESHEET_IN_PROCESS&quot;.equals(statusId)?complete:&quot;&quot;}"/>
</row-actions>
<field name="timesheetId" title="${uiLabelMap.WorkEffortTimesheetTimesheetId}" widget-style="buttontext">
<hyperlink description="${timesheetId}" target="ViewTimeSheet" also-hidden="false">
<parameter param-name="timesheetId"/>
Expand All @@ -75,13 +68,13 @@
<field name="thruDate" title="${uiLabelMap.CommonThruDate}"><display type="date"/></field>
<!--field name="comments" title="${uiLabelMap.CommonComments}"><display/></field-->
<field name="completeLink" title="${uiLabelMap.CommonStatustoComplete}" widget-style="buttontext">
<hyperlink description="${groovy:statusId.equals(&quot;TIMESHEET_IN_PROCESS&quot;)?complete:&quot;&quot;}" target="TimeSheetStatusToComplete">
<hyperlink description="${groovy: statusId == 'TIMESHEET_IN_PROCESS' ? uiLabelMap.ScrumToComplete : ''}" target="TimeSheetStatusToComplete">
<parameter param-name="timesheetId"/>
<parameter param-name="statusId" value="TIMESHEET_COMPLETED"/>
</hyperlink>
</field>
<field name="inProcessLink" title="${uiLabelMap.StatusToInProcess}" widget-style="buttontext">
<hyperlink description="${groovy:statusId.equals(&quot;TIMESHEET_COMPLETED&quot;)?inProcess:&quot;&quot;}" target="processTimesheet" >
<hyperlink description="${groovy: statusId == 'TIMESHEET_COMPLETED' ? 'Set To In-progress' : ''}" target="processTimesheet" >
<parameter param-name="timesheetId"/>
<parameter param-name="statusId" value="TIMESHEET_IN_PROCESS"/>
</hyperlink>
Expand All @@ -104,7 +97,7 @@
<field name="hours"><display/></field>
<field name="comments" title="${uiLabelMap.CommonComments}"><display/></field>
<field name="completeLink" title="${uiLabelMap.CommonStatustoComplete}" widget-style="buttontext">
<hyperlink description="${groovy:statusId.equals(&quot;TIMESHEET_IN_PROCESS&quot;)?complete:&quot;&quot;}" target="TimeSheetStatusToComplete" also-hidden="false">
<hyperlink description="${groovy: statusId == 'TIMESHEET_IN_PROCESS' ? complete : ''}" target="TimeSheetStatusToComplete" also-hidden="false">
<parameter param-name="timesheetId"/>
<parameter param-name="statusId" value="TIMESHEET_COMPLETED"/>
</hyperlink>
Expand Down
Loading

0 comments on commit 0fda48b

Please sign in to comment.