Author: jleroux
Date: Fri Oct  8 15:33:03 2010
New Revision: 1005861

URL: http://svn.apache.org/viewvc?rev=1005861&view=rev
Log:
New Price Rules screen. 
I tried to make it look better by having only one Value column but I found that 
a field inserted by Prototype was not taken into account when submitted. As 
it's not possible to rename a DOM element I finally gave up and used use-when + 
hide/show instead. I will see if we can do better with jQuery...
I kept the old Screen + Groovy + FTL files, not for nostalgics, but in case 
someone has to quickly deal with fields with a lot of values (to avoid 
drop-down saturation). Then the Id will still be used. Note that it's also 
possible to do so with the new screen: you need only to put the field type in 
setPriceRulesCondEventJs.ftl and at top of getAssociatedPriceRulesConds service 
implementation in order to handle it as an Id with an input field (like it's 
done OOTB for Quantity and List Price)

I'd like to use the same mechanism for Promo Rules. I will do that later, 
hopefully before merging jQuery...

BTW, I like the now clear separation with Ajax onComplete event.


Added:
    
ofbiz/trunk/applications/product/webapp/catalog/WEB-INF/actions/price/EditProductPriceRules_old.groovy
   (with props)
    
ofbiz/trunk/framework/common/webcommon/includes/setPriceRulesCondEventJs.ftl   
(with props)
Modified:
    
ofbiz/trunk/applications/product/script/org/ofbiz/product/price/PriceServices.xml
    ofbiz/trunk/applications/product/servicedef/services_pricepromo.xml
    
ofbiz/trunk/applications/product/webapp/catalog/WEB-INF/actions/price/EditProductPriceRules.groovy
    ofbiz/trunk/applications/product/webapp/catalog/WEB-INF/controller.xml
    ofbiz/trunk/applications/product/widget/catalog/CatalogMenus.xml
    ofbiz/trunk/applications/product/widget/catalog/PriceForms.xml
    ofbiz/trunk/applications/product/widget/catalog/PriceScreens.xml
    
ofbiz/trunk/framework/common/webcommon/includes/setDependentDropdownValuesJs.ftl
    ofbiz/trunk/framework/images/webapp/images/getDependentDropdownValues.js

Modified: 
ofbiz/trunk/applications/product/script/org/ofbiz/product/price/PriceServices.xml
URL: 
http://svn.apache.org/viewvc/ofbiz/trunk/applications/product/script/org/ofbiz/product/price/PriceServices.xml?rev=1005861&r1=1005860&r2=1005861&view=diff
==============================================================================
--- 
ofbiz/trunk/applications/product/script/org/ofbiz/product/price/PriceServices.xml
 (original)
+++ 
ofbiz/trunk/applications/product/script/org/ofbiz/product/price/PriceServices.xml
 Fri Oct  8 15:33:03 2010
@@ -249,4 +249,116 @@ under the License.
         <find-by-primary-key entity-name="ProductPriceAction" 
map="lookupPKMap" value-field="lookedUpValue"/>
         <remove-value value-field="lookedUpValue"/>
     </simple-method>
