details:   https://code.openbravo.com/erp/devel/pi/rev/5d04ccfa2cd8
changeset: 15624:5d04ccfa2cd8
user:      Augusto Mauch <augusto.mauch <at> openbravo.com>
date:      Mon Feb 27 11:18:21 2012 +0100
summary:   Related to issue 19805: Modify grid properties of String and Foreign 
Key fields

Include info about the length of ForeignKeyUIDefinition in the 
getGridFieldProperties method. Edit the info about the length of 
StringUIDefinition so it is taken from field.getDisplayedLength() istead of 
field.getColumn().getLength(). This length info is then used to select the 
field that will be automatically expanded in the grid (if any).

details:   https://code.openbravo.com/erp/devel/pi/rev/4d25a7e6f421
changeset: 15625:4d25a7e6f421
user:      Augusto Mauch <augusto.mauch <at> openbravo.com>
date:      Mon Feb 27 11:30:01 2012 +0100
summary:   Fixes issue 19805: Fix function that sorts an array by the length 
property

To decide which field should be automatically expanded in the field, the array 
that contains all the fields is sorted by the length property. Then the 
available field with the highest length will the one being auto expanded. The 
function used to sort the array was faulty, now it is fixed: it puts first in 
descending order the fields that have defined the length property, and after 
them it puts the fields that do not have that property defined.

diffstat:

 
modules/org.openbravo.client.application/web/org.openbravo.client.application/js/main/ob-standard-view.js
 |  8 ++++----
 
modules/org.openbravo.client.kernel/src/org/openbravo/client/kernel/reference/ForeignKeyUIDefinition.java
 |  8 +++++++-
 
modules/org.openbravo.client.kernel/src/org/openbravo/client/kernel/reference/StringUIDefinition.java
     |  5 ++++-
 3 files changed, 15 insertions(+), 6 deletions(-)

diffs (58 lines):

diff -r 14313dc2eac4 -r 4d25a7e6f421 
modules/org.openbravo.client.application/web/org.openbravo.client.application/js/main/ob-standard-view.js
--- 
a/modules/org.openbravo.client.application/web/org.openbravo.client.application/js/main/ob-standard-view.js
 Mon Feb 27 10:30:45 2012 +0100
+++ 
b/modules/org.openbravo.client.application/web/org.openbravo.client.application/js/main/ob-standard-view.js
 Mon Feb 27 11:30:01 2012 +0100
@@ -2108,12 +2108,12 @@
         return 0;
       }
       if (!t1) {
+        return 1;
+      }
+      if (!t2) {
         return -1;
       }
-      if (!t2) {
-        return 1;
-      }
-      if (t1 < t2) {
+      if (t1 > t2) {
         return -1;
       } else if (t1 === t2) {
         return 0;
diff -r 14313dc2eac4 -r 4d25a7e6f421 
modules/org.openbravo.client.kernel/src/org/openbravo/client/kernel/reference/ForeignKeyUIDefinition.java
--- 
a/modules/org.openbravo.client.kernel/src/org/openbravo/client/kernel/reference/ForeignKeyUIDefinition.java
 Mon Feb 27 10:30:45 2012 +0100
+++ 
b/modules/org.openbravo.client.kernel/src/org/openbravo/client/kernel/reference/ForeignKeyUIDefinition.java
 Mon Feb 27 11:30:01 2012 +0100
@@ -48,12 +48,18 @@
   public String getGridFieldProperties(Field field) {
     final Property prop = 
KernelUtils.getInstance().getPropertyFromColumn(field.getColumn());
 
+    Long length = field.getDisplayedLength();
+    if (length == null || length == 0) {
+      length = field.getColumn().getLength();
+    }
+    String lengthProperty = length != null ? ", length:" + length : "";
+
     // only output when really needed
     String displayField = "";
     if (getDisplayFieldName(field, prop) != null) {
       displayField = ", displayField: '" + getDisplayFieldName(field, prop) + 
"'";
     }
-    return displayField + ",fkField: true" + 
super.getGridFieldProperties(field)
+    return displayField + lengthProperty + ",fkField: true" + 
super.getGridFieldProperties(field)
         + getShowHoverGridFieldSettings(field);
   }
 
diff -r 14313dc2eac4 -r 4d25a7e6f421 
modules/org.openbravo.client.kernel/src/org/openbravo/client/kernel/reference/StringUIDefinition.java
--- 
a/modules/org.openbravo.client.kernel/src/org/openbravo/client/kernel/reference/StringUIDefinition.java
     Mon Feb 27 10:30:45 2012 +0100
+++ 
b/modules/org.openbravo.client.kernel/src/org/openbravo/client/kernel/reference/StringUIDefinition.java
     Mon Feb 27 11:30:01 2012 +0100
@@ -44,7 +44,10 @@
 
   @Override
   public String getGridFieldProperties(Field field) {
-    Long length = field.getColumn().getLength();
+    Long length = field.getDisplayedLength();
+    if (length == null || length == 0) {
+      length = field.getColumn().getLength();
+    }
 
     // custom override
     if (field.getColumn().getDBColumnName().compareToIgnoreCase("documentno") 
== 0) {

------------------------------------------------------------------------------
Try before you buy = See our experts in action!
The most comprehensive online learning library for Microsoft developers
is just $99.99! Visual Studio, SharePoint, SQL - plus HTML5, CSS3, MVC3,
Metro Style Apps, more. Free future releases when you subscribe now!
http://p.sf.net/sfu/learndevnow-dev2
_______________________________________________
Openbravo-commits mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/openbravo-commits

Reply via email to