details:   /erp/devel/pi/rev/a02b82831805
changeset: 10326:a02b82831805
user:      Martin Taal <martin.taal <at> openbravo.com>
date:      Wed Feb 02 15:32:58 2011 +0100
summary:   Solve issue with null value of view datasource

details:   /erp/devel/pi/rev/b53f9e9335cd
changeset: 10327:b53f9e9335cd
user:      Martin Taal <martin.taal <at> openbravo.com>
date:      Wed Feb 02 15:34:23 2011 +0100
summary:   Grid editing: also pass/handle form values in edit mode

details:   /erp/devel/pi/rev/001abf5ee1fa
changeset: 10328:001abf5ee1fa
user:      Martin Taal <martin.taal <at> openbravo.com>
date:      Wed Feb 02 15:35:28 2011 +0100
summary:   Consider all context values (also from editable grid) when opening 
popup

details:   /erp/devel/pi/rev/8c027d350043
changeset: 10329:8c027d350043
user:      Martin Taal <martin.taal <at> openbravo.com>
date:      Wed Feb 02 15:35:57 2011 +0100
summary:   Save edit values in grid before saving the record itself

diffstat:

 
modules/org.openbravo.client.application/src/org/openbravo/client/application/templates/ob-view-tab.js.ftl
            |   4 +-
 
modules/org.openbravo.client.application/src/org/openbravo/client/application/window/FormInitializationComponent.java
 |   7 +-
 
modules/org.openbravo.client.application/web/org.openbravo.client.application/js/ob-formitem-widgets.js
               |  18 +-
 
modules/org.openbravo.client.application/web/org.openbravo.client.application/js/ob-standard-view.js
                  |  61 +++++++--
 
modules/org.openbravo.client.application/web/org.openbravo.client.application/js/ob-view-form.js
                      |  58 +++++----
 
modules/org.openbravo.client.application/web/org.openbravo.client.application/js/ob-view-grid.js
                      |   1 +
 6 files changed, 96 insertions(+), 53 deletions(-)

diffs (truncated from 345 to 300 lines):

diff -r 2260f5f59c95 -r 8c027d350043 
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
        Wed Feb 02 14:26:32 2011 +0100
+++ 
b/modules/org.openbravo.client.application/src/org/openbravo/client/application/templates/ob-view-tab.js.ftl
        Wed Feb 02 15:35:57 2011 +0100
@@ -27,7 +27,6 @@
     </#if>
     <#if tabComponent.tabSet>
         tabId: '${tabComponent.tabId}',
-        dataSource: ${tabComponent.dataSourceJavaScript},
         moduleId: '${tabComponent.moduleId}',
     </#if>
     