+    
+    <simple-method method-name="getAssociatedPriceRulesConds" 
short-description="Set the Value options for selected Price Rule Condition 
Input" login-required="false">
+        <if>
+            <condition>
+                <or>
+                    <if-compare field="parameters.inputParamEnumId" 
operator="equals" value="PRIP_QUANTITY"/>
+                    <if-compare field="parameters.inputParamEnumId" 
operator="equals" value="PRIP_LIST_PRICE"/>
+                </or>
+            </condition>
+            <then>
+                <return/>
+            </then>
+        </if>
+        
+        <if-compare field="parameters.inputParamEnumId" operator="equals" 
value="PRIP_PRODUCT_ID">
+            <entity-condition entity-name="Product" list="condValues">
+                <!-- May prove more useful rather than an entity-and in custom 
cases-->
+            </entity-condition>
+            <iterate list="condValues" entry="condValue">
+                <set field="option" value="${condValue.internalName}: 
${condValue.productId}"/>
+                <field-to-list list="productPriceRulesCondValues" 
field="option"/>
+            </iterate>
+        </if-compare>
+        <if-compare field="parameters.inputParamEnumId" operator="equals" 
value="PRIP_PROD_CAT_ID">
+            <entity-condition entity-name="ProductCategory" list="condValues">
+                <!-- May prove more useful rather than an entity-and in custom 
cases-->
+            </entity-condition>
+            <iterate list="condValues" entry="condValue">
+                <set field="option" value="${condValue.categoryName} 
${condValue.description} ${groovy: condValue?.longDescription?.substring(0,10)} 
[${condValue.productCategoryId}]: ${condValue.productCategoryId}"/>
+                <field-to-list list="productPriceRulesCondValues" 
field="option"/>
+            </iterate>
+        </if-compare>
+        <if-compare field="parameters.inputParamEnumId" operator="equals" 
value="PRIP_PROD_FEAT_ID">
+            <entity-condition entity-name="ProductFeatureType" 
list="condValues">
+                <!-- May prove more useful rather than an entity-and in custom 
cases-->
+            </entity-condition>
+            <iterate list="condValues" entry="condValue">
+                <set field="option" value="${condValue.description}: 
${condValue.productFeatureTypeId}"/>
+                <field-to-list list="productPriceRulesCondValues" 
field="option"/>
+            </iterate>
+        </if-compare>
+        <if>
+            <condition>
+                <or>
+                    <if-compare field="parameters.inputParamEnumId" 
operator="equals" value="PRIP_PARTY_ID"/>
+                    <if-compare field="parameters.inputParamEnumId" 
operator="equals" value="PRIP_PARTY_GRP_MEM"/>
+                </or>
+            </condition>
+            <then>
+                <entity-condition entity-name="PartyNameView" 
list="condValues"/>
+                <iterate list="condValues" entry="condValue">
+                    <set field="option" value="${condValue.firstName} 
${condValue.lastName}${condValue.groupName}: ${condValue.partyId}"/>
+                    <field-to-list list="productPriceRulesCondValues" 
field="option"/>
+                </iterate>
+            </then>
+        </if>
+        <if-compare field="parameters.inputParamEnumId" operator="equals" 
value="PRIP_PARTY_CLASS">
+            <entity-condition entity-name="PartyClassificationGroup" 
list="condValues">
+                <!-- May prove more useful rather than an entity-and in custom 
cases-->
+            </entity-condition>
+            <iterate list="condValues" entry="condValue">
+                <set field="option" value="${condValue.description}: 
${condValue.partyClassificationGroupId}"/>
+                <field-to-list list="productPriceRulesCondValues" 
field="option"/>
+            </iterate>
+        </if-compare>
+        <if-compare field="parameters.inputParamEnumId" operator="equals" 
value="PRIP_ROLE_TYPE">
+            <entity-condition entity-name="RoleType" list="condValues">
+                <!-- May prove more useful rather than an entity-and in custom 
cases-->
+            </entity-condition>
+            <iterate list="condValues" entry="condValue">
+                <set field="option" value="${condValue.description}: 
${condValue.roleTypeId}"/>
+                <field-to-list list="productPriceRulesCondValues" 
field="option"/>
+            </iterate>
+        </if-compare>        
+        <if-compare field="parameters.inputParamEnumId" operator="equals" 
value="PRIP_WEBSITE_ID">
+            <entity-condition entity-name="WebSite" list="condValues"/>
+            <iterate list="condValues" entry="condValue">
+                <set field="option" value="${condValue.siteName}: 
${condValue.webSiteId}"/>
+                <field-to-list list="productPriceRulesCondValues" 
field="option"/>
+            </iterate>
+        </if-compare> 
+        <if-compare field="parameters.inputParamEnumId" operator="equals" 
value="PRIP_PROD_SGRP_ID">
+            <entity-condition entity-name="ProductStoreGroup" 
list="condValues"/>
+            <iterate list="condValues" entry="condValue">
+                <set field="option" value="${condValue.productStoreGroupName} 
(${condValue.description}): ${condValue.productStoreGroupId}"/>
+                <field-to-list list="productPriceRulesCondValues" 
field="option"/>
+            </iterate>
+        </if-compare> 
+        <if-compare field="parameters.inputParamEnumId" operator="equals" 
value="PRIP_PROD_CLG_ID">
+            <entity-condition entity-name="ProdCatalog" list="condValues"/>
+            <iterate list="condValues" entry="condValue">
+                <set field="option" value="${condValue.catalogName}: 
${condValue.prodCatalogId}"/>
+                <field-to-list list="productPriceRulesCondValues" 
field="option"/>
+            </iterate>
+        </if-compare> 
+        <if-compare field="parameters.inputParamEnumId" operator="equals" 
value="PRIP_CURRENCY_UOMID">
+            <entity-condition entity-name="Uom" list="condValues">
+                <condition-expr field-name="uomTypeId" 
value="CURRENCY_MEASURE"/>
+            </entity-condition>
+            <iterate list="condValues" entry="condValue">
+                <set field="option" value="${condValue.description}: 
${condValue.uomId}"/>
+                <field-to-list list="productPriceRulesCondValues" 
field="option"/>
+            </iterate>
+        </if-compare> 
+        
+        <if-empty field="productPriceRulesCondValues">
+            <property-to-field resource="CommonUiLabels" 
property="CommonNoOptions" field="noOptions"/>
+            <field-to-list list="productPriceRulesCondValues" 
field="noOptions"/>
+        </if-empty>
+        <field-to-result field="productPriceRulesCondValues"/>
+    </simple-method>
+    
 </simple-methods>

Modified: ofbiz/trunk/applications/product/servicedef/services_pricepromo.xml
URL: 
http://svn.apache.org/viewvc/ofbiz/trunk/applications/product/servicedef/services_pricepromo.xml?rev=1005861&r1=1005860&r2=1005861&view=diff
==============================================================================
--- ofbiz/trunk/applications/product/servicedef/services_pricepromo.xml 
(original)
+++ ofbiz/trunk/applications/product/servicedef/services_pricepromo.xml Fri Oct 
 8 15:33:03 2010
@@ -340,4 +340,11 @@ under the License.
         <attribute name="validPriceFound" type="Boolean" mode="OUT" 
optional="false"/>
         <attribute name="orderItemPriceInfos" type="java.util.List" mode="OUT" 
