details:   /erp/devel/pi/rev/b1f22bbfb79f
changeset: 10223:b1f22bbfb79f
user:      Martin Taal <martin.taal <at> openbravo.com>
date:      Sat Jan 29 11:51:56 2011 +0100
summary:   Added tab header in identifier for grid mode

details:   /erp/devel/pi/rev/0b0dae5828d5
changeset: 10224:0b0dae5828d5
user:      Martin Taal <martin.taal <at> openbravo.com>
date:      Sat Jan 29 11:53:46 2011 +0100
summary:   Datasources for a view are now no longer retrieved with a separate 
request

diffstat:

 
modules/org.openbravo.client.application/src-db/database/sourcedata/AD_MESSAGE.xml
                                                                                
    |   11 +
 
modules/org.openbravo.client.application/src/org/openbravo/client/application/ApplicationComponentProvider.java
                                                       |    2 +
 
modules/org.openbravo.client.application/src/org/openbravo/client/application/templates/ob-view-tab.js.ftl
                                                            |    2 +-
 
modules/org.openbravo.client.application/src/org/openbravo/client/application/window/OBViewTab.java
                                                                   |   20 +
 
modules/org.openbravo.client.application/web/org.openbravo.client.application/js/ob-standard-view-datasource.js
                                                       |  147 +++++++++
 
modules/org.openbravo.client.application/web/org.openbravo.client.application/js/ob-standard-view.js
                                                                  |  154 
++-------
 
modules/org.openbravo.client.application/web/org.openbravo.client.application/js/ob-toolbar.js
                                                                        |   15 
+-
 
modules/org.openbravo.client.application/web/org.openbravo.client.application/js/ob-view-grid.js
                                                                      |    3 +-
 
modules/org.openbravo.client.application/web/org.openbravo.userinterface.smartclient/openbravo/skins/3.00/org.openbravo.client.application/ob-main-content-styles.css
 |   32 +-
 
modules/org.openbravo.client.application/web/org.openbravo.userinterface.smartclient/openbravo/skins/3.00/org.openbravo.client.application/ob-tab-styles.css
          |   34 +-
 
modules/org.openbravo.service.datasource/src/org/openbravo/service/datasource/DataSourceComponent.java
                                                                |    8 +
 
modules/org.openbravo.service.datasource/src/org/openbravo/service/datasource/DataSourceConstants.java
                                                                |    2 +
 
modules/org.openbravo.service.datasource/src/org/openbravo/service/datasource/templates/datasource.ftl
                                                                |    1 +
 
modules/org.openbravo.service.datasource/web/org.openbravo.service.datasource/js/ob-datasource-utilities.js
                                                           |    3 +
 14 files changed, 245 insertions(+), 189 deletions(-)

diffs (truncated from 709 to 300 lines):

diff -r 62a6e03ea3ab -r 0b0dae5828d5 
modules/org.openbravo.client.application/src-db/database/sourcedata/AD_MESSAGE.xml
--- 
a/modules/org.openbravo.client.application/src-db/database/sourcedata/AD_MESSAGE.xml
        Fri Jan 28 22:24:06 2011 +0100
+++ 
b/modules/org.openbravo.client.application/src-db/database/sourcedata/AD_MESSAGE.xml
        Sat Jan 29 11:53:46 2011 +0100
@@ -970,4 +970,15 @@
 <!--FF8081812DCD184B012DCD2CB6360079-->  
<AD_MODULE_ID><![CDATA[9BA0836A3CD74EE4AB48753A47211BCC]]></AD_MODULE_ID>
 <!--FF8081812DCD184B012DCD2CB6360079--></AD_MESSAGE>
 
+<!--FF8081812DCF2253012DCF284749000E--><AD_MESSAGE>
+<!--FF8081812DCF2253012DCF284749000E-->  
<AD_MESSAGE_ID><![CDATA[FF8081812DCF2253012DCF284749000E]]></AD_MESSAGE_ID>
+<!--FF8081812DCF2253012DCF284749000E-->  
<AD_CLIENT_ID><![CDATA[0]]></AD_CLIENT_ID>
+<!--FF8081812DCF2253012DCF284749000E-->  <AD_ORG_ID><![CDATA[0]]></AD_ORG_ID>
+<!--FF8081812DCF2253012DCF284749000E-->  <ISACTIVE><![CDATA[Y]]></ISACTIVE>
+<!--FF8081812DCF2253012DCF284749000E-->  
<VALUE><![CDATA[OBUIAPP_SelectedRecords]]></VALUE>
+<!--FF8081812DCF2253012DCF284749000E-->  <MSGTEXT><![CDATA[%0 
selected]]></MSGTEXT>
+<!--FF8081812DCF2253012DCF284749000E-->  <MSGTYPE><![CDATA[I]]></MSGTYPE>
+<!--FF8081812DCF2253012DCF284749000E-->  
<AD_MODULE_ID><![CDATA[9BA0836A3CD74EE4AB48753A47211BCC]]></AD_MODULE_ID>
+<!--FF8081812DCF2253012DCF284749000E--></AD_MESSAGE>
+
 </data>
