fixed bug 24504, fixed bug 24502, related to bug 24403, related to bug 24402
authorAsier Lostalé <asier.lostale@openbravo.com>
Wed, 07 Aug 2013 16:26:59 +0200
changeset 20854 8b3d1a079183
parent 20853 fcf4d70d6019
child 20855 1fb4fef1d70b
fixed bug 24504, fixed bug 24502, related to bug 24403, related to bug 24402

Backout of fix for issue #24403 as it creates regressions #24504 and #24502
modules/org.openbravo.client.application/src-db/database/sourcedata/AD_MESSAGE.xml
modules/org.openbravo.client.application/src/org/openbravo/client/application/templates/ob-view-grid.js.ftl
modules/org.openbravo.client.application/src/org/openbravo/client/application/window/FormInitializationComponent.java
modules/org.openbravo.client.application/src/org/openbravo/client/application/window/OBViewFieldHandler.java
modules/org.openbravo.client.application/src/org/openbravo/client/application/window/OBViewGridComponent.java
modules/org.openbravo.client.application/web/org.openbravo.client.application/js/form/ob-view-form.js
modules/org.openbravo.client.application/web/org.openbravo.client.application/js/grid/ob-grid.js
modules/org.openbravo.client.application/web/org.openbravo.client.application/js/grid/ob-view-grid.js
modules/org.openbravo.client.application/web/org.openbravo.client.application/js/main/ob-standard-view.js
--- a/modules/org.openbravo.client.application/src-db/database/sourcedata/AD_MESSAGE.xml	Wed Aug 07 15:43:49 2013 +0200
+++ b/modules/org.openbravo.client.application/src-db/database/sourcedata/AD_MESSAGE.xml	Wed Aug 07 16:26:59 2013 +0200
@@ -1253,18 +1253,6 @@
 <!--B8C1706AB7C34C0EA750048CD68E314A-->  <ISINCLUDEINI18N><![CDATA[N]]></ISINCLUDEINI18N>
 <!--B8C1706AB7C34C0EA750048CD68E314A--></AD_MESSAGE>
 
-<!--BCA6318A99B54DB5A27D319C6569316B--><AD_MESSAGE>
-<!--BCA6318A99B54DB5A27D319C6569316B-->  <AD_MESSAGE_ID><![CDATA[BCA6318A99B54DB5A27D319C6569316B]]></AD_MESSAGE_ID>
-<!--BCA6318A99B54DB5A27D319C6569316B-->  <AD_CLIENT_ID><![CDATA[0]]></AD_CLIENT_ID>
-<!--BCA6318A99B54DB5A27D319C6569316B-->  <AD_ORG_ID><![CDATA[0]]></AD_ORG_ID>
-<!--BCA6318A99B54DB5A27D319C6569316B-->  <ISACTIVE><![CDATA[Y]]></ISACTIVE>
-<!--BCA6318A99B54DB5A27D319C6569316B-->  <VALUE><![CDATA[OBUIAPP_NotAddingFieldsWhileGridEditing]]></VALUE>
-<!--BCA6318A99B54DB5A27D319C6569316B-->  <MSGTEXT><![CDATA[New fields cannot be added to the grid while it is being edited.]]></MSGTEXT>
-<!--BCA6318A99B54DB5A27D319C6569316B-->  <MSGTYPE><![CDATA[E]]></MSGTYPE>
-<!--BCA6318A99B54DB5A27D319C6569316B-->  <AD_MODULE_ID><![CDATA[9BA0836A3CD74EE4AB48753A47211BCC]]></AD_MODULE_ID>
-<!--BCA6318A99B54DB5A27D319C6569316B-->  <ISINCLUDEINI18N><![CDATA[N]]></ISINCLUDEINI18N>
-<!--BCA6318A99B54DB5A27D319C6569316B--></AD_MESSAGE>
-
 <!--C415C626CAE14E35A7F05C42F11DA114--><AD_MESSAGE>
 <!--C415C626CAE14E35A7F05C42F11DA114-->  <AD_MESSAGE_ID><![CDATA[C415C626CAE14E35A7F05C42F11DA114]]></AD_MESSAGE_ID>
 <!--C415C626CAE14E35A7F05C42F11DA114-->  <AD_CLIENT_ID><![CDATA[0]]></AD_CLIENT_ID>
--- a/modules/org.openbravo.client.application/src/org/openbravo/client/application/templates/ob-view-grid.js.ftl	Wed Aug 07 15:43:49 2013 +0200
+++ b/modules/org.openbravo.client.application/src/org/openbravo/client/application/templates/ob-view-grid.js.ftl	Wed Aug 07 16:26:59 2013 +0200
@@ -12,7 +12,7 @@
  * under the License.
  * The Original Code is Openbravo ERP.
  * The Initial Developer of the Original Code is Openbravo SLU