optional="false"/>
     </service>
+    
+    <service name="getAssociatedPriceRulesConds" engine="simple" auth="false"
+        
location="component://product/script/org/ofbiz/product/price/PriceServices.xml" 
invoke="getAssociatedPriceRulesConds">
+        <description>Set the Value options for selected Price Rule Condition 
Input</description>
+        <attribute name="inputParamEnumId" mode="IN" type="String"/>
+        <attribute name="productPriceRulesCondValues" mode="OUT" 
type="java.util.List" optional="true"/><!-- optional="true" because of quantity 
or other kind of fiels needing an input -->
+    </service>    
 </services>

Modified: 
ofbiz/trunk/applications/product/webapp/catalog/WEB-INF/actions/price/EditProductPriceRules.groovy
URL: 
http://svn.apache.org/viewvc/ofbiz/trunk/applications/product/webapp/catalog/WEB-INF/actions/price/EditProductPriceRules.groovy?rev=1005861&r1=1005860&r2=1005861&view=diff
==============================================================================
--- 
ofbiz/trunk/applications/product/webapp/catalog/WEB-INF/actions/price/EditProductPriceRules.groovy
 (original)
+++ 
ofbiz/trunk/applications/product/webapp/catalog/WEB-INF/actions/price/EditProductPriceRules.groovy
 Fri Oct  8 15:33:03 2010
@@ -18,14 +18,44 @@
  */
 
 import org.ofbiz.entity.condition.*
-
-String priceRuleId = request.getParameter("productPriceRuleId");
-if (priceRuleId) {
-    context.productPriceRule = delegator.findOne("ProductPriceRule", 
[productPriceRuleId : priceRuleId], false);
-}
+import org.ofbiz.entity.util.EntityUtil;
+import org.ofbiz.base.util.UtilMisc;
 
 context.inputParamEnums = delegator.findList("Enumeration", 
EntityCondition.makeCondition([enumTypeId : 'PROD_PRICE_IN_PARAM']), null, 
['sequenceId'], null, true);
-
 context.condOperEnums = delegator.findList("Enumeration", 
EntityCondition.makeCondition([enumTypeId : 'PROD_PRICE_COND']), null, 
['sequenceId'], null, true);
-
 context.productPriceActionTypes = delegator.findList("ProductPriceActionType", 
null, null, ['description'], null, true);
+
+String priceRuleId = request.getParameter("productPriceRuleId");
+if (priceRuleId) {
+    productPriceRules = [];
+    productPriceRules.add(delegator.findOne("ProductPriceRule", 
[productPriceRuleId : priceRuleId], false));
+    productPriceConds = 
productPriceRules[0].getRelatedCache("ProductPriceCond");
+    productPriceConds = EntityUtil.orderBy(productPriceConds, 
UtilMisc.toList("productPriceCondSeqId"));
+    productPriceActions = 
productPriceRules[0].getRelatedCache("ProductPriceAction");
+    productPriceActions = EntityUtil.orderBy(productPriceActions, 
UtilMisc.toList("productPriceActionSeqId"));
+    
+    productPriceCondAdd = [];
+    productPriceCondAdd.add(delegator.makeValue("ProductPriceCond"));
+    productPriceCondAdd[0].productPriceRuleId = priceRuleId;
+    productPriceCondAdd[0].inputParamEnumId = 
context.inputParamEnums[0].enumId;
+    productPriceCondAdd[0].operatorEnumId = context.condOperEnums[0].enumId;
+    
+    productPriceActionAdd = [];
+    productPriceActionAdd.add(delegator.makeValue("ProductPriceAction"));
+    productPriceActionAdd[0].productPriceRuleId = priceRuleId;
+    productPriceActionAdd[0].productPriceActionTypeId = 
context.productPriceActionTypes[0].productPriceActionTypeId;
+    productPriceActionAdd[0].amount = BigDecimal.ZERO;
+    
+    context.productPriceRules = productPriceRules;
+    context.productPriceConds = productPriceConds;
+    context.productPriceActions = productPriceActions;
+    context.productPriceCondAdd = productPriceCondAdd;
+    context.productPriceActionAdd = productPriceActionAdd;
+    
+} else {
+    context.productPriceRules = null;
+    context.productPriceConds = null;
+    context.productPriceActions = null;    
+    context.productPriceCondsAdd = null;
+    context.productPriceActionsAdd = null;    
+}

Added: 
ofbiz/trunk/applications/product/webapp/catalog/WEB-INF/actions/price/EditProductPriceRules_old.groovy
URL: 
http://svn.apache.org/viewvc/ofbiz/trunk/applications/product/webapp/catalog/WEB-INF/actions/price/EditProductPriceRules_old.groovy?rev=1005861&view=auto
==============================================================================
--- 
ofbiz/trunk/applications/product/webapp/catalog/WEB-INF/actions/price/EditProductPriceRules_old.groovy
 (added)
+++ 
ofbiz/trunk/applications/product/webapp/catalog/WEB-INF/actions/price/EditProductPriceRules_old.groovy
 Fri Oct  8 15:33:03 2010
