[Tree extension] refresh tree after edition/addition
authorAsier Lostalé <asier.lostale@openbravo.com>
Fri, 28 Feb 2014 13:17:43 +0100
changeset 22595 33670bdfa484
parent 22594 56250da17af1
child 22596 672104d4859b
[Tree extension] refresh tree after edition/addition
modules/org.openbravo.client.application/web/org.openbravo.client.application/js/form/ob-view-form.js
modules/org.openbravo.client.application/web/org.openbravo.client.application/js/grid/ob-tree-view-grid.js
--- a/modules/org.openbravo.client.application/web/org.openbravo.client.application/js/form/ob-view-form.js	Fri Feb 28 12:23:46 2014 +0100
+++ b/modules/org.openbravo.client.application/web/org.openbravo.client.application/js/form/ob-view-form.js	Fri Feb 28 13:17:43 2014 +0100
@@ -11,7 +11,7 @@
  * under the License.
  * The Original Code is Openbravo ERP.
  * The Initial Developer of the Original Code is Openbravo SLU
- * All portions are Copyright (C) 2010-2013 Openbravo SLU
+ * All portions are Copyright (C) 2010-2014 Openbravo SLU
  * All Rights Reserved.
  * Contributor(s):  ______________________________________.
  ************************************************************************
@@ -1425,6 +1425,10 @@
   },
 
   doClose: function () {
+    if (this.view.isShowingTree) {
+      this.view.treeGrid.refreshRecord(this.getValues());
+    }
+
     this.view.switchFormGridVisibility();
     this.view.messageBar.hide();
     if (this.isNew) {
--- a/modules/org.openbravo.client.application/web/org.openbravo.client.application/js/grid/ob-tree-view-grid.js	Fri Feb 28 12:23:46 2014 +0100
+++ b/modules/org.openbravo.client.application/web/org.openbravo.client.application/js/grid/ob-tree-view-grid.js	Fri Feb 28 13:17:43 2014 +0100
@@ -393,6 +393,23 @@
       this.actionAfterDataArrived();
       this.actionAfterDataArrived = null;
     }
+  },
+
+  // refreshes record after edition
+  refreshRecord: function (values) {
+    var record, p;
+    record = this.getNodeByID(values.id);
+    if (record) {
+      for (p in values) {
+        if (values.hasOwnProperty(p)) {
+          record[p] = values[p];
+        }
+      }
+      this.markForRedraw();
+    } else {
+      // record not found, can be new, force refresh
+      this.setData([]);
+      this.fetchData(this.getCriteria());
+    }
   }
-
 });
\ No newline at end of file