- * All portions are Copyright (C) 2010-2013 Openbravo SLU
+ * All portions are Copyright (C) 2010-2011 Openbravo SLU
  * All Rights Reserved.
  * Contributor(s):  ______________________________________.
  ************************************************************************
@@ -39,10 +39,6 @@
         filterName: '${data.filterName?js_string}',
     </#if>
     
-    requiredGridProperties: [
-    <#list data.requiredGridProperties as property>
-        '${property?js_string}'<#if property_has_next>,</#if>
-    </#list>],
     // the this is the view instance
     fields: this.gridFields
 })
--- a/modules/org.openbravo.client.application/src/org/openbravo/client/application/window/FormInitializationComponent.java	Wed Aug 07 15:43:49 2013 +0200
+++ b/modules/org.openbravo.client.application/src/org/openbravo/client/application/window/FormInitializationComponent.java	Wed Aug 07 16:26:59 2013 +0200
@@ -821,21 +821,13 @@
     // database
     if (mode.equals("EDIT") && !dataSourceBasedTable) {
       // In EDIT mode we initialize them from the database
-      List<Column> columns = getADColumnList(tab.getTable().getId());
-      for (Column column : columns) {
-        setValueOfColumnInRequest(row, null, column.getDBColumnName());
+      for (Field field : fields) {
+        if (field.getColumn() == null) {
+          continue;
+        }
+        setValueOfColumnInRequest(row, field, field.getColumn().getDBColumnName());
       }
     }
-
-    List<String> gridVisibleProperties = new ArrayList<String>();
-    if (jsContent.has("_visibleProperties")) {
-      try {
-        gridVisibleProperties = convertJSONArray(jsContent.getJSONArray("_gridVisibleProperties"));
-      } catch (JSONException e) {
-        log.error("Error while retrieving _gridVisibleProperties from jsContent" + jsContent, e);
-      }
-    }
-
     // 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
@@ -843,14 +835,7 @@
         if (field.getColumn() == null) {
           continue;
         }
-        // Do not overwrite the value of fields that are not visible in the grid, because they are
-        // empty in the request
-
         final Property prop = KernelUtils.getInstance().getPropertyFromColumn(field.getColumn());
-        if ((mode.equals("EDIT") || mode.equals("SETSESSION"))
-            && !gridVisibleProperties.contains(prop.getName())) {
-          continue;
-        }
         String inpColName = "inp"
             + Sqlc.TransformaNombreColumna(field.getColumn().getDBColumnName());
         try {
--- a/modules/org.openbravo.client.application/src/org/openbravo/client/application/window/OBViewFieldHandler.java	Wed Aug 07 15:43:49 2013 +0200
+++ b/modules/org.openbravo.client.application/src/org/openbravo/client/application/window/OBViewFieldHandler.java	Wed Aug 07 16:26:59 2013 +0200
@@ -73,7 +73,6 @@
 
   private List<String> windowEntities = null;
   private List<OBViewFieldDefinition> fields;
-  private List<String> propertiesInButtonFieldDisplayLogic = new ArrayList<String>();
 
   private List<Field> ignoredFields = new ArrayList<Field>();
 
@@ -95,8 +94,7 @@
   }
 
   public List<OBViewFieldDefinition> getFields() {
-    final Entity entity = ModelProvider.getInstance().getEntityByTableId(
-        getTab().getTable().getId());
+
     if (fields != null) {
       return fields;
     }
@@ -131,13 +129,6 @@
         if (!fieldsInDynamicExpression.contains(fieldExpression)) {
           fieldsInDynamicExpression.add(fieldExpression);
         }
-        if ("Button".equals(f.getColumn().getReference().getName())) {
-          Property property = entity.getPropertyByColumnName(fieldExpression.getColumn()
-              .getDBColumnName());
-          if (!propertiesInButtonFieldDisplayLogic.contains(property.getName())) {
-            propertiesInButtonFieldDisplayLogic.add(property.getName());
-          }
-        }
       }
     }
 
@@ -2052,9 +2043,4 @@
     getFields(); // initializes stuff
     return ignoredFields;
   }
-
-  public List<String> getPropertiesInButtonFieldDisplayLogic() {
-    return propertiesInButtonFieldDisplayLogic;
-  }
-
 }
--- a/modules/org.openbravo.client.application/src/org/openbravo/client/application/window/OBViewGridComponent.java	Wed Aug 07 15:43:49 2013 +0200
+++ b/modules/org.openbravo.client.application/src/org/openbravo/client/application/window/OBViewGridComponent.java	Wed Aug 07 16:26:59 2013 +0200
@@ -18,14 +18,11 @@
  */
 package org.openbravo.client.application.window;
 
-import java.util.ArrayList;
 import java.util.HashMap;