@@ -0,0 +1,31 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import org.ofbiz.entity.condition.*
+
+String priceRuleId = request.getParameter("productPriceRuleId");
+if (priceRuleId) {
+    context.productPriceRule = delegator.findOne("ProductPriceRule", 
[productPriceRuleId : priceRuleId], false);
+}
+
+context.inputParamEnums = delegator.findList("Enumeration", 
EntityCondition.makeCondition([enumTypeId : 'PROD_PRICE_IN_PARAM']), null, 
['sequenceId'], null, true);
+
+context.condOperEnums = delegator.findList("Enumeration", 
EntityCondition.makeCondition([enumTypeId : 'PROD_PRICE_COND']), null, 
['sequenceId'], null, true);
+
+context.productPriceActionTypes = delegator.findList("ProductPriceActionType", 
null, null, ['description'], null, true);

Propchange: 
ofbiz/trunk/applications/product/webapp/catalog/WEB-INF/actions/price/EditProductPriceRules_old.groovy
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: 
ofbiz/trunk/applications/product/webapp/catalog/WEB-INF/actions/price/EditProductPriceRules_old.groovy
------------------------------------------------------------------------------
    svn:keywords = Date Rev Author URL Id

Propchange: 
ofbiz/trunk/applications/product/webapp/catalog/WEB-INF/actions/price/EditProductPriceRules_old.groovy
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Modified: ofbiz/trunk/applications/product/webapp/catalog/WEB-INF/controller.xml
URL: 
http://svn.apache.org/viewvc/ofbiz/trunk/applications/product/webapp/catalog/WEB-INF/controller.xml?rev=1005861&r1=1005860&r2=1005861&view=diff
==============================================================================
--- ofbiz/trunk/applications/product/webapp/catalog/WEB-INF/controller.xml 
(original)
+++ ofbiz/trunk/applications/product/webapp/catalog/WEB-INF/controller.xml Fri 
Oct  8 15:33:03 2010
@@ -1844,7 +1844,15 @@ under the License.
         <response name="success" type="view" value="EditProductPriceRules"/>
         <response name="error" type="view" value="EditProductPriceRules"/>
     </request-map>
-
+    
+    <!-- Get Values options associated with a Price Rule Condition Input -->
+    <request-map uri="getAssociatedPriceRulesConds">
+        <security https="true" auth="false"/>
+        <event type="service" invoke="getAssociatedPriceRulesConds"/>
+        <response name="success" type="request" value="json"/>
+        <response name="error" type="request" value="json"/>
+    </request-map>
+    
     <!-- ================ ProductPromoCode Requests ================= -->
     <request-map uri="FindProductPromoCode">
         <security https="true" auth="true"/>

Modified: ofbiz/trunk/applications/product/widget/catalog/CatalogMenus.xml
URL: 
http://svn.apache.org/viewvc/ofbiz/trunk/applications/product/widget/catalog/CatalogMenus.xml?rev=1005861&r1=1005860&r2=1005861&view=diff
==============================================================================
--- ofbiz/trunk/applications/product/widget/catalog/CatalogMenus.xml (original)
+++ ofbiz/trunk/applications/product/widget/catalog/CatalogMenus.xml Fri Oct  8 
15:33:03 2010
@@ -225,6 +225,12 @@ under the License.
         </menu-item>
     </menu>
 
+    <menu name="PriceRulesTabBar" extends="CommonTabBarMenu" 
extends-resource="component://common/widget/CommonMenus.xml">
+        <menu-item name="FindRules" 
title="${uiLabelMap.CommonAdd}/${uiLabelMap.ProductFindRule}">
+            <link target="FindProductPriceRules"/>
+        </menu-item>
+    </menu>
+    
     <menu name="PromoTabBar" extends="CommonTabBarMenu" 
extends-resource="component://common/widget/CommonMenus.xml">
         <menu-item name="EditProductPromo" 
title="${uiLabelMap.ProductPromotion}">
             <link target="EditProductPromo">
@@ -465,5 +471,5 @@ under the License.
         <menu-item name="FindWebAnalyticsTypes" 
title="${uiLabelMap.CommonFind}"><link 
target="FindWebAnalyticsTypes"/></menu-item>
         <menu-item name="EditWebAnalyticsType" 
title="${uiLabelMap.CommonNew}"><link 
target="EditWebAnalyticsType"/></menu-item>
     </menu>
-    
+
 </menus>

Modified: ofbiz/trunk/applications/product/widget/catalog/PriceForms.xml
URL: 
http://svn.apache.org/viewvc/ofbiz/trunk/applications/product/widget/catalog/PriceForms.xml?rev=1005861&r1=1005860&r2=1005861&view=diff
==============================================================================
--- ofbiz/trunk/applications/product/widget/catalog/PriceForms.xml (original)
+++ ofbiz/trunk/applications/product/widget/catalog/PriceForms.xml Fri Oct  8 
15:33:03 2010
@@ -51,4 +51,107 @@
         <field name="ruleName" title="${uiLabelMap.ProductName}"><text 
size="30"/></field>
         <field name="submitButton" title="${uiLabelMap.CommonAdd}"><submit 
button-type="button"/></field>
     </form>
