details:   https://code.openbravo.com/erp/devel/pi/rev/b0829884d505
changeset: 22843:b0829884d505
user:      Guillermo Gil <guillermo.gil <at> openbravo.com>
date:      Tue Apr 08 15:32:57 2014 +0200
summary:   Fixed issue 25343:Message not shown after executing a process 
definition

showMsgInView need to wait till the tab is loaded

diffstat:

 
modules/org.openbravo.client.application/web/org.openbravo.client.application/js/utilities/ob-utilities-action-def.js
 |  33 +++++++--
 
modules/org.openbravo.client.application/web/org.openbravo.client.application/js/utilities/ob-utilities.js
            |  16 ++++
 2 files changed, 41 insertions(+), 8 deletions(-)

diffs (85 lines):

diff -r 28afef865651 -r b0829884d505 
modules/org.openbravo.client.application/web/org.openbravo.client.application/js/utilities/ob-utilities-action-def.js
--- 
a/modules/org.openbravo.client.application/web/org.openbravo.client.application/js/utilities/ob-utilities-action-def.js
     Tue Apr 08 10:48:24 2014 +0200
+++ 
b/modules/org.openbravo.client.application/web/org.openbravo.client.application/js/utilities/ob-utilities-action-def.js
     Tue Apr 08 15:32:57 2014 +0200
@@ -45,6 +45,18 @@
   var view = OB.MainView.TabSet.getSelectedTab().pane.activeView;
   if (view && view.messageBar) {
     view.messageBar.setMessage(paramObj.msgType, paramObj.msgTitle, 
paramObj.msgText);
+  } else { // If the window is not loaded, wait and try again
+    var i = 0,
+        messageInterval = setInterval(function () {
+        view = OB.MainView.TabSet.getSelectedTab().pane.activeView;
+        if (view && view.messageBar) {
+          clearInterval(messageInterval);
+          view.messageBar.setMessage(paramObj.msgType, paramObj.msgTitle, 
paramObj.msgText);
+        } else if (i === 5) {
+          clearInterval(messageInterval);
+        }
+        i++;
+      }, 500); //Call this action again with a 500ms delay
   }
 });
 
@@ -73,15 +85,20 @@
 // * {{{command}}}: The command with which the view to be opened
 // * {{{wait}}}: If true, the thread in which this action was called (if there 
is any) will be paused until the view be opened.
 OB.Utilities.Action.set('openDirectTab', function (paramObj) {
-  var processIndex;
+  var processIndex, tabPosition;
   if (!paramObj.newTabPosition) {
-    processIndex = 
OB.Utilities.getProcessTabBarPosition(paramObj._processView);
-    if (processIndex === -1) {
-      // If the process is not found in the main tab bar, add the new window 
in the last position
-      paramObj.newTabPosition = 
OB.MainView.TabSet.paneContainer.members.length;
+    tabPosition = OB.Utilities.getTabNumberById(paramObj.tabId); // Search if 
the tab has been opened before
+    if (tabPosition !== -1) {
+      paramObj.newTabPosition = tabPosition;
     } else {
-      // If the process is foudn in the main tab bar, add the new window in 
its next position
-      paramObj.newTabPosition = processIndex + 1;
+      processIndex = 
OB.Utilities.getProcessTabBarPosition(paramObj._processView);
+      if (processIndex === -1) {
+        // If the process is not found in the main tab bar, add the new window 
in the last position
+        paramObj.newTabPosition = 
OB.MainView.TabSet.paneContainer.members.length;
+      } else {
+        // If the process is found in the main tab bar, add the new window in 
its next position
+        paramObj.newTabPosition = processIndex + 1;
+      }
     }
   }
   if (!paramObj.isOpening) {
@@ -93,7 +110,7 @@
       paramObj.isOpening = true;
       OB.Utilities.Action.execute('openDirectTab', paramObj, 100); //Call this 
action again with a 100ms delay
     } else {
-      OB.Utilities.Action.resumeThread(paramObj.threadId, 1500); //Call this 
action again with a 1000ms delay
+      OB.Utilities.Action.resumeThread(paramObj.threadId, 1500); //Call this 
action again with a 1500ms delay
     }
   }
 });
\ No newline at end of file
diff -r 28afef865651 -r b0829884d505 
modules/org.openbravo.client.application/web/org.openbravo.client.application/js/utilities/ob-utilities.js
--- 
a/modules/org.openbravo.client.application/web/org.openbravo.client.application/js/utilities/ob-utilities.js
        Tue Apr 08 10:48:24 2014 +0200
+++ 
b/modules/org.openbravo.client.application/web/org.openbravo.client.application/js/utilities/ob-utilities.js
        Tue Apr 08 15:32:57 2014 +0200
@@ -1231,4 +1231,20 @@
     return '-'; // hack to sort nulls last
   }
   return ' ' + value;
+};
+
+//** {{{ OB.Utilities.getTabNumber }}} **
+//
+// Returns the position of a window in the main tab bar
+// Parameters:
+//  * {{{tabId}}} The if of the tab to search
+OB.Utilities.getTabNumberById = function (tabId) {
+  var i = 0,
+      len = OB.MainView.TabSet.paneContainer.members.length;
+  for (i; i < len; i++) {
+    if (tabId === OB.MainView.TabSet.getTabObject(i).id || tabId === 
OB.MainView.TabSet.getTabObject(i).pane.targetTabId) {
+      return i;
+    }
+  }
+  return -1;
 };
\ No newline at end of file

------------------------------------------------------------------------------
Put Bad Developers to Shame
Dominate Development with Jenkins Continuous Integration
Continuously Automate Build, Test & Deployment 
Start a new project now. Try Jenkins in the cloud.
http://p.sf.net/sfu/13600_Cloudbees
_______________________________________________
Openbravo-commits mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/openbravo-commits

Reply via email to