details:   /erp/devel/pi/rev/4c2695cdb5cd
changeset: 9638:4c2695cdb5cd
user:      Martin Taal <martin.taal <at> openbravo.com>
date:      Sat Jan 08 13:31:37 2011 +0100
summary:   Support overriding the httpmethod through request props

details:   /erp/devel/pi/rev/f2c46c756b71
changeset: 9639:f2c46c756b71
user:      Martin Taal <martin.taal <at> openbravo.com>
date:      Sat Jan 08 13:34:44 2011 +0100
summary:   GetContextInfo now makes difference between classic/new mode, form 
posts values to FIC instead of get

diffstat:

 
modules/org.openbravo.client.application/web/org.openbravo.client.application/js/ob-remote-call-manager.js
 |   9 +-
 
modules/org.openbravo.client.application/web/org.openbravo.client.application/js/ob-standard-view.js
       |  42 ++++++---
 
modules/org.openbravo.client.application/web/org.openbravo.client.application/js/ob-utilities.js
           |   4 +-
 
modules/org.openbravo.client.application/web/org.openbravo.client.application/js/ob-view-form.js
           |  13 +-
 
modules/org.openbravo.client.application/web/org.openbravo.client.application/js/ob-view-grid.js
           |   2 +-
 5 files changed, 46 insertions(+), 24 deletions(-)

diffs (216 lines):

diff -r 4681d6ba34a9 -r f2c46c756b71 
modules/org.openbravo.client.application/web/org.openbravo.client.application/js/ob-remote-call-manager.js
--- 
a/modules/org.openbravo.client.application/web/org.openbravo.client.application/js/ob-remote-call-manager.js
        Sat Jan 08 13:13:14 2011 +0100
+++ 
b/modules/org.openbravo.client.application/web/org.openbravo.client.application/js/ob-remote-call-manager.js
        Sat Jan 08 13:34:44 2011 +0100
@@ -62,14 +62,19 @@
       var requestParameters = {};
       ISC.addProperties(requestParameters, requestParams);
       requestParameters._action = actionName;
+      var rpcRequest = {};
 
-      var rpcRequest = {};
+      // support overriding of the http method through a request param
+      if (requestParameters.httpMethod) {
+        rpcRequest.httpMethod = requestParameters.httpMethod;
+      }
+
       rpcRequest.actionURL = OB.Application.contextUrl + 
'org.openbravo.client.kernel';
       rpcRequest.callback = callback;
       if (data) {
         rpcRequest.data = ISC.JSON.encode(data);
         rpcRequest.httpMethod = 'POST';
-      } else {
+      } else if (!rpcRequest.httpMethod) {
         rpcRequest.httpMethod = 'GET';
       }
       rpcRequest.contentType = 'application/json;charset=UTF-8';
diff -r 4681d6ba34a9 -r f2c46c756b71 
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
      Sat Jan 08 13:13:14 2011 +0100
+++ 
b/modules/org.openbravo.client.application/web/org.openbravo.client.application/js/ob-standard-view.js
      Sat Jan 08 13:34:44 2011 +0100
@@ -186,7 +186,7 @@
   // ** {{{ toolbar }}} **
   // The toolbar canvas.
   toolBar: null,
-
+  
   messageBar: null,
   
   // ** {{{ formGridLayout }}} **
@@ -461,7 +461,7 @@
       this.statusBarFormLayout.addMember(formContainerLayout);
       
       this.formGridLayout.addMember(this.statusBarFormLayout);
-
+      
       // wrap the messagebar and the formgridlayout in a VLayout
       var gridFormMessageLayout = isc.VLayout.create({
         height: '100%',
@@ -470,7 +470,7 @@
       });
       gridFormMessageLayout.addMember(this.messageBar);
       gridFormMessageLayout.addMember(this.formGridLayout);
