details:   https://code.openbravo.com/erp/devel/pi/rev/58da827197d1
changeset: 15854:58da827197d1
user:      Augusto Mauch <augusto.mauch <at> openbravo.com>
date:      Wed Mar 21 12:37:23 2012 +0100
summary:   Fixes issue 20049: Image fields are not shown in grid view.

The fields that represent images (its targetEntity is 'ADImage') can no longer 
be shown in the grid view. This has been achieved by removing this fields from 
the field list that
 is entered when setting the data source of the grid.

diffstat:

 
modules/org.openbravo.client.application/web/org.openbravo.client.application/js/main/ob-standard-view.js
 |  35 +++++++++-
 1 files changed, 33 insertions(+), 2 deletions(-)

diffs (59 lines):

diff -r 60a3b45a21d4 -r 58da827197d1 
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
 Wed Mar 21 11:57:13 2012 +0100
+++ 
b/modules/org.openbravo.client.application/web/org.openbravo.client.application/js/main/ob-standard-view.js
 Wed Mar 21 12:37:23 2012 +0100
@@ -399,7 +399,8 @@
   // ** {{{ createMainParts }}} **
   // Creates the main layout components of this view.
   createMainParts: function () {
-    var me = this;
+    var me = this,
+        completeFieldsWithoutImages, fieldsWithoutImages;
     if (this.tabId && this.tabId.length > 0) {
       this.formGridLayout = isc.HLayout.create({
         canFocus: true,
@@ -428,7 +429,12 @@
         }
       });
 
-      this.viewGrid.setDataSource(this.dataSource, 
this.viewGrid.completeFields || this.viewGrid.fields);
+      // the grid should not show the image fields
+      // see issue 20049 (https://issues.openbravo.com/view.php?id=20049)
+      completeFieldsWithoutImages = 
this.removeImageFields(this.viewGrid.completeFields);
+      fieldsWithoutImages = this.removeImageFields(this.viewGrid.fields);
+
+      this.viewGrid.setDataSource(this.dataSource, completeFieldsWithoutImages 
|| fieldsWithoutImages);
 
       if (this.viewGrid) {
         this.viewGrid.setWidth('100%');
@@ -506,6 +512,31 @@
     }
   },
 
+  // returns a copy of fields after deleting the image fields
+  // see issue 20049 (https://issues.openbravo.com/view.php?id=20049)
+  removeImageFields: function (fields) {
+    var indexesToDelete, i, length, fieldsWithoutImages;
+    indexesToDelete = [];
+    if (fields) {
+      fieldsWithoutImages = fields.duplicate();
+      length = fieldsWithoutImages.length;
+      // gets the index of the image fields
+      for (i = 0; i < length; i++) {
+        if (fieldsWithoutImages[i].targetEntity === 'ADImage') {
+          indexesToDelete.push(i);
+        }
+      }
+      // removes the image fields
+      length = indexesToDelete.length;
+      for (i = 0; i < length; i++) {
+        fieldsWithoutImages.splice(indexesToDelete[i] - i, 1);
+      }
+    } else {
+      fieldsWithoutImages = fields;
+    }
+    return fieldsWithoutImages;
+  },
+
   getDirectLinkUrl: function () {
     var url = window.location.href,
         crit;

------------------------------------------------------------------------------
This SF email is sponsosred by:
Try Windows Azure free for 90 days Click Here 
http://p.sf.net/sfu/sfd2d-msazure
_______________________________________________
Openbravo-commits mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/openbravo-commits

Reply via email to