You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ofbiz.apache.org by jl...@apache.org on 2010/05/23 12:08:22 UTC

svn commit: r947392 - in /ofbiz/trunk/framework: common/webcommon/includes/lookup.ftl example/widget/example/FormWidgetExampleForms.xml images/webapp/images/fieldlookup.js

Author: jleroux
Date: Sun May 23 10:08:21 2010
New Revision: 947392

URL: http://svn.apache.org/viewvc?rev=947392&view=rev
Log:
* Especially fix a bug in fieldlookup.js. 
When using description-field-name in a layered lookup called from another layered lookup (recursively or not) the description-field-name parameter (target2) in the call from the 2d lookup button was not modified, therefore the link was not working.

Miscellaneous:
* Format and fix some typos in fieldlookup.js
* Removes now useless commented out functions set_value and set_values in lookup.ftl
* Improves comments in FormWidgetExampleForms.xml

Modified:
    ofbiz/trunk/framework/common/webcommon/includes/lookup.ftl
    ofbiz/trunk/framework/example/widget/example/FormWidgetExampleForms.xml
    ofbiz/trunk/framework/images/webapp/images/fieldlookup.js

Modified: ofbiz/trunk/framework/common/webcommon/includes/lookup.ftl
URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/common/webcommon/includes/lookup.ftl?rev=947392&r1=947391&r2=947392&view=diff
==============================================================================
--- ofbiz/trunk/framework/common/webcommon/includes/lookup.ftl (original)
+++ ofbiz/trunk/framework/common/webcommon/includes/lookup.ftl Sun May 23 10:08:21 2010
@@ -85,29 +85,7 @@ under the License.
              src.style.backgroundColor = bkColor;
         }
         // function passing selected value to calling window