-import java.util.List;
 import java.util.Map;
 
 import org.openbravo.base.model.Entity;
 import org.openbravo.base.model.ModelProvider;
-import org.openbravo.base.model.Property;
 import org.openbravo.client.application.window.OBViewFieldHandler.OBViewField;
 import org.openbravo.client.application.window.OBViewFieldHandler.OBViewFieldDefinition;
 import org.openbravo.client.kernel.BaseTemplateComponent;
@@ -234,27 +231,4 @@
     this.viewTab = viewTab;
   }
 
-  /**
-   * Returns the string representation of an array that contains all the properties that must always
-   * be returned from the datasource when the grid asks for data: - id - all the properties that
-   * compose the identifier of the entity - all the properties that are part of the display logic of
-   * the tab buttons
-   */
-  public List<String> getRequiredGridProperties() {
-    List<String> requiredGridProperties = new ArrayList<String>();
-    requiredGridProperties.add("id");
-
-    for (Property identifierProperty : this.entity.getIdentifierProperties()) {
-      requiredGridProperties.add(identifierProperty.getName());
-    }
-
-    List<String> propertiesInButtonFieldDisplayLogic = getViewTab().getFieldHandler()
-        .getPropertiesInButtonFieldDisplayLogic();
-
-    for (String propertyName : propertiesInButtonFieldDisplayLogic) {
-      requiredGridProperties.add(propertyName);
-    }
-
-    return requiredGridProperties;
-  }
 }
--- a/modules/org.openbravo.client.application/web/org.openbravo.client.application/js/form/ob-view-form.js	Wed Aug 07 15:43:49 2013 +0200
+++ b/modules/org.openbravo.client.application/web/org.openbravo.client.application/js/form/ob-view-form.js	Wed Aug 07 16:26:59 2013 +0200
@@ -567,9 +567,7 @@
     var parentId = this.view.getParentId(),
         i, fldNames = [],
         requestParams, allProperties, parentColumn, me = this,
-        mode, length = this.getFields().length,
-        gridVisibleProperties = [],
-        len;
+        mode, length = this.getFields().length;
 
     this.setParentDisplayInfo();
 
@@ -595,18 +593,6 @@
       requestParams[parentColumn] = parentId;
     }
 
-    if (this.view && this.view.viewGrid && this.view.viewGrid.fields) {
-      gridVisibleProperties.push('id');
-      len = this.view.viewGrid.fields.length;
-      for (i = 0; i < len; i++) {
-        if (this.view.viewGrid.fields[i].name[0] !== '_') {
-          gridVisibleProperties.push(this.view.viewGrid.fields[i].name);
-        }
-      }
-      allProperties._gridVisibleProperties = gridVisibleProperties;
-    }
-
-
     allProperties._entityName = this.view.entity;
 
     // only put the visible field names in the call
@@ -1975,4 +1961,4 @@
     }
     return true;
   }
-};
+};
\ No newline at end of file
--- a/modules/org.openbravo.client.application/web/org.openbravo.client.application/js/grid/ob-grid.js	Wed Aug 07 15:43:49 2013 +0200
+++ b/modules/org.openbravo.client.application/web/org.openbravo.client.application/js/grid/ob-grid.js	Wed Aug 07 16:26:59 2013 +0200
@@ -711,8 +711,7 @@
         dsURL = this.dataSource.dataURL;
     var sortCriteria;
     var lcriteria = this.getCriteria();
-    var gdata = this.getData(),
-        isExporting = true;
+    var gdata = this.getData();
     if (gdata && gdata.dataSource) {
       lcriteria = gdata.dataSource.convertRelativeDates(lcriteria);
     }
@@ -729,7 +728,7 @@
       exportToFile: true,
       _textMatchStyle: 'substring',
       _UTCOffsetMiliseconds: OB.Utilities.Date.getUTCOffsetInMiliseconds()