+    
+    <!-- Below, I tried also single forms but lists are better as long as we 
have not introduced a better way to handle positions -->   
+    <form name="EditProductPriceRule" type="list" 
target="updateProductPriceRule" title="" list-name="productPriceRules" 
+        odd-row-style="alternate-row" default-table-style="basic-table 
hover-bar" separate-columns="true">
+        <field name="productPriceRuleId"><hidden/></field><!-- Users don't 
need this information there, the screen is already sufficiently complex! -->
+        <field name="ruleName" title="${uiLabelMap.CommonName}"><text 
size="25"/></field>
+        <field name="description" 
title="${uiLabelMap.CommonDescription}"><text size="60"/></field>
+        <field name="fromDate" title="${uiLabelMap.CommonFromDate}"><date-time 
type="timestamp"/></field>
+        <field name="thruDate" title="${uiLabelMap.CommonThruDate}"><date-time 
type="timestamp"/></field>        
+        <field name="submitButton" title="${uiLabelMap.CommonUpdate}" 
widget-style="smallSubmit"><submit/></field>        
+        <field 
use-when="org.ofbiz.base.util.UtilValidate.isEmpty(productPriceConds) 
&amp;&amp; org.ofbiz.base.util.UtilValidate.isEmpty(productPriceActions)"
+            name="deleteLink" title="${uiLabelMap.CommonEmptyHeader}" 
widget-style="buttontext">
+            <hyperlink target="deleteProductPriceRule" 
description="${uiLabelMap.CommonRemove}">
+                <parameter param-name="productPriceRuleId"/>
+            </hyperlink>
+        </field>        
+    </form>            
+    <form name="EditProductPriceRulesCond" type="list" 
target="updateProductPriceCond" title="" list-name="productPriceConds" 
+        odd-row-style="alternate-row" default-table-style="basic-table 
hover-bar" separate-columns="true">
+        <field name="productPriceRuleId"><hidden/></field><!-- Users don't 
need this information there, the screen is already sufficiently complex! -->
+        <field name="productPriceCondSeqId"><hidden/></field><!-- Users don't 
need this information there, the screen is already sufficiently complex! -->
+        <field name="inputParamEnumId" title="${uiLabelMap.ProductInput}">
+            <drop-down allow-empty="false" current="selected">
+                <list-options list-name="inputParamEnums" key-name="enumId" 
description="${description}"/>                
+            </drop-down>
+        </field>        
+        <field name="operatorEnumId" title="${uiLabelMap.ProductOperator}">
+            <drop-down allow-empty="false" current="selected">
+                <list-options list-name="condOperEnums" key-name="enumId" 
description="${description}"/>                
+            </drop-down>
+        </field>        
+        <field use-when="&quot;PRIP_QUANTITY&quot;.equals(inputParamEnumId) || 
&quot;PRIP_LIST_PRICE&quot;.equals(inputParamEnumId)" 
+            name="condValueInput" title="${uiLabelMap.ProductValue}">
+            <text size="10" default-value="${condValue}"/>
+        </field>                
+        <field 
+            use-when="!&quot;PRIP_QUANTITY&quot;.equals(inputParamEnumId) 
&amp;&amp; !&quot;PRIP_LIST_PRICE&quot;.equals(inputParamEnumId)" 
+            name="condValue" title="${uiLabelMap.CommonEmptyHeader}">
+            <drop-down allow-empty="false" current="selected">
+                <list-options list-name="productPriceRulesCondValues" 
key-name="condValue"/>
+            </drop-down>
+        </field>                
+        <field name="submitButton" title="${uiLabelMap.CommonUpdate}" 
widget-style="smallSubmit"><submit/></field>        
+        <field name="deleteLink" title="${uiLabelMap.CommonEmptyHeader}" 
widget-style="buttontext" widget-area-style="align-text">
+            <hyperlink target="deleteProductPriceCond" 
description="${uiLabelMap.CommonRemove}">
+                <parameter param-name="productPriceRuleId" 
from-field="productPriceCond.productPriceRuleId"/>
+                <parameter param-name="productPriceCondSeqId" 
from-field="productPriceCond.productPriceCondSeqId"/>
+            </hyperlink>
+        </field>        
+    </form>
+    <form name="AddProductPriceRulesCond" type="list" 
target="createProductPriceCond" title="" list-name="productPriceCondAdd" 
+        odd-row-style="alternate-row" default-table-style="basic-table 
hover-bar" separate-columns="true">
+        <field name="productPriceRuleId"><hidden/></field><!-- Users don't 
need this information there, the screen is already sufficiently complex! -->
+        <field name="new"><display 
default-value="${uiLabelMap.ProductPriceRulesNewCond}"/></field>
+        <field name="inputParamEnumId" title="${uiLabelMap.ProductInput}">
+            <drop-down allow-empty="false">
+                <list-options list-name="inputParamEnums" key-name="enumId" 
description="${description}"/>                
+            </drop-down>
+        </field>        
+        <field name="operatorEnumId" title="${uiLabelMap.ProductOperator}">
+            <drop-down allow-empty="false">
+                <list-options list-name="condOperEnums" key-name="enumId" 
description="${description}"/>                
+            </drop-down>
+        </field>        
+        <field name="condValueInput" title="${uiLabelMap.ProductValue}"><text 
size="10"/></field>
+        <field name="condValue" title="${uiLabelMap.CommonEmptyHeader}">
+            <drop-down allow-empty="false">
+                <list-options list-name="productPriceRulesCondValues" 
key-name="condValue"/>                
+            </drop-down>
+        </field>
+        <field name="submitButton" title="${uiLabelMap.CommonAdd}" 
widget-style="smallSubmit"><submit/></field>        
+    </form>
+    <form name="EditProductPriceRulesAction" type="list" 
target="updateProductPriceAction" title="" list-name="productPriceActions" 
+        odd-row-style="alternate-row" default-table-style="basic-table 
hover-bar" separate-columns="true">
+        <field name="productPriceRuleId"><hidden/></field><!-- Users don't 
need this information there, the screen is already sufficiently complex! -->
+        <field name="productPriceActionSeqId"><hidden/></field><!-- Users 
don't need this information there, the screen is already sufficiently complex! 
-->
+        <field name="productPriceActionTypeId" 
title="${uiLabelMap.ProductActionType}">
+            <drop-down allow-empty="false" current="selected">
+                <list-options list-name="productPriceActionTypes" 
key-name="productPriceActionTypeId" description="${description}"/>              
  