diff -r 62a6e03ea3ab -r 0b0dae5828d5 
modules/org.openbravo.client.application/src/org/openbravo/client/application/ApplicationComponentProvider.java
--- 
a/modules/org.openbravo.client.application/src/org/openbravo/client/application/ApplicationComponentProvider.java
   Fri Jan 28 22:24:06 2011 +0100
+++ 
b/modules/org.openbravo.client.application/src/org/openbravo/client/application/ApplicationComponentProvider.java
   Sat Jan 29 11:53:46 2011 +0100
@@ -117,6 +117,8 @@
     globalResources.add(createStaticResource(
         "web/org.openbravo.client.application/js/ob-standard-window.js", 
false));
     globalResources.add(createStaticResource(
+        
"web/org.openbravo.client.application/js/ob-standard-view-datasource.js", 
false));
+    globalResources.add(createStaticResource(
         "web/org.openbravo.client.application/js/ob-standard-view-tabset.js", 
false));
     globalResources.add(createStaticResource(
         "web/org.openbravo.client.application/js/ob-standard-view.js", false));
diff -r 62a6e03ea3ab -r 0b0dae5828d5 
modules/org.openbravo.client.application/src/org/openbravo/client/application/templates/ob-view-tab.js.ftl
--- 
a/modules/org.openbravo.client.application/src/org/openbravo/client/application/templates/ob-view-tab.js.ftl
        Fri Jan 28 22:24:06 2011 +0100
+++ 
b/modules/org.openbravo.client.application/src/org/openbravo/client/application/templates/ob-view-tab.js.ftl
        Sat Jan 29 11:53:46 2011 +0100
@@ -27,7 +27,7 @@
     </#if>
     <#if tabComponent.tabSet>
         tabId: '${tabComponent.tabId}',
-        dataSourceId: '${tabComponent.dataSourceId?js_string}',
+        dataSource: ${tabComponent.dataSourceJavaScript},
         moduleId: '${tabComponent.moduleId}',
     </#if>
     
diff -r 62a6e03ea3ab -r 0b0dae5828d5 
modules/org.openbravo.client.application/src/org/openbravo/client/application/window/OBViewTab.java
--- 
a/modules/org.openbravo.client.application/src/org/openbravo/client/application/window/OBViewTab.java
       Fri Jan 28 22:24:06 2011 +0100
+++ 
b/modules/org.openbravo.client.application/src/org/openbravo/client/application/window/OBViewTab.java
       Sat Jan 29 11:53:46 2011 +0100
@@ -21,12 +21,18 @@
 import java.util.ArrayList;
 import java.util.Collection;
 import java.util.Collections;
+import java.util.HashMap;
 import java.util.List;
+import java.util.Map;
+
+import javax.inject.Inject;
 
 import org.openbravo.client.application.ApplicationUtils;
 import org.openbravo.client.application.DynamicExpressionParser;
 import 
org.openbravo.client.application.window.OBViewFormComponent.FormFieldComparator;
 import org.openbravo.client.kernel.BaseTemplateComponent;
+import org.openbravo.client.kernel.Component;
+import org.openbravo.client.kernel.ComponentProvider;
 import org.openbravo.client.kernel.KernelUtils;
 import org.openbravo.client.kernel.Template;
 import org.openbravo.client.kernel.reference.UIDefinitionController;
@@ -45,6 +51,7 @@
 import org.openbravo.model.ad.ui.Process;
 import org.openbravo.model.ad.ui.Tab;
 import org.openbravo.model.ad.ui.TabTrl;
+import org.openbravo.service.datasource.DataSourceConstants;
 import org.openbravo.service.db.DalConnectionProvider;
 import org.openbravo.utils.FormatUtilities;
 
@@ -69,6 +76,19 @@
   private boolean buttonSessionLogic;
   private boolean isRootTab;
 
