Hi Scott,

Yes, the service attribute is intentional. For the moment it does nothing in 
OFBiz. The related logic is in
getDependentDropdownValues.js. This logic is not a calculation logic but an UI 
logic.

The idea was to refactor the Price Rules, UIs (and later Promo's). Instead of 
using an input field in the right part of conditions
we use dependent dropdowns. Also I used Forms instead of current complex to 
read/maintain FTL. The result is not only a better UI,
but also better code. For the quantity I had to use an input field. This is why 
there are these small changes in services and
getDependentDropdownValues.js

Also this works well in our custom application because there are not too much 
products, categories, etc. It would work also OOTB.
But in some case dependent dropdowns will not work (too much records). So I 
will also introduce a mechanism to allow the choice of
the type of the rendered right field. Either a dependent dropdown, a simple input field (like for quantity) or an autocompleted field
for larger sets of records (working like the autocompleted lookup field, ie 
supporting search on one to many fields values and
returning only teen (or a wanted number) records.

So I could not put all in this commit but to be able to test the changes in the custom application I committed the needed. When it will be valdated in the custom application, I will enhance and contribute the rest to OFBiz. I will also enhance the jQuery branch and use the them for the Promo UI everywhere.

Jacques

Scott Gray wrote:
You may want to consider discussing the changes with the community before 
proceeding much further.  Was that service attribute
intentional? What does it do? Why commit it without the logic?

Thanks
Scott

HotWax Media
http://www.hotwaxmedia.com

On 18/09/2010, at 8:33 AM, [email protected] wrote:

Author: jleroux
Date: Fri Sep 17 20:33:40 2010
New Revision: 998305

URL: http://svn.apache.org/viewvc?rev=998305&view=rev
Log:
This introduces changes that will be used soon (after some client tests) to 
refactor the Price Rules UI. They introduces any
functional changes yet, all new things are optional.

Modified:
   ofbiz/trunk/applications/product/config/ProductUiLabels.xml
   
ofbiz/trunk/applications/product/script/org/ofbiz/product/price/PriceServices.xml
   ofbiz/trunk/applications/product/servicedef/services_pricepromo.xml
   ofbiz/trunk/framework/common/config/CommonUiLabels.xml
   ofbiz/trunk/framework/images/webapp/images/getDependentDropdownValues.js

Modified: ofbiz/trunk/applications/product/config/ProductUiLabels.xml
URL:
http://svn.apache.org/viewvc/ofbiz/trunk/applications/product/config/ProductUiLabels.xml?rev=998305&r1=998304&r2=998305&view=diff
============================================================================== 
---
ofbiz/trunk/applications/product/config/ProductUiLabels.xml (original) +++
ofbiz/trunk/applications/product/config/ProductUiLabels.xml Fri Sep 17 20:33:40 
2010 @@ -6591,6 +6591,17 @@
        <value xml:lang="th">à¸sัญà¸Sี</value>
        <value xml:lang="zh">è´¦æ^·</value>
    </property>
+    <property key="ProductActionType">
+        <value xml:lang="de">Aktionstyp</value>
+        <value xml:lang="en">Action Type</value>
+        <value xml:lang="es">Tipo de Acción</value>
+        <value xml:lang="fr">Type d'action</value>
+        <value xml:lang="it">Tipo Azione</value>
+        <value xml:lang="ro">Tip Actiune</value>
+        <value xml:lang="ru">Тип дейсÑ,вия</value>
+        <value xml:lang="th">à¸^ำà¸Tวà¸Tà¸>ระà¹?ภ
à¸-การà¸-ำà¸?าà¸T</value>
+        <value xml:lang="zh">æ"ä½oç±»åz<</value>
+    </property>
    <property key="ProductActionTypeAmount">
        <value xml:lang="de">Aktionstyp Betrag</value>
        <value xml:lang="en">Action Type Amount</value>
@@ -8952,6 +8963,10 @@
        <value xml:lang="th">à¹?à¸?ืà¹^ภà¸Tà¹"à¸,</value>
        <value xml:lang="zh">条件</value>
    </property>
+    <property key="ProductConditionsThenActions">
+        <value xml:lang="en">If all conditions are true, then actions will be 
executed (logical conjunction, ie conditions are
'ANDED' between them, so are actions))</value> +        <value xml:lang="fr">Si 
toutes les conditions sont vérifiées, alors
les actions seront exécutées (conjonction, autrement dit ET logique entre 
conditions, de même pour les actions)</value> +
    </property> <property key="ProductConfigItem">
        <value xml:lang="de">Konfigurationsposition</value>
        <value xml:lang="en">Config Item</value>
@@ -12104,6 +12119,17 @@
        <value 
xml:lang="th">สà¸-าà¸Tะรายการสิà¸Tà¸"à¹?าà¸"à¸?à¹?หลืà¸
 à¹?à¸sืà¹?à¸
        à¸?à¸.à¹?à¸T</value> <value xml:lang="zh">å^å§<åº"å 
~æ~Zç»?çS¶æ?</value>
    </property>
+    <property key="ProductInput">
+        <value xml:lang="de">Eingang</value>
+        <value xml:lang="en">Input</value>
+        <value xml:lang="es">Entrada</value>
+        <value xml:lang="fr">Donnée</value>
+        <value xml:lang="it">Input</value>
+        <value xml:lang="ro">Input</value>
+        <value xml:lang="ru">Ð~сÑ
од. паÑ?амеÑ,Ñ?</value>
+        <value xml:lang="th">à¸,à¹?ภมูล</value>
+        <value xml:lang="zh">æ.°æ®</value>
+    </property>
    <property key="ProductInputOperatorValue">
        <value xml:lang="de">Eingang, Operator, Wert</value>
        <value xml:lang="en">Input, Operator Value</value>
@@ -12115,6 +12141,28 @@
        <value xml:lang="th">à¹fสà¹^, à¸oูà¹?à¸"วà¸sà¸"ุม และ 
à¸"à¹^า</value>
        <value xml:lang="zh">è¾"å
¥ã?æ"ä½o符å'Oæ.°å?¼</value>
    </property>
+    <property key="ProductOperator">
+        <value xml:lang="de">Operator</value>
+        <value xml:lang="en">Operator</value>
+        <value xml:lang="es">Operador</value>
+        <value xml:lang="fr">Opérateur</value>
+        <value xml:lang="it">Operatore</value>
+        <value xml:lang="ro">Operator si Valoare</value>
+        <value xml:lang="ru">опеÑ?аÑ,оÑ?</value>
+        <value xml:lang="th">à¸oูà¹?à¸>ระกภà¸sการ</value>
+        <value xml:lang="zh">å?¼</value>
+    </property>
+    <property key="ProductValue">
+        <value xml:lang="de">Wert</value>
+        <value xml:lang="en">Value</value>
+        <value xml:lang="es">Valor</value>
+        <value xml:lang="fr">Valeur</value>
+        <value xml:lang="it">Valore</value>
+        <value xml:lang="ro">Valoare</value>
+        <value xml:lang="ru">знаÑ?ение</value>
+        <value xml:lang="th">มูลà¸"à¹^า</value>
+        <value xml:lang="zh">ç®-å </value>
+    </property>
    <property key="ProductInsertDefaultImageUrl">
        <value xml:lang="de">Standart Bild URL einfügen</value>
        <value xml:lang="en">Insert Default Image URL</value>
@@ -15929,6 +15977,18 @@
        <value xml:lang="th">à¸"ุà¸"à¹"มà¹^มีการภ
à¸Tุญาà¸.à¸-ึà¸?à¸,à¹?à¸
        มูลราà¸"าà¸-ีà¹^รักษาà¹"วà¹?. ("CATALOG_PRICE_MAINT" 
à¸.à¹?ภà¸?การ)</value> <value
    xml:lang="zh">ä½ æ²¡æo?æféTç»´æS¤ä»·æ ¼ä¿¡æ¯ã?, 
(éo?要"CATALOG_PRICE_MAINT")</value> </property>
+    <property key="ProductPriceRuleId">
+        <value xml:lang="de">Preisregel [ID]</value>
+        <value xml:lang="en">Edit Price Rule [ID]</value>
+        <value xml:lang="es">Regla de precio [CÃ"DIGO]</value>
+        <value xml:lang="fr">Modifier la règle de prix [Réf.]</value>
+        <value xml:lang="it">Regola Prezzo [Codice]</value>
+        <value xml:lang="nl">Prijsregel [ID]</value>
+        <value xml:lang="ro">Regula Pret [Cod]</value>
+        <value xml:lang="ru">пÑ?авила Ñ?енообÑ?азования 
[Ðsод]</value>
+        <value xml:lang="th">à¸Sืà¹^ภà¸,à¹?ภกำหà¸Tà¸"ราà¸"า 
[รหัส]</value>
+        <value xml:lang="zh">ä»·æ ¼è§"å^T[å,è?fã?,]</value>
+    </property>
    <property key="ProductPriceRuleNameId">
        <value xml:lang="de">Preisregel Name [ID]</value>
        <value xml:lang="en">Price Rule Name [ID]</value>
@@ -15953,6 +16013,14 @@
        <value xml:lang="th">à¸,à¹?ภกำหà¸Tà¸"ราà¸"า</value>
        <value xml:lang="zh">ä»·æ ¼è§"å^T</value>
    </property>
+    <property key="ProductPriceRulesNewAction">
+        <value xml:lang="en">Add a New Action</value>
+        <value xml:lang="fr">Ajout d'une action</value>
+    </property>
+    <property key="ProductPriceRulesNewCond">
+        <value xml:lang="en">Add a New Condition</value>
+        <value xml:lang="fr">Ajout d'une condition</value>
+    </property>
    <property key="ProductPriceTitle1">
        <value xml:lang="en">Price charge</value>
        <value xml:lang="fr">Frais lié au prix</value>

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=998305&r1=998304&r2=998305&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 Sep 17 20:33:40 2010 @@ -178,6 +178,9 @@
        under the License. <check-permission 
permission="CATALOG_PRICE_MAINT"><fail-property resource="ProductUiLabels"
        property="ProductPriceMaintPermissionError"/></check-permission> 
<check-errors/>

+        <if-not-empty field="parameters.condValueInput">
+            <set field="parameters.condValue" 
from-field="parameters.condValueInput"/>
+        </if-not-empty>
        <make-value value-field="newEntity" entity-name="ProductPriceCond"/>
        <set-nonpk-fields map="parameters" value-field="newEntity"/>
        <set-pk-fields map="parameters" value-field="newEntity"/>
@@ -191,6 +194,9 @@ under the License.
        <check-permission permission="CATALOG_PRICE_MAINT"><fail-property 
resource="ProductUiLabels"
        property="ProductPriceMaintPermissionError"/></check-permission> 
<check-errors/>

+        <if-not-empty field="parameters.condValueInput">
+            <set field="parameters.condValue" 
from-field="parameters.condValueInput"/>
+        </if-not-empty>
        <make-value entity-name="ProductPriceCond" value-field="lookupPKMap"/>
        <set-pk-fields map="parameters" value-field="lookupPKMap"/>
        <find-by-primary-key entity-name="ProductPriceCond" map="lookupPKMap" 
value-field="lookedUpValue"/>

Modified: ofbiz/trunk/applications/product/servicedef/services_pricepromo.xml
URL:
http://svn.apache.org/viewvc/ofbiz/trunk/applications/product/servicedef/services_pricepromo.xml?rev=998305&r1=998304&r2=998305&view=diff
============================================================================== 
---
ofbiz/trunk/applications/product/servicedef/services_pricepromo.xml (original) 
+++
ofbiz/trunk/applications/product/servicedef/services_pricepromo.xml Fri Sep 17 
20:33:40 2010 @@ -89,6 +89,7 @@ under the License.
        <description>Create an ProductPriceCond</description>
        <auto-attributes include="pk" mode="IN" optional="false"/>
        <auto-attributes include="nonpk" mode="IN" optional="true"/>
+        <attribute name="condValueInput" type="String" mode="IN" 
optional="true"></attribute>
        <override name="productPriceCondSeqId" mode="OUT"/>
    </service>
    <service name="updateProductPriceCond" default-entity-name="ProductPriceCond" 
engine="simple"
@@ -96,6 +97,7 @@ under the License.
        <description>Update an ProductPriceCond</description>
        <auto-attributes include="pk" mode="IN" optional="false"/>
        <auto-attributes include="nonpk" mode="IN" optional="true"/>
+        <attribute name="condValueInput" type="String" mode="IN" 
optional="true"></attribute>
    </service>
    <service name="deleteProductPriceCond" default-entity-name="ProductPriceCond" 
engine="simple"
                
location="component://product/script/org/ofbiz/product/price/PriceServices.xml" 
invoke="deleteProductPriceCond"
auth="true">

Modified: ofbiz/trunk/framework/common/config/CommonUiLabels.xml
URL: 
http://svn.apache.org/viewvc/ofbiz/trunk/framework/common/config/CommonUiLabels.xml?rev=998305&r1=998304&r2=998305&view=diff
==============================================================================
--- ofbiz/trunk/framework/common/config/CommonUiLabels.xml (original)
+++ ofbiz/trunk/framework/common/config/CommonUiLabels.xml Fri Sep 17 20:33:40 
2010
@@ -4599,6 +4599,10 @@
        <value 
xml:lang="th">à¹"มà¹^มีรหัสà¹"à¸>รษà¸"ียà¹O</value>
        <value xml:lang="zh">没æo?é,®æ"¿åo°å?</value>
    </property>
+    <property key="CommonNoOptions">
+        <value xml:lang="en">No options: _NA_</value>
+        <value xml:lang="fr">Aucun option: _NA_</value>
+    </property>
    <property key="CommonNoStatesProvinces">
        <value xml:lang="en">No States/Provinces exist: _NA_</value>
        <value xml:lang="fr">Aucun état ou province: _NA_</value>

Modified: 
ofbiz/trunk/framework/images/webapp/images/getDependentDropdownValues.js
URL:
http://svn.apache.org/viewvc/ofbiz/trunk/framework/images/webapp/images/getDependentDropdownValues.js?rev=998305&r1=998304&r2=998305&view=diff
============================================================================== 
---
ofbiz/trunk/framework/images/webapp/images/getDependentDropdownValues.js 
(original) +++
ofbiz/trunk/framework/images/webapp/images/getDependentDropdownValues.js Fri 
Sep 17 20:33:40 2010 @@ -27,10 +27,12 @@
// descName     = name of the dependent dropdown description
// selected     = optional name of a selected option
// callback     = optional javascript function called at end
-function getDependentDropdownValues(request, paramKey, paramField, 
targetField, responseName, keyName, descName, selected,
callback) { +// inputField   = optional name of an input field to use instead 
of a dropdown (this will be extended later to use
an of autocompleted dropdown, instead of dropdown or a lookup, when there are 
too much values to populate) +// hide         =
optional argument, if true the dependend dropdown field (targetField) will be 
hidden when no options are available else only
disabled. False by default. +function getDependentDropdownValues(request, 
paramKey, paramField, targetField, responseName,
keyName, descName, selected, callback, hide) { // parameters
var params = new Array();
- params[paramKey] = $F(paramField);
+ params[paramKey] = $F(paramField);

    var optionList = [];
    var requestToSend = request;
@@ -40,6 +42,17 @@ 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, uses inputField for the field name
+            if (!list) {
+ $(targetField).hide();
+ $(targetField).insert({after: new Element('input', {name : inputField, id : 
targetField + '_input', size : 3})});
+            return;
+            } else {
+            if ($(targetField + '_input')) {
+            $(targetField + '_input').remove();
+ $(targetField).show();
+            }
+            }
            list.each(function(value) {
            if (typeof value == 'string') {
                values = value.split(': ');
@@ -57,14 +70,20 @@ function getDependentDropdownValues(requ
            }
            });
            $(targetField).update(optionList);
-            if ((list.size() < 1) || ((list.size() == 1) && 
list[0].indexOf("_NA_") >=0)) {
-                if ($(targetField).visible()) {
-                    Effect.Fade(targetField, {duration: 1.5});
-                }
+            if ((list.size() < 1) || ((list.size() == 1) && 
list[0].indexOf("_NA_") >=0)) {
+            Form.Element.disable(targetField);
+            if (hide) {
+ if ($(targetField).visible()) {
+ Effect.Fade(targetField, {duration: 1.5});
+ }
+ }
            } else {
-                if (!$(targetField).visible()) {
-                    Effect.Appear(targetField, {duration: 0.0});
-                }
+            Form.Element.enable(targetField);
+            if (hide) {
+                 if (!$(targetField).visible()) {
+                     Effect.Appear(targetField, {duration: 0.0});
+                 }
+            }
            }
            if (callback != null)
            eval(callback);


Reply via email to