details:   https://code.openbravo.com/erp/devel/pi/rev/832f9c67f42b
changeset: 14196:832f9c67f42b
user:      Martin Taal <martin.taal <at> openbravo.com>
date:      Sat Nov 05 23:36:04 2011 +0100
summary:   Fixes issue 18841: Upgrade smartclient workaround issues
Fixes issue 18765: AND and OR logic does not work in column filter expressions

diffstat:

 
modules/org.openbravo.userinterface.smartclient/web/org.openbravo.userinterface.smartclient/js/ob-smartclient.js
 |  318 +++++----
 1 files changed, 164 insertions(+), 154 deletions(-)

diffs (truncated from 422 to 300 lines):

diff -r 5e7f093f2199 -r 832f9c67f42b 
modules/org.openbravo.userinterface.smartclient/web/org.openbravo.userinterface.smartclient/js/ob-smartclient.js
--- 
a/modules/org.openbravo.userinterface.smartclient/web/org.openbravo.userinterface.smartclient/js/ob-smartclient.js
  Sat Nov 05 23:25:14 2011 +0100
+++ 
b/modules/org.openbravo.userinterface.smartclient/web/org.openbravo.userinterface.smartclient/js/ob-smartclient.js
  Sat Nov 05 23:36:04 2011 +0100