+  @Inject
+  @ComponentProvider.Qualifier(DataSourceConstants.DS_COMPONENT_TYPE)
+  private ComponentProvider componentProvider;
+
+  public String getDataSourceJavaScript() {
+    final String dsId = getDataSourceId();
+    final Map<String, Object> dsParameters = new HashMap<String, 
Object>(getParameters());
+    dsParameters.put(DataSourceConstants.DS_ONLY_GENERATE_CREATESTATEMENT, 
true);
+    dsParameters.put(DataSourceConstants.DS_CLASS_NAME, "OBViewDataSource");
+    final Component component = componentProvider.getComponent(dsId, 
dsParameters);
+    return component.generate();
+  }
+
   protected Template getComponentTemplate() {
     return OBDal.getInstance().get(Template.class, TEMPLATE_ID);
   }
diff -r 62a6e03ea3ab -r 0b0dae5828d5 
modules/org.openbravo.client.application/web/org.openbravo.client.application/js/ob-standard-view-datasource.js
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ 
b/modules/org.openbravo.client.application/web/org.openbravo.client.application/js/ob-standard-view-datasource.js
   Sat Jan 29 11:53:46 2011 +0100
@@ -0,0 +1,147 @@
+/*
+ *************************************************************************
+ * The contents of this file are subject to the Openbravo  Public  License
+ * Version  1.1  (the  "License"),  being   the  Mozilla   Public  License
+ * Version 1.1  with a permitted attribution clause; you may not  use this
+ * file except in compliance with the License. You  may  obtain  a copy of
+ * the License at http://www.openbravo.com/legal/license.html
+ * Software distributed under the License  is  distribfuted  on  an "AS IS"
+ * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
+ * License for the specific  language  governing  rights  and  limitations
+ * under the License.
+ * The Original Code is Openbravo ERP.
+ * The Initial Developer of the Original Code is Openbravo SLU
+ * All portions are Copyright (C) 2011 Openbravo SLU
+ * All Rights Reserved.
+ * Contributor(s):  ______________________________________.
+ ************************************************************************
+ */
+// = OBViewDataSource =
+//
+// The datasource which is used within a view. It adds specific behavior
+// by adding extra request parameters.
+//
+isc.ClassFactory.defineClass('OBViewDataSource', isc.OBRestDataSource);
+
+isc.OBViewDataSource.addProperties( {
+
+  showProgress : function(editedRecord) {
+
+    // don't show it, done to quickly
+    if (!editedRecord._showProgressAfterDelay) {
+      return;
+    }
+
+    if (editedRecord && editedRecord.editColumnLayout) {
+      if (!this.view.isShowingForm) {
+        editedRecord.editColumnLayout.toggleProgressIcon(true);
+      }
+    }
+
+    if (this.view.isShowingForm) {
+      var btn = this.view.toolBar.getLeftMember(isc.OBToolbar.TYPE_SAVE);
+      btn.customState = 'Progress';
+      btn.resetBaseStyle();
+      btn.markForRedraw();
+    }
+  },
+
+  hideProgress : function(editedRecord) {
+    editedRecord._showProgressAfterDelay = false;
+    if (editedRecord && editedRecord.editColumnLayout) {
+      editedRecord.editColumnLayout.toggleProgressIcon(false);
+    }
+
+    // always remove the progress style here anyway
+    var btn = this.view.toolBar.getLeftMember(isc.OBToolbar.TYPE_SAVE);
+    btn.customState = '';
+    btn.resetBaseStyle();
+    btn.markForRedraw();
+  },
+
+  performDSOperation : function(operationType, data, callback,
+      requestProperties) {
+    // requestProperties.showPrompt = false;
+    // set the current selected record before the delay
+    var currentRecord = this.view.viewGrid.getSelectedRecord();
+    if (currentRecord) {
+      // only show progress after 200ms delay
+      currentRecord._showProgressAfterDelay = true;
+      // keep the edited record in the client context
+      if (!requestProperties.clientContext) {
+        requestProperties.clientContext = {};
+      }
+      requestProperties.clientContext.progressIndicatorSelectedRecord = 
currentRecord;
+      this
+          .delayCall(
+              'showProgress',
+              [ 
requestProperties.clientContext.progressIndicatorSelectedRecord ],
+              200);
+    }
+
+    var newRequestProperties = this.getTabInfoRequestProperties(this.view,
+        requestProperties);
+    // standard update is not sent with operationType
+    var additionalPara = {
+      _operationType : 'update',
+      _noActiveFilter : true
+    };
+    isc.addProperties(newRequestProperties.params, additionalPara);
+    if (!newRequestProperties.dataSource) {
+      newRequestProperties.dataSource = this;
+    }
+    this.Super('performDSOperation', [ operationType, data, callback,
+        newRequestProperties ]);
+  },
+
+  transformResponse : function(dsResponse, dsRequest, jsonData) {
+    if (dsRequest.clientContext && 
dsRequest.clientContext.progressIndicatorSelectedRecord) {
+      
this.hideProgress(dsRequest.clientContext.progressIndicatorSelectedRecord);
+    }
+    if (jsonData) {
+      var errorStatus = !jsonData.response || jsonData.response.status === 
'undefined' || jsonData.response.status !== isc.RPCResponse.STATUS_SUCCESS;
+      if (errorStatus) {
+        var handled = this.view.setErrorMessageFromResponse(dsResponse,
+            jsonData, dsRequest);
+
+        if (!handled && !dsRequest.willHandleError) {
+          OB.KernelUtilities.handleSystemException(error.message);
+        }
+      } else {
+        // there are some cases where the jsonData is not passed, in case of
+        // errors
+        // make it available through the response object
+        dsResponse.dataObject = jsonData;
+      }
+    }
+    return this.Super('transformResponse', arguments);
+  },
+
+  // ** {{{ getTabInfoRequestProperties }}} **
+  //
+  // Adds tab and module information to the requestProperties.
+  //
+  // Parameters:
+  // * {{{theView}}}: view to obtain tab and module info from.
+  // * {{{requestProperties}}}: original requestProperties.
+  // Return:
+  // * Original requestProperties including the new module and tab
+  // properties.
+  getTabInfoRequestProperties : function(theView, requestProperties) {
+    if (theView && theView.tabId) {
+      var tabParam = {
+        params : {
+          windowId : theView.standardWindow.windowId,
+          tabId : theView.tabId,
+          moduleId : theView.moduleId
+        }
+      };
+      if (requestProperties) {
+        isc.addProperties(requestProperties, tabParam);
+      } else {
+        requestProperties = tabParam;
+      }
+    }
+    return requestProperties;
+  }
+});
diff -r 62a6e03ea3ab -r 0b0dae5828d5 
modules/org.openbravo.client.application/web/org.openbravo.client.application/js/ob-standard-view.js
--- 
a/modules/org.openbravo.client.application/web/org.openbravo.client.application/js/ob-standard-view.js
      Fri Jan 28 22:24:06 2011 +0100
