Added new preference to control classic or new mode
authorMartin Taal <martin.taal@openbravo.com>
Tue, 25 Jan 2011 23:47:41 +0100
changeset 10126 157e1d81beb8
parent 10125 ddb356afbb3d
child 10127 72003d0cf144
Added new preference to control classic or new mode
modules/org.openbravo.client.application/src-db/database/sourcedata/AD_PREFERENCE.xml
modules/org.openbravo.client.application/src-db/database/sourcedata/AD_REF_LIST.xml
modules/org.openbravo.client.application/src/org/openbravo/client/application/PropertiesComponent.java
modules/org.openbravo.client.application/src/org/openbravo/client/application/navigationbarcomponents/templates/application-menu.js.ftl
modules/org.openbravo.client.application/src/org/openbravo/client/application/navigationbarcomponents/templates/quick-launch.js.ftl
modules/org.openbravo.client.application/web/org.openbravo.client.application/js/ob-classic-compatibility.js
modules/org.openbravo.client.application/web/org.openbravo.client.application/js/ob-property-store.js
modules/org.openbravo.client.application/web/org.openbravo.client.application/js/ob-utilities.js
--- a/modules/org.openbravo.client.application/src-db/database/sourcedata/AD_PREFERENCE.xml	Tue Jan 25 20:42:18 2011 +0100
+++ b/modules/org.openbravo.client.application/src-db/database/sourcedata/AD_PREFERENCE.xml	Tue Jan 25 23:47:41 2011 +0100
@@ -89,4 +89,16 @@
 <!--C5C3ECF98CB14B02B88D2FE46D810739-->  <AD_MODULE_ID><![CDATA[9BA0836A3CD74EE4AB48753A47211BCC]]></AD_MODULE_ID>
 <!--C5C3ECF98CB14B02B88D2FE46D810739--></AD_PREFERENCE>
 
+<!--FF8081812DBF2839012DBF4D98400060--><AD_PREFERENCE>
+<!--FF8081812DBF2839012DBF4D98400060-->  <AD_PREFERENCE_ID><![CDATA[FF8081812DBF2839012DBF4D98400060]]></AD_PREFERENCE_ID>
+<!--FF8081812DBF2839012DBF4D98400060-->  <AD_CLIENT_ID><![CDATA[0]]></AD_CLIENT_ID>
+<!--FF8081812DBF2839012DBF4D98400060-->  <AD_ORG_ID><![CDATA[0]]></AD_ORG_ID>
+<!--FF8081812DBF2839012DBF4D98400060-->  <ISACTIVE><![CDATA[Y]]></ISACTIVE>
+<!--FF8081812DBF2839012DBF4D98400060-->  <AD_USER_ID><![CDATA[100]]></AD_USER_ID>
+<!--FF8081812DBF2839012DBF4D98400060-->  <VALUE><![CDATA[N]]></VALUE>
+<!--FF8081812DBF2839012DBF4D98400060-->  <PROPERTY><![CDATA[OBUIAPP_UseClassicMode]]></PROPERTY>
+<!--FF8081812DBF2839012DBF4D98400060-->  <ISPROPERTYLIST><![CDATA[Y]]></ISPROPERTYLIST>
+<!--FF8081812DBF2839012DBF4D98400060-->  <AD_MODULE_ID><![CDATA[9BA0836A3CD74EE4AB48753A47211BCC]]></AD_MODULE_ID>
+<!--FF8081812DBF2839012DBF4D98400060--></AD_PREFERENCE>
+
 </data>
--- a/modules/org.openbravo.client.application/src-db/database/sourcedata/AD_REF_LIST.xml	Tue Jan 25 20:42:18 2011 +0100
+++ b/modules/org.openbravo.client.application/src-db/database/sourcedata/AD_REF_LIST.xml	Tue Jan 25 23:47:41 2011 +0100
@@ -128,6 +128,18 @@
 <!--C38DEECEC59544609E4CC4D7FC819E46-->  <AD_MODULE_ID><![CDATA[9BA0836A3CD74EE4AB48753A47211BCC]]></AD_MODULE_ID>
 <!--C38DEECEC59544609E4CC4D7FC819E46--></AD_REF_LIST>
 
