Fixes bug 28499:Proper params are used when opening a link using the quick view
authorAugusto Mauch <augusto.mauch@openbravo.com>
Mon, 29 Dec 2014 18:40:27 +0100
changeset 25716 e47640ded61f
parent 25715 4e47ac5c68fa
child 25717 644c58ebe196
Fixes bug 28499:Proper params are used when opening a link using the quick view

The problem was that the OB.Utilities.openDirecTab function, which is used to open a view using the Quick View and also when an URL is pasted in the address bar, tries to fetch the parameters from the current address bar URL. If the link has been entered in the Quick View the parameters won't be available in the address bar, whereas if the view is opened by entering the URL in the address window the view will be opened properly.

This has been fixed by adding the urlParams as an optional parameter to the openDirectTab function. If the parameter is not passed to the function then it will work as usual and it will take its values from the address bar. When the function is called from the quick view the proper parameters are passed, so in this case the url params are not taken from the address bar.
modules/org.openbravo.client.application/web/org.openbravo.client.application/js/navbar/ob-quick-launch.js
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/navbar/ob-quick-launch.js	Tue Dec 30 10:50:25 2014 +0100
+++ b/modules/org.openbravo.client.application/web/org.openbravo.client.application/js/navbar/ob-quick-launch.js	Mon Dec 29 18:40:27 2014 +0100
@@ -142,7 +142,7 @@
     if (this.members[2].getField('value').getValue() && this.members[2].getField('value').getValue().contains('?')) {
       var params = OB.Utilities.getUrlParameters(this.members[2].getField('value').getValue());
       if (params && params.tabId) {
-        OB.Utilities.openDirectTab(params.tabId, params.recordId, params.command);
+        OB.Utilities.openDirectTab(params.tabId, params.recordId, params.command, null, null, null, params);
       }
     }
     if (this.members[1].getMembers()) {
--- a/modules/org.openbravo.client.application/web/org.openbravo.client.application/js/utilities/ob-utilities.js	Tue Dec 30 10:50:25 2014 +0100
+++ b/modules/org.openbravo.client.application/web/org.openbravo.client.application/js/utilities/ob-utilities.js	Mon Dec 29 18:40:27 2014 +0100
@@ -338,15 +338,14 @@
 // Open a view using a tab id and record id. The tab can be a child tab. If the record id
 // is not set then the tab is opened in grid mode. If command is not set then default is
 // used.
-OB.Utilities.openDirectTab = function (tabId, recordId, command, position, criteria, direct) {
-
+OB.Utilities.openDirectTab = function (tabId, recordId, command, position, criteria, direct, urlParams) {
+  var callback, isDirect = direct;
+  // if the url params are not passed to the function, obtain then from the url
+  urlParams = urlParams || OB.Utilities.getUrlParameters();
   tabId = OB.Utilities.removeFragment(tabId);
   recordId = OB.Utilities.removeFragment(recordId);
   command = OB.Utilities.removeFragment(command);
 
-  var urlParams = OB.Utilities.getUrlParameters(),
-      callback, isDirect = direct;
-
   //added to have the additional filter clause and tabid. Mallikarjun M
   callback = function (response, data, request) {
     command = command || 'DEFAULT';