Author: jonesde
Date: Thu Jul 29 07:53:06 2010
New Revision: 980348

URL: http://svn.apache.org/viewvc?rev=980348&view=rev
Log:
Fixed two bugs with autocomplete functionality: init script in selectall.js was 
not doing the search/replace properly for ampersands, in the 
FindAutocompleteOptions.groovy script the andExprs were not really anded 
together so split into the or and main and lists and assembled the conditions 
properly, which will fix the conditionFields and the andCondition fields

Modified:
    
ofbiz/trunk/framework/common/webcommon/WEB-INF/actions/includes/FindAutocompleteOptions.groovy
    ofbiz/trunk/framework/images/webapp/images/selectall.js

Modified: 
ofbiz/trunk/framework/common/webcommon/WEB-INF/actions/includes/FindAutocompleteOptions.groovy
URL: 
http://svn.apache.org/viewvc/ofbiz/trunk/framework/common/webcommon/WEB-INF/actions/includes/FindAutocompleteOptions.groovy?rev=980348&r1=980347&r2=980348&view=diff
==============================================================================
--- 
ofbiz/trunk/framework/common/webcommon/WEB-INF/actions/includes/FindAutocompleteOptions.groovy
 (original)
+++ 
ofbiz/trunk/framework/common/webcommon/WEB-INF/actions/includes/FindAutocompleteOptions.groovy
 Thu Jul 29 07:53:06 2010
@@ -27,16 +27,21 @@ import org.ofbiz.entity.condition.Entity
 import org.ofbiz.entity.condition.EntityFunction;
 import org.ofbiz.entity.condition.EntityOperator;
 
-def andExprs = [];
+def mainAndConds = [];
+def orExprs = [];
 def entityName = context.entityName;
 def searchFields = context.searchFields;
 def displayFields = context.displayFields ?: searchFields;
+
 def searchValueFieldName = parameters.searchValueField;
+def fieldValue = null;
 if (searchValueFieldName) fieldValue = parameters.get(searchValueFieldName);
+
 def searchType = context.searchType;
+def displayFieldsSet = null;
 
 if (searchFields && fieldValue) {
-    searchFieldsList = StringUtil.toList(searchFields);
+    def searchFieldsList = StringUtil.toList(searchFields);
     displayFieldsSet = StringUtil.toSet(displayFields);
     returnField = searchFieldsList[0]; //default to first element of 
searchFields
     displayFieldsSet.add(returnField); //add it to select fields, in case it 
is missing
@@ -51,10 +56,10 @@ if (searchFields && fieldValue) {
     }
     searchFieldsList.each { fieldName ->
         if ("EQUALS".equals(searchType)) {
-            
andExprs.add(EntityCondition.makeCondition(EntityFieldValue.makeFieldValue(returnField),
 EntityOperator.EQUALS, searchValue));    
+            
orExprs.add(EntityCondition.makeCondition(EntityFieldValue.makeFieldValue(returnField),
 EntityOperator.EQUALS, searchValue));    
             return;//in case of EQUALS, we search only a match for the 
returned field
         } else {
-            
andExprs.add(EntityCondition.makeCondition(EntityFunction.UPPER(EntityFieldValue.makeFieldValue(fieldName)),
 EntityOperator.LIKE, searchValue));
+            
orExprs.add(EntityCondition.makeCondition(EntityFunction.UPPER(EntityFieldValue.makeFieldValue(fieldName)),
 EntityOperator.LIKE, searchValue));
         }        
     }
 }
@@ -67,17 +72,19 @@ def conditionFields = context.conditionF
 if (conditionFields) {
     // these fields are for additonal conditions, this is a Map of name/value 
pairs
     for (conditionFieldEntry in conditionFields.entrySet()) {
-        
andExprs.add(EntityCondition.makeCondition(EntityFieldValue.makeFieldValue(conditionFieldEntry.getKey()),
 EntityOperator.EQUALS, conditionFieldEntry.getValue()));    
+        
mainAndConds.add(EntityCondition.makeCondition(EntityFieldValue.makeFieldValue(conditionFieldEntry.getKey()),
 EntityOperator.EQUALS, conditionFieldEntry.getValue()));    
     }
 }
 
-if (andExprs && entityName && displayFieldsSet) {
-    entityConditionList = EntityCondition.makeCondition(andExprs, 
EntityOperator.OR);
+if (orExprs && entityName && displayFieldsSet) {
+    mainAndConds.add(EntityCondition.makeCondition(orExprs, 
EntityOperator.OR));
 
-    //if there is an extra condition, add it to main condition
-    if (context.andCondition && context.andCondition  instanceof 
EntityCondition) {
-        entityConditionList = 
EntityCondition.makeCondition(context.andCondition, entityConditionList);
+    //if there is an extra condition, add it to main condition list
+    if (context.andCondition && context.andCondition instanceof 
EntityCondition) {
+        mainAndConds.add(context.andCondition);
     }
+    
+    def entityConditionList = EntityCondition.makeCondition(mainAndConds, 
EntityOperator.AND);
 
     Integer autocompleterViewSize = 
Integer.valueOf(context.autocompleterViewSize ?: 10);
     EntityFindOptions findOptions = new EntityFindOptions();

Modified: ofbiz/trunk/framework/images/webapp/images/selectall.js
URL: 
http://svn.apache.org/viewvc/ofbiz/trunk/framework/images/webapp/images/selectall.js?rev=980348&r1=980347&r2=980348&view=diff
==============================================================================
--- ofbiz/trunk/framework/images/webapp/images/selectall.js (original)
+++ ofbiz/trunk/framework/images/webapp/images/selectall.js Thu Jul 29 07:53:06 
2010
@@ -353,7 +353,7 @@ function ajaxSubmitFormUpdateAreas(form,
   * form of: areaId, target, target parameters [, areaId, target, target 
parameters...].
 */
 function ajaxAutoCompleter(areaCsvString, showDescription) {
-    var areaArray = areaCsvString.replace('&','&').split(",");
+    var areaArray = areaCsvString.replace(/&/g,'&').split(",");
     var numAreas = parseInt(areaArray.length / 3);
     for (var i = 0; i < numAreas * 3; i = i + 3) {
         var optionsDivId = areaArray[i] + "_autoCompleterOptions";


Reply via email to