Support direct opening of record in tab using simple link
authorMartin Taal <martin.taal@openbravo.com>
Tue, 08 Mar 2011 15:27:13 +0100
changeset 11099 f7e47cafe51c
parent 11098 44a28572b42c
child 11100 3c1ef57fc562
Support direct opening of record in tab using simple link
modules/org.openbravo.client.application/web/org.openbravo.client.application/js/ob-standard-view.js
modules/org.openbravo.client.application/web/org.openbravo.client.application/js/ob-standard-window.js
--- a/modules/org.openbravo.client.application/web/org.openbravo.client.application/js/ob-standard-view.js	Tue Mar 08 15:26:12 2011 +0100
+++ b/modules/org.openbravo.client.application/web/org.openbravo.client.application/js/ob-standard-view.js	Tue Mar 08 15:27:13 2011 +0100
@@ -547,17 +547,27 @@
   isActiveView: function() {
     return this.standardWindow.activeView === this;
   },
-  
+    
   setAsActiveView: function(){
     this.standardWindow.setActiveView(this);
   },
   
+  setTargetRecordInWindow: function(recordId) {
+    if (this.isActiveView()) {
+      this.standardWindow.setTargetInformation(this.tabId, recordId);
+    }
+  },
+  
   setActiveViewProps: function(state){
     if (state) {
       this.toolBar.show();
       this.activeBar.setActive(true);
       this.setViewFocus();
       this.viewGrid.setActive(true);
+      // if we are in form view
+      if (this.isShowingForm && !this.viewForm.isNew) {        
+        this.setTargetRecordInWindow(this.viewGrid.getSelectedRecord().id);
+      }
     } else {
       
       // close any editors we may have
--- a/modules/org.openbravo.client.application/web/org.openbravo.client.application/js/ob-standard-window.js	Tue Mar 08 15:26:12 2011 +0100
+++ b/modules/org.openbravo.client.application/web/org.openbravo.client.application/js/ob-standard-window.js	Tue Mar 08 15:27:13 2011 +0100
@@ -292,7 +292,6 @@
   draw: function(){
     var standardWindow = this, targetEntity;
     var ret = this.Super('draw', arguments);
-    
     if (this.targetTabId) {
       for (var i = 0; i < this.views.length; i++) {
         if (this.views[i].tabId === this.targetTabId) {
@@ -365,6 +364,10 @@
     result.windowId = this.windowId;
     result.viewId = this.getClassName();
     result.tabTitle = this.tabTitle;
+    if (this.targetTabId) {
+      result.targetTabId = this.targetTabId;
+      result.targetRecordId = this.targetRecordId;
+    }
     return result;
   },
   
@@ -381,6 +384,12 @@
     return this.isEqualParams(params) && viewName === this.getClassName();
   },
   
+  setTargetInformation: function(tabId, recordId) {
+    this.targetTabId = tabId;
+    this.targetRecordId = recordId;
+    OB.Layout.HistoryManager.updateHistory();
+  },
+  
   storeViewState: function(){
 	var result={};
     for (var i = 0; i < this.views.length; i++) {