[Tree Extension] Supports canvas fields
authorAugusto Mauch <augusto.mauch@openbravo.com>
Wed, 29 Jan 2014 18:41:44 +0100
changeset 22500 330aafc6d8e5
parent 22499 8c9e7678477b
child 22501 e0c8171836c2
[Tree Extension] Supports canvas fields

Pending: filtering in canvas fields
modules/org.openbravo.client.application/web/org.openbravo.client.application/js/grid/ob-tree-grid.js
src-db/database/model/tables/AD_TABLE_TREE.xml
--- a/modules/org.openbravo.client.application/web/org.openbravo.client.application/js/grid/ob-tree-grid.js	Fri Jan 24 15:01:45 2014 +0100
+++ b/modules/org.openbravo.client.application/web/org.openbravo.client.application/js/grid/ob-tree-grid.js	Wed Jan 29 18:41:44 2014 +0100
@@ -27,6 +27,8 @@
   nodeIcon: null,
   folderIcon: null,
   showSortArrow: false,
+  showRecordComponentsByCell: true,
+  showRecordComponents: true,
   dataProperties: {
     modelType: 'parent',
     rootValue: '0',
@@ -74,5 +76,43 @@
     if (!noPerformAction) {
       this.filterEditor.performAction();
     }
+  },
+
+  createRecordComponent: function (record, colNum) {
+    var field = this.getField(colNum),
+        rowNum = this.getRecordIndex(record),
+        isSummary = record && (record[this.groupSummaryRecordProperty] || record[this.gridSummaryRecordProperty]),
+        isEditRecord = rowNum === this.getEditRow(),
+        canvas, clientClassArray, clientClass, clientClassProps, clientClassIsShownInGridEdit;
+
+    if (isSummary) {
+      return null;
+    }
+
+    if (field.clientClass) {
+      clientClassArray = OB.Utilities.clientClassSplitProps(field.clientClass);
+      clientClass = clientClassArray[0];
+      clientClassProps = clientClassArray[1];
+
+      clientClassIsShownInGridEdit = new Function('return ' + clientClass + '.getInstanceProperty("isShownInGridEdit")')();
+
+      if (!isEditRecord || clientClassIsShownInGridEdit) {
+        canvas = isc.ClassFactory.newInstance(clientClass, {
+          grid: this,
+          align: this.getCellAlign(record, rowNum, colNum),
+          field: field,
+          record: record,
+          rowNum: rowNum,
+          colNum: colNum
+        }, clientClassProps);
+        if (canvas) {
+          if (canvas.setRecord) {
+            canvas.setRecord(record);
+          }
+          return canvas;
+        }
+      }
+    }
+    return null;
   }
 });
\ No newline at end of file
--- a/src-db/database/model/tables/AD_TABLE_TREE.xml	Fri Jan 24 15:01:45 2014 +0100
+++ b/src-db/database/model/tables/AD_TABLE_TREE.xml	Wed Jan 29 18:41:44 2014 +0100
@@ -76,9 +76,6 @@
       <foreign-key foreignTable="AD_TABLE" name="AD_TABLETREE_AD_TABLE">
         <reference local="AD_TABLE_ID" foreign="AD_TABLE_ID"/>
       </foreign-key>
-      <foreign-key foreignTable="AD_TREETYPE" name="AD_TABLETREE_AD_TREETYPE">
-        <reference local="AD_TREETYPE_ID" foreign="AD_TREETYPE_ID"/>
-      </foreign-key>
       <foreign-key foreignTable="AD_MODULE" name="AD_TABLTREE_AD_MODULE">
         <reference local="AD_MODULE_ID" foreign="AD_MODULE_ID"/>
       </foreign-key>