details:   /erp/devel/pi/rev/c47f101fe0bb
changeset: 10726:c47f101fe0bb
user:      Martin Taal <martin.taal <at> openbravo.com>
date:      Thu Feb 17 08:50:51 2011 +0100
summary:   Small code streamlining

details:   /erp/devel/pi/rev/c11e5fc332d9
changeset: 10727:c11e5fc332d9
user:      Martin Taal <martin.taal <at> openbravo.com>
date:      Thu Feb 17 08:52:47 2011 +0100
summary:   Prevent extra requests from picklist

details:   /erp/devel/pi/rev/9b32e12288e7
changeset: 10728:9b32e12288e7
user:      Martin Taal <martin.taal <at> openbravo.com>
date:      Thu Feb 17 08:53:22 2011 +0100
summary:   Solve issue with failure on product selector

diffstat:

 
modules/org.openbravo.client.application/web/org.openbravo.client.application/js/ob-standard-view.js
         |   4 +-
 
modules/org.openbravo.client.application/web/org.openbravo.client.application/js/ob-view-grid.js
             |  17 ++---
 
modules/org.openbravo.service.json/src/org/openbravo/service/json/QueryBuilder.java
                          |  28 +++++++--
 
modules/org.openbravo.userinterface.selector/web/org.openbravo.userinterface.selector/js/ob-selector-item.js
 |  13 +++-
 4 files changed, 42 insertions(+), 20 deletions(-)

diffs (124 lines):

diff -r 063e4b88d526 -r 9b32e12288e7 
modules/org.openbravo.client.application/web/org.openbravo.client.application/js/ob-standard-view.js
--- 
a/modules/org.openbravo.client.application/web/org.openbravo.client.application/js/ob-standard-view.js
      Wed Feb 16 20:07:42 2011 +0100
+++ 
b/modules/org.openbravo.client.application/web/org.openbravo.client.application/js/ob-standard-view.js
      Thu Feb 17 08:53:22 2011 +0100
