[Tree Extension] Use canBeParentNode instead of canAcceptDrop
authorAugusto Mauch <augusto.mauch@openbravo.com>
Sun, 02 Mar 2014 14:34:26 +0100
changeset 22605 3349386cdc71
parent 22603 c0aaef98a544
child 22606 9e7138180e20
[Tree Extension] Use canBeParentNode instead of canAcceptDrop

Using canAcceptDrop to handle what nodes can be parent was not working properly, it was not possible to move a node to another position in its same parent if
its siblings had summaryLevel=false

This has been fixed by using a new property called canBeParentNode. The transferNodes function cancels the node movement is the new parent node can not be a p
arent node.
modules/org.openbravo.client.application/web/org.openbravo.client.application/js/grid/ob-tree-view-grid.js
modules/org.openbravo.service.datasource/src/org/openbravo/service/datasource/ADTreeDatasourceService.java
--- a/modules/org.openbravo.client.application/web/org.openbravo.client.application/js/grid/ob-tree-view-grid.js	Fri Feb 28 17:00:40 2014 +0100
+++ b/modules/org.openbravo.client.application/web/org.openbravo.client.application/js/grid/ob-tree-view-grid.js	Sun Mar 02 14:34:26 2014 +0100
@@ -59,7 +59,6 @@
     }
     this.confirmNodeReparent = OB.PropertyStore.get('OBUIAPP_ConfirmNodeReparent', this.view.windowId);
     this.filterNoRecordsEmptyMessage = '<span class="' + this.emptyMessageStyle + '">' + OB.I18N.getLabel('OBUIAPP_GridFilterNoResults') + '</span>' + '<span onclick="window[\'' + this.ID + '\'].clearFilter();" class="' + this.emptyMessageLinkStyle + '">' + OB.I18N.getLabel('OBUIAPP_GridClearFilter') + '</span>';
-    console.log('tree popup', this.isPopup);
   },
 
   // Some OBTreeViewGrid functionality is alreadyd implemented in OBViewGrid
@@ -196,6 +195,9 @@
         i, len = nodes.length,
         nodesIdentifier = "",
         parentIdentifier, message;
+    if (folder.canBeParentNode === false) {
+      return;
+    }
     if (this.canReorderRecords) {
       if (this.confirmNodeReparent && this.canReorderRecords) {
         for (i = 0; i < len; i++) {
--- a/modules/org.openbravo.service.datasource/src/org/openbravo/service/datasource/ADTreeDatasourceService.java	Fri Feb 28 17:00:40 2014 +0100
+++ b/modules/org.openbravo.service.datasource/src/org/openbravo/service/datasource/ADTreeDatasourceService.java	Sun Mar 02 14:34:26 2014 +0100
@@ -304,7 +304,7 @@
         }
 
         if (!canAcceptDrop(entity, bob)) {
-          value.put("canAcceptDrop", false);
+          value.put("canBeParentNode", false);
         }
         value.put("seqno", node[SEQNO]);
         value.put("_hasChildren",