-     /*   function set_value(value) {
-                if (!obj_caller) return;
-                setSourceColor(obj_caller.target);
-                obj_caller.target.value = value;
-                obj_caller.target.fire("lookup:changed");
-                if (obj_caller.target.onchange != null) {
-                    obj_caller.target.onchange();                       
-                }
-                window.close();
-        }
-       // function passing selected value to calling window
-        function set_values(value, value2) {
-                set_value(value);
-                if (!obj_caller.target2) return;
-                if (obj_caller.target2 == null) return;
-                setSourceColor(obj_caller.target2);
-                obj_caller.target2.value = value2;
-                obj_caller.target2.fire("lookup:changed");
-                if (obj_caller.target2.onchange != null) {
-                    obj_caller.target2.onchange();
-                }
-        }
-      */  function set_multivalues(value) {
+        function set_multivalues(value) {
             obj_caller.target.value = value;
             var thisForm = obj_caller.target.form;
             var evalString = "";

Modified: ofbiz/trunk/framework/example/widget/example/FormWidgetExampleForms.xml
URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/example/widget/example/FormWidgetExampleForms.xml?rev=947392&r1=947391&r2=947392&view=diff
==============================================================================
--- ofbiz/trunk/framework/example/widget/example/FormWidgetExampleForms.xml (original)
+++ ofbiz/trunk/framework/example/widget/example/FormWidgetExampleForms.xml Sun May 23 10:08:21 2010
@@ -282,12 +282,12 @@ under the License.
 
     <!-- Lookup Layer Example -->
     <form name="ExampleLookupFields" type="single" title="">
-        <!-- Lookup (in a popup windows, old style) -->
-        <!-- Using separated labels is not recommended (it's better using sentences than words for translation) but here we use only Common labels to avoid dependencies from application to framework -->
+        <!-- Old style lookup (in a popup window) -->
+        <!-- Using separated labels is not recommended (it's better using sentences than words for translation) -->
         <field name="partyIdFrom" title="${uiLabelMap.CommonPartyID} ${uiLabelMap.CommonFrom}"><!-- we use partyIdFrom here only to differentiate from the other partyId field we use below, ie partyIdTo-->
             <lookup target-form-name="LookupPartyExample" presentation="window"/>
         </field>
-        <!-- Standard Lookup in a layer (new style)-->
+        <!-- Standard lookup (in a layer)-->
         <!-- passes the name in one and the id in another field -->
         <field name="partyName" title="${uiLabelMap.CommonName}">
             <lookup target-form-name="LookupPartyExampleByName" description-field-name="partyIdTo"/>

Modified: ofbiz/trunk/framework/images/webapp/images/fieldlookup.js
URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/images/webapp/images/fieldlookup.js?rev=947392&r1=947391&r2=947392&view=diff
==============================================================================
--- ofbiz/trunk/framework/images/webapp/images/fieldlookup.js (original)
+++ ofbiz/trunk/framework/images/webapp/images/fieldlookup.js Sun May 23 10:08:21 2010
@@ -60,6 +60,7 @@ function call_fieldlookupLayer3(target, 
     if (isEmpty(target) || isEmpty(target2) || isEmpty(viewName)) {
         return lookup_error("Lookup can't be created, one of these variables is missing: target=" + target + " target2=" + target2 + " viewName=" + viewName);
     }
+        
     var fieldLookupPopup = new FieldLookupPopup(target, viewName, lookupWidth, lookupHeight, lookupPosition, fadeBackground);
     fieldLookupPopup.showLookup();
     this.target = target;
@@ -83,10 +84,8 @@ function fieldLookup1(obj_target, args) 
     this.popup2 = lookup_popup2;
     
     // validate input parameters
-    if (! obj_target)
-    return lookup_error("Error calling the field lookup: no target control specified");
-    if (obj_target.value == null)
-    return lookup_error("Error calling the field lookup: parameter specified is not valid target control");
+    if (! obj_target) return lookup_error("Error calling the field lookup: no target control specified");
+    if (obj_target.value == null) return lookup_error("Error calling the field lookup: parameter specified is not valid target control");
     //this.target = obj_target;
     targetW = obj_target;
     
@@ -100,16 +99,12 @@ function fieldLookup2(obj_target, obj_ta
     this.popup = lookup_popup1;
     this.popup2 = lookup_popup2;
     // validate input parameters
-    if (! obj_target)
-    return lookup_error("Error calling the field lookup: no target control specified");
-    if (obj_target.value == null)
-    return lookup_error("Error calling the field lookup: parameter specified is not valid target control");
+    if (! obj_target) return lookup_error("Error calling the field lookup: no target control specified");
+    if (obj_target.value == null) return lookup_error("Error calling the field lookup: parameter specified is not valid target control");
     targetW = obj_target;
     // validate input parameters
-    if (! obj_target2)
-    return lookup_error("Error calling the field lookup: no target2 control specified");
-    if (obj_target2.value == null)
-    return lookup_error("Error calling the field lookup: parameter specified is not valid target2 control");
+    if (! obj_target2) return lookup_error("Error calling the field lookup: no target2 control specified");
+    if (obj_target2.value == null) return lookup_error("Error calling the field lookup: parameter specified is not valid target2 control");
     target2 = obj_target2;
     
     
@@ -182,7 +177,6 @@ var FieldLookupCounter = Class.create({
         for (itm in this.refArr) {
             count++;
         }
-        
         return count;
     },
     
@@ -308,7 +302,7 @@ var FieldLookupPopup = Class.create({
         //set the layer position
         this.setPosition(lookupDiv);
 
-        this.divRef = lookupDiv;
+        this.divRef = lookupDiv;        
 
         //make layer draggable
         this.makeDraggable(lookupDiv);
@@ -528,7 +522,7 @@ var FieldLookupPopup = Class.create({
 });
 
 /**
-* returns true if a Stirng is empty
+* returns true if a String is empty
 * @param value - String value
 * @return
 */
@@ -557,7 +551,7 @@ function getNextCollapseSeq() {
     return COLLAPSE;
 }
 
-//modify epande/ collapse button
+//modify expande/collapse button
 function modifyCollapseable(lookupDiv){
     if (!lookupDiv) {
         return;
@@ -618,7 +612,8 @@ function modifySubmitButton (lookupDiv) 
         var newLookups = $A(lookupDiv.getElementsByClassName('field-lookup'));
         newLookups.each(function(newLookup){
             var link = newLookup.getElementsByTagName('a')[0].href;
-            newLookup.getElementsByTagName('a')[0].href = link.replace('document.' + oldFormName, 'document.'+'form_' + GLOBAL_LOOKUP_REF.getReference(ACTIVATED_LOOKUP).globalRef);
+            var replaced = new  RegExp('document.' + oldFormName, 'g');
+            newLookup.getElementsByTagName('a')[0].href = link.replace(replaced, 'document.'+'form_' + GLOBAL_LOOKUP_REF.getReference(ACTIVATED_LOOKUP).globalRef);
         });
 
         //disable the form action
@@ -652,7 +647,7 @@ function modifySubmitButton (lookupDiv) 
                     }
                 });
                 ele.parentNode.removeChild(ele);
-                // modifay nav-pager
+                // modify nav-pager
                 var navPager = null;
                 navPager = lookupDiv.getElementsByClassName("nav-pager");
                 if (navPager.length > 0) {
@@ -733,17 +728,15 @@ function modifySubmitButton (lookupDiv) 
                                     cellElement.href = "javascript:lookupAjaxRequest('" + liSub + "')";
                                 }
                             }
-                            
                         }
                     }
-                }
-                
+                }                
             }
         }
     }
 }
 /**
- * Createan ajax Request
+ * Create an ajax Request
  */
 function lookupAjaxRequest(request) {
     lookupDiv = (GLOBAL_LOOKUP_REF.getReference(ACTIVATED_LOOKUP).divRef);
@@ -809,7 +802,7 @@ function lookupFormAjaxRequest(formActio
 
             lookupCont.insert({
                 bottom: "" + formRequest + ""
-            });
+            });           
             GLOBAL_LOOKUP_REF.getReference(ACTIVATED_LOOKUP).contentRef = lookupCont;
             modifySubmitButton(lookupDiv);
         }
@@ -871,10 +864,10 @@ function setSourceColor(src) {
 // function passing selected value to calling window
 function set_value (value) {
     if(GLOBAL_LOOKUP_REF.getReference(ACTIVATED_LOOKUP)){
-    obj_caller.target = $(GLOBAL_LOOKUP_REF.getReference(ACTIVATED_LOOKUP).parentTarget);
+        obj_caller.target = $(GLOBAL_LOOKUP_REF.getReference(ACTIVATED_LOOKUP).parentTarget);
     }
     else{
-    obj_caller.target = obj_caller.targetW;        
+        obj_caller.target = obj_caller.targetW;
     }    
     var target = obj_caller.target;
     
@@ -885,10 +878,10 @@ function set_value (value) {
 // function passing selected value to calling window
 function set_values (value, value2) {
     if(GLOBAL_LOOKUP_REF.getReference(ACTIVATED_LOOKUP)){
-    obj_caller.target = $(GLOBAL_LOOKUP_REF.getReference(ACTIVATED_LOOKUP).parentTarget.id);
+        obj_caller.target = $(GLOBAL_LOOKUP_REF.getReference(ACTIVATED_LOOKUP).parentTarget.id);
     }
     else{
-    obj_caller.target = obj_caller.targetW;        
+        obj_caller.target = obj_caller.targetW;        
     }
     var target = obj_caller.target;
     var target2 = obj_caller.target2;