+<!--FF8081812DB867FE012DB86CD07D0017--><AD_REF_LIST>
+<!--FF8081812DB867FE012DB86CD07D0017-->  <AD_REF_LIST_ID><![CDATA[FF8081812DB867FE012DB86CD07D0017]]></AD_REF_LIST_ID>
+<!--FF8081812DB867FE012DB86CD07D0017-->  <AD_CLIENT_ID><![CDATA[0]]></AD_CLIENT_ID>
+<!--FF8081812DB867FE012DB86CD07D0017-->  <AD_ORG_ID><![CDATA[0]]></AD_ORG_ID>
+<!--FF8081812DB867FE012DB86CD07D0017-->  <ISACTIVE><![CDATA[Y]]></ISACTIVE>
+<!--FF8081812DB867FE012DB86CD07D0017-->  <VALUE><![CDATA[OBUIAPP_UseClassicMode]]></VALUE>
+<!--FF8081812DB867FE012DB86CD07D0017-->  <NAME><![CDATA[Use Classic UI Mode]]></NAME>
+<!--FF8081812DB867FE012DB86CD07D0017-->  <DESCRIPTION><![CDATA[If set to Y then the classic user interface mode is shown]]></DESCRIPTION>
+<!--FF8081812DB867FE012DB86CD07D0017-->  <AD_REFERENCE_ID><![CDATA[A26BA480E2014707B47257024C3CBFF7]]></AD_REFERENCE_ID>
+<!--FF8081812DB867FE012DB86CD07D0017-->  <AD_MODULE_ID><![CDATA[9BA0836A3CD74EE4AB48753A47211BCC]]></AD_MODULE_ID>
+<!--FF8081812DB867FE012DB86CD07D0017--></AD_REF_LIST>
+
 <!--CF6EAC4255D0484399EF03DB23376CD5--><AD_REF_LIST>
 <!--CF6EAC4255D0484399EF03DB23376CD5-->  <AD_REF_LIST_ID><![CDATA[CF6EAC4255D0484399EF03DB23376CD5]]></AD_REF_LIST_ID>
 <!--CF6EAC4255D0484399EF03DB23376CD5-->  <AD_CLIENT_ID><![CDATA[0]]></AD_CLIENT_ID>
--- a/modules/org.openbravo.client.application/src/org/openbravo/client/application/PropertiesComponent.java	Tue Jan 25 20:42:18 2011 +0100
+++ b/modules/org.openbravo.client.application/src/org/openbravo/client/application/PropertiesComponent.java	Tue Jan 25 23:47:41 2011 +0100
@@ -27,6 +27,7 @@
 import org.codehaus.jettison.json.JSONObject;
 import org.openbravo.client.kernel.BaseTemplateComponent;
 import org.openbravo.client.kernel.Template;
+import org.openbravo.dal.core.DalUtil;
 import org.openbravo.dal.core.OBContext;
 import org.openbravo.dal.service.OBDal;
 import org.openbravo.erpCommon.businessUtility.Preferences;
@@ -83,6 +84,10 @@
         localProperty.setId(preference.getAttribute());
       }
 