@@ -46,7 +45,7 @@
       <#list tabComponent.allFields as field>
         {
           property: '${field.propertyName?js_string}',
-          column: '${field.columnName?js_string}', 
+          inpColumn: '${field.columnName?js_string}', 
           dbColumn: '${field.dbColumnName?js_string}', 
           sessionProperty: ${field.session},
           type: '${field.typeName?js_string}'
@@ -99,6 +98,7 @@
         hasChildTabs: true,
     </#if>
     initWidget: function() {
+        this.dataSource = ${tabComponent.dataSourceJavaScript};
         this.viewForm = ${tabComponent.viewForm}; 
         this.viewGrid = ${tabComponent.viewGrid};
         this.Super('initWidget', arguments);
diff -r 2260f5f59c95 -r 8c027d350043 
modules/org.openbravo.client.application/src/org/openbravo/client/application/window/FormInitializationComponent.java
--- 
a/modules/org.openbravo.client.application/src/org/openbravo/client/application/window/FormInitializationComponent.java
     Wed Feb 02 14:26:32 2011 +0100
+++ 
b/modules/org.openbravo.client.application/src/org/openbravo/client/application/window/FormInitializationComponent.java
     Wed Feb 02 15:35:57 2011 +0100
@@ -413,11 +413,14 @@
   private void setValuesInRequest(String mode, Tab tab, BaseOBObject row, 
JSONObject jsContent) {
     List<Field> fields = tab.getADFieldList();
     if (mode.equals("EDIT")) {
-      // In EDIT mode we get them from the database
+      // In EDIT mode we initialize them from the database
       for (Field field : fields) {
         setValueOfColumnInRequest(row, field.getColumn().getDBColumnName());
       }
-    } else if (mode.equals("CHANGE") || mode.equals("SETSESSION")) {
+    }
+
+    // and then overwrite with what gets passed in
+    if (mode.equals("EDIT") || mode.equals("CHANGE") || 
mode.equals("SETSESSION")) {
       // In CHANGE and SETSESSION we get them from the request
       for (Field field : fields) {
         final Property prop = 
KernelUtils.getInstance().getPropertyFromColumn(field.getColumn());
diff -r 2260f5f59c95 -r 8c027d350043 
modules/org.openbravo.client.application/web/org.openbravo.client.application/js/ob-formitem-widgets.js
--- 
a/modules/org.openbravo.client.application/web/org.openbravo.client.application/js/ob-formitem-widgets.js
   Wed Feb 02 14:26:32 2011 +0100
+++ 
b/modules/org.openbravo.client.application/web/org.openbravo.client.application/js/ob-formitem-widgets.js
   Wed Feb 02 15:35:57 2011 +0100
@@ -173,10 +173,11 @@
   }, 
 
   showPicker: function(){
+    var parameters = [], index = 0, i = 0, length, propDef, inpName, values;
+    var form = this.form, view = form.view;
     if (this.isFocusable()) {
       this.focusInItem(); 
     }
-    var parameters = [], index = 0, i = 0, length, fld, inpName;
     parameters[index++] = 'inpIDValue';
     if (this.getValue()) {
       parameters[index++] = this.getValue();
@@ -184,14 +185,19 @@
       parameters[index++] = '';
     }
     parameters[index++] = 'WindowID';
-    parameters[index++] = this.form.view.standardWindow.windowId;
+    parameters[index++] = view.standardWindow.windowId;
+    values = view.getContextInfo(false, true, true, true);
     length = this.inFields.length;
     for (i = 0; i < length; i++) {
       inpName = this.inFields[i];
-      fld = this.form.getFieldFromInpColumnName(inpName);
-      if (fld && fld.getValue()) {
-        parameters[index++] = 'inp' + fld.columnName;
-        parameters[index++] = fld.getValue();
+      propDef = view.getPropertyDefinitionFromInpColumnName(inpName);
+      if (propDef && values[inpName]) {        
+        // note the name passed is not the same as the inp name, it is inp + 
dbcolumn
+        parameters[index++] = 'inp' + propDef.dbColumn;
+        parameters[index++] = values[inpName];
+        // and to be save also pass the value as the input name
+        parameters[index++] = inpName;
+        parameters[index++] = values[inpName];
       }
     }
     this.openSearchWindow(this.searchUrl, parameters, this.getValue());
diff -r 2260f5f59c95 -r 8c027d350043 
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
      Wed Feb 02 14:26:32 2011 +0100
+++ 
b/modules/org.openbravo.client.application/web/org.openbravo.client.application/js/ob-standard-view.js
      Wed Feb 02 15:35:57 2011 +0100
@@ -1264,12 +1264,45 @@
     if (this.isShowingForm) {
       return this.viewForm.getValues();
     } else if (this.isEditingGrid) {
-      return this.viewGrid.getEditForm().getValues();
+      return isc.addProperties({}, this.viewGrid.getSelectedRecord(), 
this.viewGrid.getEditForm().getValues());
     } else {
       return this.viewGrid.getSelectedRecord();
     }
   },
   
+  getPropertyFromColumnName: function(columnName){
+    var length = this.view.propertyToColumns.length;
+    for (var i = 0; i < length; i++) {
+      var propDef = this.view.propertyToColumns[i];
+      if (propDef.dbColumn === columnName) {
+        return propDef.property;
+      }
+    }
+    return null;
+  },
+  
+  getPropertyFromDBColumnName: function(columnName){
+    var length = this.propertyToColumns.length;
+    for (var i = 0; i < length; i++) {
+      var propDef = this.propertyToColumns[i];
+      if (propDef.dbColumn === columnName) {
+        return propDef.property;
+      }
+    }
+    return null;
+  },
+  
+  getPropertyDefinitionFromInpColumnName: function(columnName){
+    var length = this.propertyToColumns.length;
+    for (var i = 0; i < length; i++) {
+      var propDef = this.propertyToColumns[i];
+      if (propDef.inpColumn === columnName) {
+        return propDef;
+      }
+    }
+    return null;
+  },
+
   //++++++++++++++++++ Reading context ++++++++++++++++++++++++++++++
   
   getContextInfo: function(onlySessionProperties, classicMode, 
forceSettingContextVars, convertToClassicFormat){
@@ -1284,16 +1317,16 @@
     // 1) showing grid with one record selected
     // 2) showing form with aux inputs
     if (this.isEditingGrid) {
-      record = this.viewGrid.getEditForm().getValues();
+      record = isc.addProperties({}, this.viewGrid.getSelectedRecord(), 
this.viewGrid.getEditForm().getValues());
       component = this.viewGrid.getEditForm();
       form = component;
-    } else if (!this.isShowingForm) {
-      record = this.viewGrid.getSelectedRecord();
-      component = this.viewGrid;
-    } else {
+    } else if (this.isShowingForm) {
       record = this.viewForm.getValues();
       component = this.viewForm;
       form = component;
+    } else {
+      record = this.viewGrid.getSelectedRecord();
+      component = this.viewGrid;
     }
     
     var properties = this.propertyToColumns;
@@ -1316,12 +1349,12 @@
             if (propertyObj.type && convertToClassicFormat) {
               type = SimpleType.getType(propertyObj.type);
               if (type.createClassicString) {
-                contextInfo[properties[i].column] = 
type.createClassicString(value);
+                contextInfo[properties[i].inpColumn] = 
type.createClassicString(value);
               } else {
-                contextInfo[properties[i].column] = value;
+                contextInfo[properties[i].inpColumn] = value;
               }
             } else {
-            contextInfo[properties[i].column] = value;
+            contextInfo[properties[i].inpColumn] = value;
             }
           } else {
             // surround the property name with @ symbols to make them different
@@ -1355,7 +1388,7 @@
     }
     
     if (this.parentView) {
-      isc.addProperties(contextInfo, 
this.parentView.getContextInfo(onlySessionProperties, classicMode));
+      isc.addProperties(this.parentView.getContextInfo(onlySessionProperties, 
classicMode, forceSettingContextVars, convertToClassicFormat), contextInfo);
     }
     
     return contextInfo;
@@ -1382,13 +1415,5 @@
     
OB.RemoteCallManager.call('org.openbravo.client.application.window.GetTabMessageActionHandler',
 {
       tabId: this.tabId
     }, null, callback, this);
-  },
-  
-  addStandardProperties: function(allProperties){
-    for(var objPropertyName in this.standardProperties){
-         if(this.standardProperties.hasOwnProperty(objPropertyName)){
-               
allProperties[objPropertyName]=this.standardProperties[objPropertyName];
-      }
-    }
   }
 });
diff -r 2260f5f59c95 -r 8c027d350043 
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
  Wed Feb 02 14:26:32 2011 +0100
+++ 
b/modules/org.openbravo.client.application/web/org.openbravo.client.application/js/ob-view-form.js
  Wed Feb 02 15:35:57 2011 +0100
@@ -191,17 +191,6 @@
     return this.fieldsByColumnName[columnName.toLowerCase()];
   },
   
-  getPropertyFromColumnName: function(columnName){
-    var length = this.view.propertyToColumns.length;
-    for (var i = 0; i < length; i++) {
-      var propDef = this.view.propertyToColumns[i];
-      if (propDef.dbColumn === columnName) {
-        return propDef.property;
-      }
-    }
-    return null;
-  },
-  
   setFields: function(){
     this.Super('setFields', arguments);
     this.fieldsByInpColumnName = null;
@@ -209,7 +198,10 @@
   },
   
   retrieveInitialValues: function(isNew){
-    var parentId = this.view.getParentId(), requestParams, parentColumn, me = 
this, mode, properties={};
+    var parentId = this.view.getParentId(), requestParams, parentColumn, me = 
this, mode;
+    // note also in this case initial vvalues are passed in as in case of grid
+    // editing the unsaved/error values from a previous edit session are 
maintained
+    var allProperties = this.view.getContextInfo(false, true, false, false);
     //this.setDisabled(true);
     //this.allItemsDisabled = true;
     
@@ -229,9 +221,8 @@
       parentColumn = this.getField(this.view.parentProperty).inpColumnName;
       requestParams[parentColumn] = parentId;
     }
-
-    this.view.addStandardProperties(properties);
-    
OB.RemoteCallManager.call('org.openbravo.client.application.window.FormInitializationComponent',
 properties, requestParams, function(response, data, request){
+    
+    
OB.RemoteCallManager.call('org.openbravo.client.application.window.FormInitializationComponent',
 allProperties, requestParams, function(response, data, request){
       me.processFICReturn(response, data, request);
       // remember the initial values 
       me.rememberValues();
@@ -248,7 +239,7 @@
     }
     
     var columnValues = data.columnValues, calloutMessages = 
data.calloutMessages,
-                       auxInputs = data.auxiliaryInputValues, prop, value,
+                       auxInputs = data.auxiliaryInputValues, prop, value, i,
                        dynamicCols = data.dynamicCols,
                        sessionAttributes = data.sessionAttributes;
     if (columnValues) {
@@ -292,13 +283,26 @@
     // note onFieldChanged uses the form.readOnly set above
     this.onFieldChanged(this);
     this.focus();
+    
+    // save out the values to the grid before redrawing
+    if (this.grid && this.grid.setEditValues && (this.grid.getEditRow() || 
this.grid.getEditRow() === 0)) {
+      this.grid.setEditValues(this.grid.getEditRow(), this.getValues(), true);
+    }
+    if (this.redrawItems) {
+      for (i = 0; i < this.redrawItems.length; i++) {
+        if (this.redrawItems[i].redraw) {
+          this.redrawItems[i].redraw();
+        }
+      }
+      delete this.redrawItems;
+    }
   },
   
   processColumnValue: function(columnName, columnValue){
     var data, record, length, valuePresent, currentValue, isDate, value, i, 
valueMap = {}, field = this.getFieldFromColumnName(columnName), entries = 
columnValue.entries;
     if (!field) {
       // not a field on the form, probably a datasource field
-      var prop = this.getPropertyFromColumnName(columnName);
+      var prop = this.view.getPropertyFromDBColumnName(columnName);
       if (!prop) {
         return;
       }
@@ -306,7 +310,14 @@
       if (!field) {
         return;
       }
+    } else {
+      // redraw at the end
+      if (!this.redrawItems) {
+        this.redrawItems = [];
+      }
+      this.redrawItems.push(field);
     }
+    
     // ignore the id
     if (field.name === OB.Constants.ID) {
       return;
@@ -357,10 +368,6 @@
     } else {
       this.clearValue(field.name);

------------------------------------------------------------------------------
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
Openbravo-commits@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/openbravo-commits

Reply via email to