@@ -1465,7 +1465,9 @@
       component = this.viewGrid.getEditForm();
       form = component;
     } else if (this.isShowingForm) {
-      record = isc.addProperties({}, this.viewGrid.getSelectedRecord(), 
this.viewForm.getValues());
+      // note on purpose not calling form.getValues() as this will cause extra 
requests 
+      // in case of a picklist
+      record = isc.addProperties({}, this.viewGrid.getSelectedRecord(), 
this.viewForm.values);
       component = this.viewForm;
       form = component;
     } else {
diff -r 063e4b88d526 -r 9b32e12288e7 
modules/org.openbravo.client.application/web/org.openbravo.client.application/js/ob-view-grid.js
--- 
a/modules/org.openbravo.client.application/web/org.openbravo.client.application/js/ob-view-grid.js
  Wed Feb 16 20:07:42 2011 +0100
+++ 
b/modules/org.openbravo.client.application/web/org.openbravo.client.application/js/ob-view-grid.js
  Thu Feb 17 08:53:22 2011 +0100
@@ -1285,16 +1285,15 @@
   },
   
   showInlineEditor: function(rowNum, colNum, newCell, newRow, suppressFocus){
-  
-    if (this.getEditForm() && newRow) {
-      this.getEditForm().clearErrors();
+    if (newRow) {
+      if (this.getEditForm()) {
+        this.getEditForm().clearErrors();
+      }
+      // if the focus does not get suppressed then the clicked field will 
receive focus
+      // and won't be disabled so the user can already start typing      
+      suppressFocus = true; 
     }
-    // if the focus does not get supressed then the clicked field will receive 
focus
-    // and won't be disabled so the user can already start typing
-    if (newRow) {
-      suppressFocus = true;
-    }
-    
+
     var ret = this.Super('showInlineEditor', [rowNum, colNum, newCell, newRow, 
suppressFocus]);
     if (!newRow) {
       return ret;
diff -r 063e4b88d526 -r 9b32e12288e7 
modules/org.openbravo.service.json/src/org/openbravo/service/json/QueryBuilder.java
--- 
a/modules/org.openbravo.service.json/src/org/openbravo/service/json/QueryBuilder.java
       Wed Feb 16 20:07:42 2011 +0100
+++ 
b/modules/org.openbravo.service.json/src/org/openbravo/service/json/QueryBuilder.java
       Thu Feb 17 08:53:22 2011 +0100
@@ -203,7 +203,9 @@
             + " not part of identifier of " + property.getEntity());
         final String prefix;
         final int index = leftWherePart.lastIndexOf(".");
-        if (index == -1) {
+        if (key.equals(JsonConstants.IDENTIFIER)) {
+          prefix = getMainAlias() + ".";
+        } else if (index == -1) {
           prefix = "";
         } else {
           // the + 1 makes sure that the dot is included
@@ -224,7 +226,18 @@
 
       // NOTE the typedParameters.add call must be done after the call to
       // getTypedParameterAlias, this to get the correct alias codes
-      if (!property.isPrimitive()) {
+      if (key.equals(JsonConstants.IDENTIFIER)) {
+        if (textMatching == TextMatching.exact) {
+          sb.append(leftWherePart + " = " + getTypedParameterAlias());
+          typedParameters.add(value);
+        } else if (textMatching == TextMatching.startsWith) {
+          sb.append("upper(" + leftWherePart + ") like " + 
getTypedParameterAlias());
+          typedParameters.add(value.toUpperCase() + "%");
+        } else {
+          sb.append("upper(" + leftWherePart + ") like " + 
getTypedParameterAlias());
+          typedParameters.add("%" + value.toUpperCase().replaceAll(" ", "%") + 
"%");
+        }
+      } else if (!property.isPrimitive()) {
         // an in parameter use it...
         if (value.contains(JsonConstants.IN_PARAMETER_SEPARATOR)) {
           final List<String> values = new ArrayList<String>();
@@ -528,15 +541,18 @@
   // note prefix includes the dot at the end
   private String createIdentifierLeftClause(List<Property> 
identifierProperties, String prefix) {
     final StringBuilder sb = new StringBuilder();
-    if (identifierProperties.size() == 1) {
-      return prefix + identifierProperties.get(0).getName();
-    }
     for (Property prop : identifierProperties) {
       if (sb.length() > 0) {
         sb.append(" || '" + IdentifierProvider.SEPARATOR + "' || ");
       }
       // note to_char is added to handle null values correctly
-      sb.append("COALESCE(" + prefix + prop.getName() + ",'')");
+      if (prop.getReferencedProperty() == null) {
+        sb.append("COALESCE(to_char(" + prefix + prop.getName() + "),'')");
+      } else {
+        final List<Property> newIdentifierProperties = 
prop.getReferencedProperty().getEntity()
+            .getIdentifierProperties();
+        sb.append(createIdentifierLeftClause(newIdentifierProperties, prefix + 
prop.getName() + "."));
+      }
     }
 
     return "(" + sb.toString() + ")";
diff -r 063e4b88d526 -r 9b32e12288e7 
modules/org.openbravo.userinterface.selector/web/org.openbravo.userinterface.selector/js/ob-selector-item.js
--- 
a/modules/org.openbravo.userinterface.selector/web/org.openbravo.userinterface.selector/js/ob-selector-item.js
      Wed Feb 16 20:07:42 2011 +0100
+++ 
b/modules/org.openbravo.userinterface.selector/web/org.openbravo.userinterface.selector/js/ob-selector-item.js
      Thu Feb 17 08:53:22 2011 +0100
@@ -390,12 +390,17 @@
   },
   
   getPickListFilterCriteria: function(){
-    var criteria = this.Super('getPickListFilterCriteria'), defValue, prop;
+    var criteria = isc.addProperties({}, 
this.Super('getPickListFilterCriteria', arguments) || {}), defValue, prop;
     
-    if (!criteria) {
-      criteria = {};
+    // sometimes the value is passed as a filter criteria
+    // remove it
+    if (this.getValueFieldName() && criteria[this.getValueFieldName()]) {
+      criteria[this.getValueFieldName()] = null;
     }
-    
+            
+    // do not prevent the count operation
+    criteria[isc.OBViewGrid.NO_COUNT_PARAMETER] = 'false';
+
     // also add the special ORG parameter
     if (this.form.getField('organization')) {
       criteria[OB.Constants.ORG_PARAMETER] = 
this.form.getValue('organization');

------------------------------------------------------------------------------
The ultimate all-in-one performance toolkit: Intel(R) Parallel Studio XE:
Pinpoint memory and threading errors before they happen.
Find and fix more than 250 security defects in the development cycle.
Locate bottlenecks in serial and parallel code that limit performance.
http://p.sf.net/sfu/intel-dev2devfeb
_______________________________________________
Openbravo-commits mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/openbravo-commits

Reply via email to