-
+      
       // and place the active bar to the left of the form/grid/messagebar
       var activeGridFormMessageLayout = isc.HLayout.create({
         height: '100%',
@@ -546,9 +546,9 @@
   setTabButtonState: function(active){
     var tabButton;
     if (this.tab) {
-      tabButton = this.parentTabSet.getTab(this.tab);
+      tabButton = this.tab;
     } else {
-      // not the nicest trick but okay...
+      // don't like to use the global window object, but okay..
       tabButton = window[this.standardWindow.viewTabId];
     }
     // enable this code to set the styleclass changes
@@ -1015,30 +1015,46 @@
   
   //++++++++++++++++++ Reading context ++++++++++++++++++++++++++++++
   
-  getContextInfo: function(allProperties, sessionProperties){
+  getContextInfo: function(allProperties, sessionProperties, classicMode){
+    var value, field, record, component;
     // different modes:
     // 1) showing grid with one record selected
     // 2) showing form with aux inputs
-    var record;
     if (this.viewGrid.isVisible()) {
       record = this.viewGrid.getSelectedRecord();
+      component = this.viewGrid;
     } else {
       record = this.viewForm.getValues();
+      component = this.viewForm;
     }
     
     var properties = this.propertyToColumns;
     
     if (record) {
+    
+      // add the id of the record itself also if not set
+      if (!record[OB.Constants.ID] && this.viewGrid.getSelectedRecord()) {
+        // if in edit mode then the grid always has the current record selected
+        record[OB.Constants.ID] = 
this.viewGrid.getSelectedRecord()[OB.Constants.ID];
+      }
+      
       for (var i = 0; i < properties.length; i++) {
-        var value = record[properties[i].property];
+        value = record[properties[i].property];
+        field = component.getField(properties[i].property);
         if (typeof value !== 'undefined') {
-          allProperties[properties[i].column] = value;
+          if (classicMode) {
+            allProperties[properties[i].column] = value;            
+          } else {
           // surround the property name with @ symbols to make them different
           // from filter criteria and such          
           allProperties['@' + this.entity + '.' + properties[i].property + 
'@'] = value;
+          }
           if (properties[i].sessionProperty) {
-            sessionProperties[properties[i].dbColumn] = value;
-            sessionProperties['@' + this.entity + '.' + properties[i].property 
+ '@'] = value;
+            if (classicMode) {
+              sessionProperties[properties[i].dbColumn] = value;
+            } else {
+              sessionProperties['@' + this.entity + '.' + 
properties[i].property + '@'] = value;
+            }
           }
         }
       }
@@ -1051,7 +1067,7 @@
     }
     
     if (this.parentView) {
-      this.parentView.getContextInfo(allProperties, sessionProperties);
+      this.parentView.getContextInfo(allProperties, sessionProperties, 
classicMode);
     }
   },
   
@@ -1059,7 +1075,7 @@
     var allProperties = {};
     if (!sessionProperties) {
       sessionProperties = {};
-      this.getContextInfo(allProperties, sessionProperties);
+      this.getContextInfo(allProperties, sessionProperties, true);
     }
     
OB.RemoteCallManager.call('org.openbravo.client.application.window.FormInitializationComponent',
 sessionProperties, {
       MODE: 'SETSESSION',
diff -r 4681d6ba34a9 -r f2c46c756b71 
modules/org.openbravo.client.application/web/org.openbravo.client.application/js/ob-utilities.js
--- 
a/modules/org.openbravo.client.application/web/org.openbravo.client.application/js/ob-utilities.js
  Sat Jan 08 13:13:14 2011 +0100
+++ 
b/modules/org.openbravo.client.application/web/org.openbravo.client.application/js/ob-utilities.js
  Sat Jan 08 13:34:44 2011 +0100
@@ -849,7 +849,7 @@
   
   var allProperties = {}, sessionProperties = {};
   
-  theView.getContextInfo(allProperties, sessionProperties);
+  theView.getContextInfo(allProperties, sessionProperties, true);
   OB.Utilities.viewCallingProcess = theView;
   
   for (var param in allProperties) {
@@ -873,7 +873,7 @@
   }
   
   var allProperties = {}, sessionProperties = {};
-  var params = theView.getContextInfo(allProperties, sessionProperties);
+  var params = theView.getContextInfo(allProperties, sessionProperties, true);
   
   for (var param in params) {
     if (params.hasOwnProperty(param)) {
diff -r 4681d6ba34a9 -r f2c46c756b71 
modules/org.openbravo.client.application/web/org.openbravo.client.application/js/ob-view-form.js
--- 
a/modules/org.openbravo.client.application/web/org.openbravo.client.application/js/ob-view-form.js
  Sat Jan 08 13:13:14 2011 +0100
+++ 
b/modules/org.openbravo.client.application/web/org.openbravo.client.application/js/ob-view-form.js
  Sat Jan 08 13:34:44 2011 +0100
@@ -121,7 +121,7 @@
       mode = 'EDIT';
     }
     
-    
OB.RemoteCallManager.call('org.openbravo.client.application.window.FormInitializationComponent',
 null, {
+    
OB.RemoteCallManager.call('org.openbravo.client.application.window.FormInitializationComponent',
 {}, {
       MODE: 'EDIT',
       PARENT_ID: parentId,
       TAB_ID: this.view.tabId,
@@ -227,7 +227,7 @@
   },
   
   doChangeFICCall: function(item){
-    var parentId = null, me = this, requestParams;
+    var parentId = null, me = this, requestParams, dataParams;
     var allProperties = {}, sessionProperties = {};
     
     if (this.view.parentProperty) {
@@ -235,18 +235,19 @@
     }
     
     // fills the allProperties    
-    this.view.getContextInfo(allProperties, sessionProperties);
+    this.view.getContextInfo(allProperties, sessionProperties, true);
     
-    requestParams = isc.addProperties({
+    requestParams = {
       MODE: 'CHANGE',
       PARENT_ID: parentId,
       TAB_ID: this.view.tabId,
       ROW_ID: this.getValue(OB.Constants.ID),
       CHANGED_COLUMN: item.inpColumnName
-    }, allProperties, sessionProperties);
+    };
+    dataParams = isc.addProperties({}, allProperties, sessionProperties);
     
     // collect the context information    
-    
OB.RemoteCallManager.call('org.openbravo.client.application.window.FormInitializationComponent',
 null, requestParams, function(response, data, request){
+    
OB.RemoteCallManager.call('org.openbravo.client.application.window.FormInitializationComponent',
 dataParams, requestParams, function(response, data, request){
       me.processFICReturn(response, data, request);
     });
   },
diff -r 4681d6ba34a9 -r f2c46c756b71 
modules/org.openbravo.client.application/web/org.openbravo.client.application/js/ob-view-grid.js
--- 
a/modules/org.openbravo.client.application/web/org.openbravo.client.application/js/ob-view-grid.js
  Sat Jan 08 13:13:14 2011 +0100
+++ 
b/modules/org.openbravo.client.application/web/org.openbravo.client.application/js/ob-view-grid.js
  Sat Jan 08 13:34:44 2011 +0100
@@ -469,7 +469,7 @@
     }
     
     // add all the context info to the criteria
-    this.view.getContextInfo({}, criteria);
+    this.view.getContextInfo({}, criteria, false);
     
     return criteria;
   },

------------------------------------------------------------------------------
Gaining the trust of online customers is vital for the success of any company
that requires sensitive data to be transmitted over the Web.   Learn how to 
best implement a security strategy that keeps consumers' information secure 
and instills the confidence they need to proceed with transactions.
http://p.sf.net/sfu/oracle-sfdevnl 
_______________________________________________
Openbravo-commits mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/openbravo-commits

Reply via email to