+      if (preference.getWindow() != null) {
+        localProperty.setId(localProperty.getId() + "_" + DalUtil.getId(preference.getWindow()));
+      }
+      
       // prevent duplicates
       if (handledIds.contains(localProperty.getId())) {
         continue;
--- a/modules/org.openbravo.client.application/src/org/openbravo/client/application/navigationbarcomponents/templates/application-menu.js.ftl	Tue Jan 25 20:42:18 2011 +0100
+++ b/modules/org.openbravo.client.application/src/org/openbravo/client/application/navigationbarcomponents/templates/application-menu.js.ftl	Tue Jan 25 23:47:41 2011 +0100
@@ -162,25 +162,19 @@
     },
     
     itemClick: function(item, colNum) {
-        var isTestEnvironment = OB.Utilities.hasUrlParameter('window', 'new');
+        var isClassicEnvironment = OB.Utilities.useClassicMode(item.windowId);
         var selectedView = null;
-        if (item.viewId) {
-            if (isTestEnvironment && item.viewId === 'OBClassicWindow') {
-              selectedView = {viewId: '_' + item.windowId, windowId: item.windowId, tabId: item.tabId, id: item.tabId, command: 'DEFAULT', tabTitle: item.title};
-            } else {
-              selectedView = item;
+        if (item.tabId) {
+            selectedView = OB.Utilities.openView(item.windowId, item.tabId, item.title);
+            if (selectedView) {
+              OB.RecentUtilities.addRecent('UINAVBA_MenuRecentList', selectedView);
             }
+            return;
         } else if (item.recentObject) {
             selectedView = item.recentObject;
             if (!selectedView.viewId) {
                 selectedView.viewId = 'OBClassicWindow';
             }
-        } else if (item.tabId) {
-            if (isTestEnvironment) {
-              selectedView = {viewId: '_' + item.windowId, windowId: item.windowId, tabId: item.tabId, id: item.tabId, command: 'DEFAULT', tabTitle: item.title};
-            } else {
-              selectedView = {viewId: 'OBClassicWindow', windowId: item.windowId, tabId: item.tabId, id: item.tabId, command: 'DEFAULT', tabTitle: item.title};
-            }
         } else if (item.manualUrl) {
             if (item.manualProcessId) {
                 selectedView = {viewId: 'OBClassicWindow', obManualURL: item.manualUrl, processId: item.manualProcessId, id: item.manualProcessId, command: 'DEFAULT', tabTitle: item.title};
--- a/modules/org.openbravo.client.application/src/org/openbravo/client/application/navigationbarcomponents/templates/quick-launch.js.ftl	Tue Jan 25 20:42:18 2011 +0100
+++ b/modules/org.openbravo.client.application/src/org/openbravo/client/application/navigationbarcomponents/templates/quick-launch.js.ftl	Tue Jan 25 23:47:41 2011 +0100
@@ -163,8 +163,6 @@
          optionDataSource: OB.Datasource.get('${data.dataSourceId}'),      
 
          emptyPickListMessage: OB.I18N.getLabel('OBUISC_ListGrid.emptyMessage'),
-     
-         isTestEnvironment: OB.Utilities.hasUrlParameter('window', 'new'),
          
          pickValue: function(theValue) {
             // HACK: set this temporary value to prevent a temporary 
@@ -177,19 +175,16 @@
             this.Super('pickValue', arguments);
 
             if (this.getSelectedRecord()) {
-             var value = this.getValue();
+             var value = this.getValue(), command;
              var record  = this.getSelectedRecord();
              isc.OBQuickRun.currentQuickRun.doHide();
              var openObject = null; 
              if (record.optionType && record.optionType === 'tab') {
-                if (this.isTestEnvironment) {
-                  openObject = {viewId: '_' + record.windowId, windowId: record.windowId, id: value, tabId: value, tabTitle: record[OB.Constants.IDENTIFIER]};
-                  <#if !data.quickLaunch>
-                  openObject.command = isc.OBStandardWindow.COMMAND_NEW;
-                  </#if>
-                } else {
-                  openObject = {viewId: 'OBClassicWindow', windowId: record.windowId, id: value, tabId: value, command: '${data.command}', tabTitle: record[OB.Constants.IDENTIFIER]};
+                openObject = OB.Utilities.openView(record.windowId, value, record[OB.Constants.IDENTIFIER], null, '${data.command}', record.icon);
+                if (openObject) {             
+                  OB.RecentUtilities.addRecent('${data.recentPropertyName}', openObject);
                 }
+                return;
              } else if (record.optionType && record.optionType === 'external') {
                 openObject = {viewId: 'OBExternalPage', id: value, contentsUrl: value, tabTitle: record[OB.Constants.IDENTIFIER]};
              } else if (record.optionType && record.optionType === 'process') {
--- a/modules/org.openbravo.client.application/web/org.openbravo.client.application/js/ob-classic-compatibility.js	Tue Jan 25 20:42:18 2011 +0100
+++ b/modules/org.openbravo.client.application/web/org.openbravo.client.application/js/ob-classic-compatibility.js	Tue Jan 25 23:47:41 2011 +0100
@@ -91,34 +91,7 @@
     // * {{{form}}} is an Object of the form from where it has been submitted
     //
     sendDirectLink: function(/* String */action, /* Object */ form){
-    
-      //
-      // Opens the MDI tab of the clicked link
-      //
-      function openDirectLink(/* String */address){
-        var addressObj = eval('(' + address + ')');
-        
-        if (!addressObj.recordId || addressObj.recordId.length === 0) {
-          L.ViewManager.openView('OBClassicWindow', {
-            tabTitle: addressObj.tabTitle,
-            windowId: addressObj.windowId,
-            tabId: addressObj.tabId,
-            mappingName: addressObj.mappingName,
-            command: 'DEFAULT'
-          });
-        } else {
-          L.ViewManager.openView('OBClassicWindow', {
-            tabTitle: addressObj.tabTitle,
-            windowId: addressObj.windowId,
-            tabId: addressObj.tabId,
-            mappingName: addressObj.mappingName,
-            keyParameter: addressObj.keyParameter,
-            recordId: addressObj.recordId,
-            command: 'DIRECT'
-          });
-        }
-      }
-      
+
       //
       // Returns a form field and value as a javascript object composed by name and value fields
       //
@@ -201,7 +174,7 @@
       // target address from the back-end
       //
       function fetchSendDirectLinkCallback(/* Object */response, /* String */ data){
-        openDirectLink(data);
+        OB.Utilities.openView(data.windowId, data.tabId, data.tabTitle, data.recordId);
       }
       
       //
@@ -220,7 +193,7 @@
         var reqObj = {
           params: paramsObj,
           callback: fetchSendDirectLinkCallback,
-          evalResult: false,
+          evalResult: true,
           httpMethod: 'GET',
           useSimpleHttp: true,
           actionURL: actionURL
--- a/modules/org.openbravo.client.application/web/org.openbravo.client.application/js/ob-property-store.js	Tue Jan 25 20:42:18 2011 +0100
+++ b/modules/org.openbravo.client.application/web/org.openbravo.client.application/js/ob-property-store.js	Tue Jan 25 23:47:41 2011 +0100
@@ -52,8 +52,12 @@
     //
     // Parameters:
     // * {{{propertyName}}}: the name of the property
+    // * {{{windowId}}}: the system will first search for property on windowId level
     //
-    get: function(/* String */propertyName){
+    get: function(/* String */propertyName, windowId){
+      if (windowId && OB.Properties[propertyName + '_' + windowId]) {
+        return OB.Properties[propertyName + '_' + windowId];
+      }
       if (!OB.Properties[propertyName]) {
         return null;
       }
--- a/modules/org.openbravo.client.application/web/org.openbravo.client.application/js/ob-utilities.js	Tue Jan 25 20:42:18 2011 +0100
+++ b/modules/org.openbravo.client.application/web/org.openbravo.client.application/js/ob-utilities.js	Tue Jan 25 23:47:41 2011 +0100
@@ -23,21 +23,75 @@
 OB.Utilities.Date = {};
 OB.Utilities.Number = {};
 
+// ** {{{OB.Utilities.useClassicMode}}} **
+// Returns true if the user wants to work in classic mode, checks the url parameter
+// as well as a property value.
+OB.Utilities.useClassicMode = function(windowId){
+  if (OB.Utilities.hasUrlParameter('mode', 'classic')) {
+    return true;
+  }
+  var propValue = OB.PropertyStore.get('OBUIAPP_UseClassicMode', windowId);
+  if (propValue === 'Y') {
+    return true;
+  }
+  return false;
+};
+
+// ** {{{OB.Utilities.openView}}} **
+// Open a view taking into account if a specific window should be opened in classic mode or not.
+// Returns the object used to open the window.
+OB.Utilities.openView = function(windowId, tabId, tabTitle, recordId, command, icon){
+    var isClassicEnvironment = OB.Utilities.useClassicMode(windowId);
+
+    var openObject;
+    if (isClassicEnvironment) {
+      if (recordId) {
+        OB.Layout.ClassicOBCompatibility.openLinkedItem(tabId, recordId);
+        return null;
+      } 
+      openObject = {
+          viewId: 'OBClassicWindow',
+          windowId: windowId, 
+          tabId: tabId, 
+          id: tabId, 
+          command: 'DEFAULT', 
+          tabTitle: tabTitle,
+          icon: icon
+       };
+    } else if (recordId) {
+       openObject = {
+        viewId: '_' + windowId,
+        id: tabId,
+        targetRecordId: recordId,
+        targetTabId: tabId,
+        tabTitle: tabTitle,
+        windowId: windowId
+      };      
+    } else {
+       openObject = {
+        viewId: '_' + windowId,
+        id: tabId,
+        tabId: tabId,
+        tabTitle: tabTitle,
+        windowId: windowId,
+        icon: icon
+      };      
+    }
+    if (command) {
+      openObject.command = command;
+    }
+    OB.Layout.ViewManager.openView(openObject.viewId, openObject);
+    return openObject;
+};
+
 // ** {{{OB.Utilities.openDirectView}}} **
 // Open the correct view for a passed in target definition, coming from a certain source Window.
 OB.Utilities.openDirectView = function(sourceWindowId, keyColumn, targetEntity, recordId){
+
   var actionURL = OB.Application.contextUrl + 'utility/ReferencedLink.html';
   
   var callback = function(response, data, request){
-    var openObject = {
-      viewId: '_' + data.windowId,
-      targetEntity: response.clientContext.targetEntity,
-      targetRecordId: data.recordId,
-      targetTabId: data.tabId,
-      tabTitle: data.tabTitle,
-      windowId: data.windowId
-    };
-    OB.Layout.ViewManager.openView(openObject.viewId, openObject);
+    OB.Utilities.openView(data.windowId, data.tabId, data.tabTitle, data.recordId);
   };
   
   var reqObj = {
@@ -48,9 +102,6 @@
       inpwindowId: sourceWindowId,
       inpKeyReferenceColumnName: keyColumn
     },
-    clientContext: {
-      targetEntity: targetEntity
-    },
     callback: callback,
     evalResult: true,
     httpMethod: 'GET',