-    }, lcriteria, this.getFetchRequestParams(null, isExporting));
+    }, lcriteria, this.getFetchRequestParams());
     if (this.getSortField()) {
       sortCriteria = this.getSort();
       if (sortCriteria && sortCriteria.length > 0) {
--- a/modules/org.openbravo.client.application/web/org.openbravo.client.application/js/grid/ob-view-grid.js	Wed Aug 07 15:43:49 2013 +0200
+++ b/modules/org.openbravo.client.application/web/org.openbravo.client.application/js/grid/ob-view-grid.js	Wed Aug 07 16:26:59 2013 +0200
@@ -964,19 +964,12 @@
 
   showField: function (field, suppressRelayout) {
     var res;
-    // Do not allow to add a new field while the grid is being edited. Adding a new field implies a grid refresh, 
-    // and the refresh toolbar button is disabled while the grid/form is being edited
-    if (this.view.isEditingGrid) {
-      this.view.messageBar.setMessage(isc.OBMessageBar.TYPE_ERROR, OB.I18N.getLabel('OBUIAPP_Error'), OB.I18N.getLabel('OBUIAPP_NotAddingFieldsWhileGridEditing'));
-      return;
-    }
     this._showingField = true;
     this._savedEditValues = this.getEditValues(this.getEditRow());
     res = this.Super('showField', arguments);
     delete this._savedEditValues;
     delete this._showingField;
     this.view.standardWindow.storeViewState();
-    this.invalidateCache();
     this.refreshContents();
     return res;
   },
@@ -1956,8 +1949,7 @@
     requestProperties.params = this.getFetchRequestParams(requestProperties.params);
   },
 
-  getFetchRequestParams: function (params, isExporting) {
-    var i, len, first, selectedProperties;
+  getFetchRequestParams: function (params) {
     params = params || {};
 
     if (this.targetRecordId) {
@@ -2001,29 +1993,6 @@
     } else {
       params[OB.Constants.WHERE_PARAMETER] = null;
     }
-
-    if (!isExporting) {
-      first = true;
-      selectedProperties = '';
-      len = this.requiredGridProperties.length;
-      for (i = 0; i < len; i++) {
-        if (first) {
-          first = false;
-          selectedProperties = selectedProperties + this.requiredGridProperties[i];
-        } else {
-          selectedProperties = selectedProperties + ',' + this.requiredGridProperties[i];
-        }
-      }
-
-      len = this.fields.length;
-      for (i = 0; i < len; i++) {
-        if (this.fields[i].name[0] !== '_') {
-          selectedProperties = selectedProperties + ',';
-          selectedProperties = selectedProperties + this.fields[i].name;
-        }
-      }
-      params._selectedProperties = selectedProperties;
-    }
     return params;
   },
 
@@ -3532,50 +3501,19 @@
   },
 
   getFieldFromColumnName: function (columnName) {
-    var i, field, length, fields = this.view.propertyToColumns;
+    var i, field, length, fields = this.completeFields;
 
     length = fields.length;
 
     for (i = 0; i < fields.length; i++) {
-      if (fields[i].dbColumn === columnName) {
+      if (fields[i].columnName === columnName) {
         field = fields[i];
         break;
       }
     }
     return field;
-  },
-
-  processColumnValue: function (rowNum, columnName, columnValue) {
-    var field, newValue;
-    if (!columnValue) {
-      return;
-    }
-    field = this.getFieldFromColumnName(columnName);
-    if (!field) {
-      return;
-    }
-    newValue = {};
-    newValue[field.property] = columnValue.value;
-    this.setEditValue(rowNum, field.property, columnValue.value);
-  },
-
-  processFICReturn: function (response, data, request) {
-    var context = response && response.clientContext,
-        rowNum = context && context.rowNum,
-        grid = context && context.grid,
-        columnValues, prop, value, undef;
-
-    if (rowNum === undef || !data || !data.columnValues) {
-      return;
-    }
-    columnValues = data.columnValues;
-
-    for (prop in columnValues) {
-      if (columnValues.hasOwnProperty(prop)) {
-        grid.processColumnValue(rowNum, prop, columnValues[prop]);
-      }
-    }
   }
+
 });
 
 // = OBGridToolStripIcon =
--- a/modules/org.openbravo.client.application/web/org.openbravo.client.application/js/main/ob-standard-view.js	Wed Aug 07 15:43:49 2013 +0200
+++ b/modules/org.openbravo.client.application/web/org.openbravo.client.application/js/main/ob-standard-view.js	Wed Aug 07 16:26:59 2013 +0200
@@ -2151,7 +2151,6 @@
   },
 
   setContextInfo: function (sessionProperties, callbackFunction, forced) {
-    var newCallback, me = this;
     // no need to set the context in this case
     if (!forced && (this.isEditingGrid || this.isShowingForm)) {
       if (callbackFunction) {
@@ -2164,23 +2163,12 @@
       sessionProperties = this.getContextInfo(true, true, false, true);
     }
 
-    newCallback = function (response, data, request) {
-      var context = {}, grid = me.viewGrid;
-      context.rowNum = grid.getRecordIndex(grid.getSelectedRecord());
-      context.grid = grid;
-      response.clientContext = context;
-      grid.processFICReturn (response, data, request);
-      if (callbackFunction) {
-        callbackFunction();
-      }
-    };
-
     OB.RemoteCallManager.call('org.openbravo.client.application.window.FormInitializationComponent', sessionProperties, {
-      MODE: 'EDIT',
+      MODE: 'SETSESSION',
       TAB_ID: this.tabId,
       PARENT_ID: this.getParentId(),
       ROW_ID: this.viewGrid.getSelectedRecord() ? this.viewGrid.getSelectedRecord().id : this.getCurrentValues().id
-    }, newCallback);
+    }, callbackFunction);
 
   },