@@ -33,11 +33,6 @@
 
 isc.Canvas.addProperties({
   
-  // workaround for this issue:
-  // http://forums.smartclient.com/showthread.php?p=75007#post75007
-  // https://issues.openbravo.com/view.php?id=18841
-  cancelNativeScrollOnKeyDown: false,
-  
   // make sure that the datasources are also destroyed
   _original_destroy: isc.Canvas.getPrototype().destroy,
   destroy: function() {
@@ -105,7 +100,7 @@
   // this is a copy of the FormItem.parseValueExpressions to support
   // and/or logic for enum and text fields
   parseOBValueExpressions: function(value, fieldName) {
-    var type = this.getType(),
+    var type = this.getType(), i,
       isValidLogicType = (isc.SimpleType.inheritsFrom(type, 'enum') ||
           isc.SimpleType.inheritsFrom(type, 'text') ||
           isc.SimpleType.inheritsFrom(type, 'integer') ||
@@ -114,216 +109,242 @@
       ),
       opIndex = isc.DynamicForm.getOperatorIndex(),
       validOps = isc.getKeys(opIndex),
-      result = { operator: 'and', criteria: [], fieldName: fieldName},
+      result = { operator: "and", criteria: [] },
       crit = result.criteria,
-      valueParts = [], i,
-      ds = isc.DS.get(this.form.expressionDataSource || this.form.dataSource),
-      defOpName, defOp, insensitive, field, skipTheseOps,
-      valuePart, subCrit, isDateField, useDefaultOperator, opKey, key,
-      operator, operators, op, ops, wildCard,
-      parts, partCrit, part, partIndex,
-      hasPrefix, hasSuffix;
-    
+      valueParts = [],
+      allowEx = this._shouldAllowExpressions(),
+      ds = isc.DS.get(this.form.expressionDataSource || this.form.dataSource)
+    ;
+  
     if (!value) {
       value = this.getValue();
     }
     if (!value) {
       return;
     }
-    
+  
     if (!isc.isA.String(value)) {
-      value += '';
+      value += "";
     }
     
-    defOpName = this.getOperator();
+    var tempOps, tempOp;
+    
+    var defOpName = this.getOperator();
     if (defOpName) {
       validOps.add(defOpName);
     }
+  
+    var defOp = ds ? ds.getSearchOperator(defOpName) : { id: defOpName };
     
-    defOp = ds ? ds.getSearchOperator(defOpName) : { id: defOpName };
-    
-    insensitive = defOp.caseInsensitive;
-    
-    if (isValidLogicType && value.contains(' and ')) {
-        valueParts = value.split(' and ');
-    } else if (isValidLogicType && value.contains(' or ')) {
-        valueParts = value.split(' or ');
-        result.operator = 'or';
-    } else if (value.contains('...')) {
-        valueParts = value.split('...');
+    var field, insensitive = defOp.caseInsensitive;
+    var partIndex, parts, partCrit, part; 
+
+    if (isValidLogicType && value.contains(" and ")) {
+        valueParts = value.split(" and ");
+    } else if (isValidLogicType && value.contains(" or ")) {
+        valueParts = value.split(" or ");
+        result.operator = "or";
+    } else if (value.contains("...")) {
+        valueParts = value.split("...");
         if (valueParts.length === 2) {
-            var tempOps = opIndex['...'],
-                tempOp;
-    
+            tempOps = opIndex["..."];
+  
             if (tempOps) {
-              tempOp = (insensitive ? tempOps.find('caseInsensitive', true) : 
tempOps[0]);
+              tempOp = (insensitive ? tempOps.find("caseInsensitive", true) : 
tempOps[0]);
             }
-    
+  
             field = ds ? ds.getField(fieldName) : null;
-    
-            if (field && isc.SimpleType.inheritsFrom(field.type, 'date')) {
+  
+            if (field && isc.SimpleType.inheritsFrom(field.type, "date")) {
                 valueParts[0] = new Date(Date.parse(valueParts[0]));
                 valueParts[0].logicalDate = true;
                 valueParts[1] = new Date(Date.parse(valueParts[1]));
                 valueParts[1].logicalDate = true;
-            } else if (field && field.type === 'text') {
+            } else if (field && field.type === "text") {
                 
                 if (!valueParts[1].endsWith(this._betweenInclusiveEndCrit)) {
                     valueParts[1] += this._betweenInclusiveEndCrit;
                 }
             }
-    
+  
             return { fieldName: fieldName, operator: tempOp.ID, 
                 start: valueParts[0], end: valueParts[1] };
         }
     } else {
         valueParts = [value];
     }
-    
-    skipTheseOps = [ ' and ', ' or ', '...' ];
-    
-    for (i = 0; i < valueParts.length; i++) {
-        valuePart = valueParts[i];
-        subCrit = { fieldName: fieldName };
+  
+    var skipTheseOps = [ " and ", " or " ];
+  
+    for (i = 0; i<valueParts.length; i++) {
+        var key, valuePart = valueParts[i],
+            subCrit = { fieldName: fieldName };
+            
         field = ds ? ds.getField(fieldName) : null;
-        isDateField = (field ? field && 
isc.SimpleType.inheritsFrom(field.type, 'date') : false);
-    
-        useDefaultOperator = true;
-        for (opKey in opIndex) {
-          if (opIndex.hasOwnProperty(opKey)) {
-            if (!opKey) {
-              continue;
-            }
-            
-            operators = opIndex[opKey];
-  
-            if (operators && operators.length) {
-                operator = operators.find('caseInsensitive', insensitive) || 
operators[0];
-            }
-    
-            if (!operator || !operator.symbol || 
skipTheseOps.contains(operator.symbol)) {
-              continue;
-            }
-            if (validOps.contains(operator.symbol) && 
-                      (isc.isA.String(valuePart) && 
valuePart.startsWith(operator.symbol))) {
-              useDefaultOperator = false;
-              break;
-            }
-          }
-        }
-        if (useDefaultOperator) {
-          valuePart = defOp.symbol + valuePart;
-        }
+        var isDateField = (field ? field && 
isc.SimpleType.inheritsFrom(field.type, "date") : false),
+          valueHasExpression = false;
         
         for (key in opIndex) {
           if (opIndex.hasOwnProperty(key)) {
-    
             if (!key) {
               continue;
             }
-    
-            ops = opIndex[key];
-            wildCard = false;
-    
-            if (key === '==' && isc.isA.String(valuePart) && 
valuePart.startsWith('=') && 
-                    !valuePart.startsWith('==') && 
!valuePart.startsWith('=(')) 
+  
+            var ops = opIndex[key],
+                wildCard = false,
+                op
+            ;
+  
+            if (key === "==" && isc.isA.String(valuePart) && 
valuePart.startsWith("=") && 
+                    !valuePart.startsWith("==") && 
!valuePart.startsWith("=(")) 
             {
-              wildCard = true;
+                wildCard = true;
             }
-    
+  
             if (ops && ops.length) {
-              op = ops.find('caseInsensitive', insensitive) || ops[0];
+                op = ops.find("caseInsensitive", insensitive) || ops[0];
             }
-    
+  
             if (!op || !op.symbol || skipTheseOps.contains(op.symbol)) {
               continue;
             }
             
             if (validOps.contains(op.symbol) && (
-                  (isc.isA.String(valuePart) && 
valuePart.startsWith(op.symbol)) 
-                  || wildCard))
+                    (isc.isA.String(valuePart) && 
(valuePart.startsWith(op.symbol) || 
+                        
+                        (op.symbol === "..." && valuePart.contains(op.symbol)))
+                    ) 
+                    || wildCard))
             {
-              valuePart = valuePart.substring(op.symbol.length - (wildCard ? 1 
: 0));
-              if (op.closingSymbol) {
-                // this is a containing operator (inSet, notInSet), with 
opening and 
-                // closing symbols...  check that the value endsWith the 
correct 
-                // closing symbol and strip it off - op.processValue() will 
split 
-                // the string for us later
-                if (valuePart.endsWith(op.closingSymbol)) {
-                    valuePart = valuePart.substring(0, valuePart.length - 
op.closingSymbol.length);
+                valueHasExpression = true;
+            
+                if (valuePart.startsWith(op.symbol)) {
+                    valuePart = valuePart.substring(op.symbol.length - 
(wildCard ? 1 : 0));
                 }
-              }
   
-              if (isDateField) {
-                valuePart = new Date(Date.parse(valuePart));
-                valuePart.logicalDate = true;
-              }
+                if (op.closingSymbol) {
+                    // this is a containing operator (inSet, notInSet), with 
opening and 
+                    // closing symbols...  check that the value endsWith the 
correct 
+                    // closing symbol and strip it off - op.processValue() 
will split 
+                    // the string for us later
+                    if (valuePart.endsWith(op.closingSymbol)) {
+                        valuePart = valuePart.substring(0, valuePart.length - 
op.closingSymbol.length);
+                    }
+                }
   
-              subCrit.operator = op.ID;
+                if (valuePart.contains("...")) {
+                    // allow range operators as well as conjunctives
+                    var rangeValueParts = valuePart.split("...");
+                    if (rangeValueParts.length === 2) {
+                        tempOps = opIndex["..."];
   
-              if (op.processValue) {
-                valuePart = op.processValue(valuePart, ds);
-              }
+                        if (tempOps) {
+                          tempOp = (insensitive ? 
tempOps.find("caseInsensitive", true) : tempOps[0]);
+                        }
   
-              if (op.wildCard && isc.isA.String(valuePart) && 
valuePart.contains(op.wildCard)) {
-                // this is an operator that supports wildCards (equals, 
notEquals)...
-                
-                parts = valuePart.split(op.wildCard);
+                        field = ds ? ds.getField(fieldName) : null;
   
-                if (parts.length > 1) {
-                  for (partIndex=0; partIndex<parts.length; partIndex++) {
-                    part = parts[partIndex];
+                        if (field && isc.SimpleType.inheritsFrom(field.type, 
"date")) {
+                            rangeValueParts[0] = new 
Date(Date.parse(rangeValueParts[0]));
+                            rangeValueParts[0].logicalDate = true;
+                            rangeValueParts[1] = new 
Date(Date.parse(rangeValueParts[1]));
+                            rangeValueParts[1].logicalDate = true;
+                        } else if (field && field.type === "text") {
+                            
+                            if 
(!rangeValueParts[1].endsWith(this._betweenInclusiveEndCrit)) {
+                                rangeValueParts[1] += 
this._betweenInclusiveEndCrit;
+                            }
+                        }
   
-                    if (!part || part.length === 0) {
-                      continue;
+                        result.criteria.add({ fieldName: fieldName, operator: 
tempOp.ID, 
+                            start: rangeValueParts[0], end: rangeValueParts[1] 
+                        });
+  
+                        continue;
                     }
+                }
   
-                    partCrit = { fieldName: fieldName, value: part };
+                if (isDateField) {
+                    valuePart = new Date(Date.parse(valuePart));
+                    valuePart.logicalDate = true;
+                }
   
-                    hasPrefix = partIndex > 0;
-                    hasSuffix = parts.length - 1 > partIndex;
+                subCrit.operator = op.ID;
   
-                    if (hasPrefix && hasSuffix) {
-                      // this is a contains criteria

------------------------------------------------------------------------------
RSA(R) Conference 2012
Save $700 by Nov 18
Register now
http://p.sf.net/sfu/rsa-sfdev2dev1
_______________________________________________
Openbravo-commits mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/openbravo-commits

Reply via email to