+            </drop-down>
+        </field>        
+        <field name="amount" title="${uiLabelMap.ProductValue}"><text/></field>
+        <field name="submitButton" title="${uiLabelMap.CommonUpdate}" 
widget-style="smallSubmit"><submit/></field>        
+        <field name="deleteLink" title="${uiLabelMap.CommonEmptyHeader}" 
widget-style="buttontext" widget-area-style="align-text">
+            <hyperlink target="deleteProductPriceAction" 
description="${uiLabelMap.CommonRemove}">
+                <parameter param-name="productPriceRuleId" 
from-field="productPriceAction.productPriceRuleId"/>
+                <parameter param-name="productPriceActionSeqId" 
from-field="productPriceAction.productPriceActionSeqId"/>
+            </hyperlink>
+        </field>        
+    </form>        
+    <form name="AddProductPriceRulesAction" type="list" 
target="createProductPriceAction" title="" list-name="productPriceActionAdd" 
+        odd-row-style="alternate-row" default-table-style="basic-table 
hover-bar" separate-columns="true">            
+        <field name="productPriceRuleId"><hidden/></field><!-- Users don't 
need this information there, the screen is already sufficiently complex! -->
+        <field name="new"><display 
default-value="${uiLabelMap.ProductPriceRulesNewAction}"/></field>
+        <field name="productPriceActionTypeId" 
title="${uiLabelMap.ProductActionType}">
+            <drop-down allow-empty="false">
+                <list-options list-name="productPriceActionTypes" 
key-name="productPriceActionTypeId" description="${description}"/>              
  
+            </drop-down>
+        </field>        
+        <field name="amount" title="${uiLabelMap.ProductValue}"><text/></field>
+        <field name="submitButton" title="${uiLabelMap.CommonAdd}" 
widget-style="smallSubmit"><submit/></field>
+    </form>        
+    
 </forms>

Modified: ofbiz/trunk/applications/product/widget/catalog/PriceScreens.xml
URL: 
http://svn.apache.org/viewvc/ofbiz/trunk/applications/product/widget/catalog/PriceScreens.xml?rev=1005861&r1=1005860&r2=1005861&view=diff
==============================================================================
--- ofbiz/trunk/applications/product/widget/catalog/PriceScreens.xml (original)
+++ ofbiz/trunk/applications/product/widget/catalog/PriceScreens.xml Fri Oct  8 
15:33:03 2010
@@ -67,13 +67,14 @@ under the License.
             </widgets>
         </section>
     </screen>
-    <screen name="EditProductPriceRules">
+    <!-- Old screen kept for now, in case some would prefer the old way. 
Another option is to use an input field with Id instead of a drop-down in the 
new screen below (see also setPriceRulesCondEventJs.ftl and top of 
getAssociatedPriceRulesConds service) -->
+    <!--screen name="EditProductPriceRules">
         <section>
             <actions>
                 <set field="titleProperty" 
value="PageTitleEditProductPriceRules"/>
                 <set field="headerItem" value="pricerules"/>
 
-                <script 
location="component://product/webapp/catalog/WEB-INF/actions/price/EditProductPriceRules.groovy"/>
+                <script 
location="component://product/webapp/catalog/WEB-INF/actions/price/EditProductPriceRules_old.groovy"/>
             </actions>
             <widgets>
                 <decorator-screen name="CommonPriceDecorator">
@@ -85,5 +86,41 @@ under the License.
                 </decorator-screen>
             </widgets>
         </section>