+++ 
b/modules/org.openbravo.client.application/web/org.openbravo.client.application/js/ob-standard-view.js
      Sat Jan 29 11:53:46 2011 +0100
@@ -229,7 +229,20 @@
   buildStructure: function(){
     this.createMainParts();
     this.createViewStructure();
-    this.dataSource = OB.Datasource.get(this.dataSourceId, this);
+    this.dataSource.view = this;
+    this.viewGrid.setDataSource(this.dataSource, this.viewGrid.completeFields 
|| this.viewGrid.fields);
+    
+    // directTabInfo is set when we are in direct link mode, i.e. directly 
opening
+    // a specific tab with a record, the direct link logic will already take 
care
+    // of fetching data
+    if (this.isRootView && !this.standardWindow.directTabInfo) {
+      this.viewGrid.fetchData();
+      this.refreshContents = false;
+    }
+    
+    if (this.viewForm) {
+      this.viewForm.setDataSource(this.dataSource, this.viewForm.fields);
+    }
     
     if (this.isRootView) {
       if (this.childTabSet) {
@@ -251,118 +264,6 @@
     isc.defineClass(obDsClassname, ds.getClass());
     
     var modifiedDs = isc.addProperties({}, ds, {
-      view: this,
-      ID: ds.ID + this.tabId,
-      
-      showProgress: function(editedRecord){
-      
-        // don't show it, done to quickly
-        if (!editedRecord._showProgressAfterDelay) {
-          return;
-        }
-        
-        if (editedRecord && editedRecord.editColumnLayout) {
-          if (!this.view.isShowingForm) {
-            editedRecord.editColumnLayout.toggleProgressIcon(true);
-          }
-        }
-        
-        if (this.view.isShowingForm) {
-          var btn = this.view.toolBar.getLeftMember(isc.OBToolbar.TYPE_SAVE);
-          btn.customState = 'Progress';
-          btn.resetBaseStyle();
-          btn.markForRedraw();
-        }
-      },
-      
-      hideProgress: function(editedRecord){
-        editedRecord._showProgressAfterDelay = false;
-        if (editedRecord && editedRecord.editColumnLayout) {

------------------------------------------------------------------------------
Special Offer-- Download ArcSight Logger for FREE (a $49 USD value)!
Finally, a world-class log management solution at an even better price-free!
Download using promo code Free_Logger_4_Dev2Dev. Offer expires 
February 28th, so secure your free ArcSight Logger TODAY! 
http://p.sf.net/sfu/arcsight-sfd2d
_______________________________________________
Openbravo-commits mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/openbravo-commits

Reply via email to