+    </screen-->
+    <screen name="EditProductPriceRules">
+        <section>
+            <actions>
+                <set field="titleProperty" 
value="PageTitleEditProductPriceRules"/>
+                <set field="headerItem" value="pricerules"/>
+
+                <script 
location="component://product/webapp/catalog/WEB-INF/actions/price/EditProductPriceRules.groovy"/>
+            </actions>
+            <widgets>
+                <decorator-screen name="CommonPriceDecorator">
+                    <decorator-section name="body">
+                        <platform-specific><html><html-template 
location="component://common/webcommon/includes/setPriceRulesCondEventJs.ftl"/></html></platform-specific>
+                        <include-menu name="PriceRulesTabBar" 
location="component://product/widget/catalog/CatalogMenus.xml"/>
+                        <screenlet title="${uiLabelMap.ProductPriceRuleId} 
[${parameters.productPriceRuleId}]">
+                            <label style="h6" 
text="${uiLabelMap.ProductConditionsActionsRemoveBefore}"/>
+                            <horizontal-separator/>
+                            <include-form name="EditProductPriceRule" 
location="component://product/widget/catalog/PriceForms.xml"/>
+                            <horizontal-separator/>
+                            <label style="h6" 
text="${uiLabelMap.ProductConditionsThenActions}"/>
+                            <horizontal-separator/>
+                            <screenlet title="${uiLabelMap.ProductConditions}">
+                                <include-form name="EditProductPriceRulesCond" 
location="component://product/widget/catalog/PriceForms.xml"/>
+                                <horizontal-separator/>
+                                <include-form name="AddProductPriceRulesCond" 
location="component://product/widget/catalog/PriceForms.xml"/>
+                            </screenlet>
+                            <screenlet title="${uiLabelMap.ProductActions}">
+                                <include-form 
name="EditProductPriceRulesAction" 
location="component://product/widget/catalog/PriceForms.xml"/>
+                                <horizontal-separator/>
+                                <include-form 
name="AddProductPriceRulesAction" 
location="component://product/widget/catalog/PriceForms.xml"/>
+                            </screenlet>
+                        </screenlet>
+                    </decorator-section>                    
+                </decorator-screen>
+            </widgets>
+        </section>
     </screen>
 </screens>

Modified: 
ofbiz/trunk/framework/common/webcommon/includes/setDependentDropdownValuesJs.ftl
URL: 
http://svn.apache.org/viewvc/ofbiz/trunk/framework/common/webcommon/includes/setDependentDropdownValuesJs.ftl?rev=1005861&r1=1005860&r2=1005861&view=diff
==============================================================================
--- 
ofbiz/trunk/framework/common/webcommon/includes/setDependentDropdownValuesJs.ftl
 (original)
+++ 
ofbiz/trunk/framework/common/webcommon/includes/setDependentDropdownValuesJs.ftl
 Fri Oct  8 15:33:03 2010
@@ -20,9 +20,9 @@ under the License.
 document.observe('dom:loaded', function() {
     if ($('${dependentForm}')) {
         Event.observe($('${dependentForm}_${mainId}'), 'change', function() {
-            getDependentDropdownValues('${requestName}', '${paramKey}', 
'${dependentForm}_${mainId}', '${dependentForm}_${dependentId}', 
'${responseName}', '${dependentId}', '${descName}', '', '');
+            getDependentDropdownValues('${requestName}', '${paramKey}', 
'${dependentForm}_${mainId}', '${dependentForm}_${dependentId}', 
'${responseName}', '${dependentId}', '${descName}');
         });
-        getDependentDropdownValues('${requestName}', '${paramKey}', 
'${dependentForm}_${mainId}', '${dependentForm}_${dependentId}', 
'${responseName}', '${dependentId}', '${descName}', 
'${selectedDependentOption}', '');
+        getDependentDropdownValues('${requestName}', '${paramKey}', 
'${dependentForm}_${mainId}', '${dependentForm}_${dependentId}', 
'${responseName}', '${dependentId}', '${descName}', 
'${selectedDependentOption}');
     }
 })
 </script>
\ No newline at end of file

Added: 
ofbiz/trunk/framework/common/webcommon/includes/setPriceRulesCondEventJs.ftl
URL: 
http://svn.apache.org/viewvc/ofbiz/trunk/framework/common/webcommon/includes/setPriceRulesCondEventJs.ftl?rev=1005861&view=auto
==============================================================================
--- 
ofbiz/trunk/framework/common/webcommon/includes/setPriceRulesCondEventJs.ftl 
(added)
+++ 
ofbiz/trunk/framework/common/webcommon/includes/setPriceRulesCondEventJs.ftl 
Fri Oct  8 15:33:03 2010
@@ -0,0 +1,26 @@
+<script type="text/javascript">
+document.observe('dom:loaded', function() {
+
+<#if 0 < productPriceConds.size()>
+  <#list 0..productPriceConds.size()-1 as i>
+    if ($('EditProductPriceRulesCond_o_${i}')) {    
+      Event.observe($('EditProductPriceRulesCond_inputParamEnumId_o_${i}'), 
'change', function() {
+    <#if 'PRIP_QUANTITY' != productPriceConds[i].inputParamEnumId && 
'PRIP_LIST_PRICE' != productPriceConds[i].inputParamEnumId>
+        getDependentDropdownValues('getAssociatedPriceRulesConds', 
'inputParamEnumId', 'EditProductPriceRulesCond_inputParamEnumId_o_${i}', 
'EditProductPriceRulesCond_condValue_o_${i}', 'productPriceRulesCondValues', 
'condValue_o_${i}', 'description');
+    </#if>
+      });
+    <#if 'PRIP_QUANTITY' != productPriceConds[i].inputParamEnumId && 
'PRIP_LIST_PRICE' != productPriceConds[i].inputParamEnumId>
+      getDependentDropdownValues('getAssociatedPriceRulesConds', 
'inputParamEnumId', 'EditProductPriceRulesCond_inputParamEnumId_o_${i}', 
'EditProductPriceRulesCond_condValue_o_${i}', 'productPriceRulesCondValues', 
'condValue_o_${i}', 'description', '${productPriceConds[i].condValue}');
+    </#if>
+    }
+  </#list>        
+</#if>  
+  if ($('AddProductPriceRulesCond_o_0')) {
+    $('AddProductPriceRulesCond_condValueInput_o_0').hide();
+    Event.observe($('AddProductPriceRulesCond_inputParamEnumId_o_0'), 
'change', function() {
+      getDependentDropdownValues('getAssociatedPriceRulesConds', 
'inputParamEnumId', 'AddProductPriceRulesCond_inputParamEnumId_o_0', 
'AddProductPriceRulesCond_condValue_o_0', 'productPriceRulesCondValues', 
'condValue_o_0', 'description', '', '', '', '', 
'AddProductPriceRulesCond_condValueInput_o_0');
+    });
+    getDependentDropdownValues('getAssociatedPriceRulesConds', 
'inputParamEnumId', 'AddProductPriceRulesCond_inputParamEnumId_o_0', 
'AddProductPriceRulesCond_condValue_o_0', 'productPriceRulesCondValues', 
'condValue_o_0', 'description', '', '', '', '', 
'AddProductPriceRulesCond_condValueInput_o_0');
+  }
+})
+</script>

Propchange: 
ofbiz/trunk/framework/common/webcommon/includes/setPriceRulesCondEventJs.ftl
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: 
ofbiz/trunk/framework/common/webcommon/includes/setPriceRulesCondEventJs.ftl
------------------------------------------------------------------------------
    svn:keywords = Date Rev Author URL Id

Propchange: 
ofbiz/trunk/framework/common/webcommon/includes/setPriceRulesCondEventJs.ftl
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Modified: 
ofbiz/trunk/framework/images/webapp/images/getDependentDropdownValues.js
URL: 
http://svn.apache.org/viewvc/ofbiz/trunk/framework/images/webapp/images/getDependentDropdownValues.js?rev=1005861&r1=1005860&r2=1005861&view=diff
==============================================================================
--- ofbiz/trunk/framework/images/webapp/images/getDependentDropdownValues.js 
(original)
+++ ofbiz/trunk/framework/images/webapp/images/getDependentDropdownValues.js 
Fri Oct  8 15:33:03 2010
@@ -29,7 +29,7 @@
 // callback     = optional javascript function called at end
 // hide         = optional boolean argument, if true the dependent drop-down 
field (targetField) will be hidden when no options are available else only 
disabled. False by default.
 // hideTitle    = optional boolean argument (hide must be set to true), if 
true the title of the dependent drop-down field (targetField) will be hidden 
when no options are available else only disabled. False by default.
-// inputField  = optional boolean argument 
+// inputField   = optional name of an input field    
 //                               this is to handle a specific case where an 
input field is needed instead of a drop-down when no values are returned by the 
request
 //                               this will be maybe extended later to use an 
auto-completed drop-down or a lookup, instead of straight drop-down currently, 
when there are too much values to populate
 //                               this is e.g. currently used in the Product 
Price Rules screen
@@ -46,18 +46,6 @@ function getDependentDropdownValues(requ
         onSuccess: function(transport) {
             var data = transport.responseText.evalJSON(true);                  
   
             list = data[responseName];
-            // this is to handle a specific case where an input field is 
needed instead of a drop-down when no values are returned by the request (else 
if allow-empty="true" is used autoComplete handle the case)
-            // this will be maybe extended later to use an autocompleted 
drop-down or a lookup, instead of drop-down currently, when there are too much 
values to populate
-            if (!list && inputField) {
-                               $(targetField).hide();
-                               $(targetField).insert({after: new 
Element('input', {name : arguments[9], id : targetField + '_input', size : 
3})}); 
-               return;
-            } else if (inputField) { 
-               if ($(targetField + '_input')) { 
-                       $(targetField + '_input').remove();                     
-                                       $(targetField).show();
-               }
-            }
             list.each(function(value) {
                if (typeof value == 'string') {                 
                        values = value.split(': ');
@@ -100,7 +88,17 @@ function getDependentDropdownValues(requ
                eval(callback);
         },
            onComplete: function() {
-                       $(targetField).update(optionList);
+            // this is to handle a specific case where an input field is 
needed instead of a drop-down when no values are returned by the request (else 
if allow-empty="true" is used autoComplete handle the case)
+            // this could be extended later to use an autocompleted drop-down 
or a lookup, instead of drop-down currently, when there are too much values to 
populate
+            // Another option is to use an input field with Id instead of a 
drop-down, see setPriceRulesCondEventJs.ftl and top of 
getAssociatedPriceRulesConds service
+            if (!list && inputField) {
+                $(targetField).hide();
+                $(inputField).show();
+            } else if (inputField) { 
+                $(inputField).hide();
+                $(targetField).show();
+            }
+            $(targetField).update(optionList);
                }        
     });
 }


Reply via email to