details: https://code.openbravo.com/erp/devel/pi/rev/94d0fb151919
changeset: 21243:94d0fb151919
user: Augusto Mauch <augusto.mauch <at> openbravo.com>
date: Mon Oct 07 17:17:08 2013 +0200
summary: Fixes bug 24402, fixes bug 24403: Grid Datasource load minimum
property set
Changes with respect to changeset 20851:
- In the FIC, do not try to set in the session the values of properties that
are empty in the request due to being shown only in grid view. In this case the
value that will prevail will be the one present in the database.
- New mandatory property fields:
* Client and organization
* Button fields with label values
* Link to parent properties
- In the grid, do not detect as a change if a value change from undefined to
not undefined. Otherwise, when the user opens a record in form view the record
would appear as changed. This happens because the properties that are present
in the form but not in the grid change from undefined to not undefined.
- The fieldStateChanged function has been deleted. This function handled the
case when the user added a new column to the grid while it was being edited.
This action is no longer allowed, so the function serves no purpose.
- The FIC call in the setContextInfo has been changed from SETSESSION to EDIT,
because now in the response we need the values of all the view fields, not only
the shown in the grid. A callback has been defined to apply this new values to
the grid.
diffstat:
modules/org.openbravo.client.application/src-db/database/sourcedata/AD_MESSAGE.xml
| 12 +
modules/org.openbravo.client.application/src/org/openbravo/client/application/templates/ob-view-grid.js.ftl
| 8 +-
modules/org.openbravo.client.application/src/org/openbravo/client/application/window/FormInitializationComponent.java
| 54 +++-
modules/org.openbravo.client.application/src/org/openbravo/client/application/window/OBViewFieldHandler.java
| 18 +-
modules/org.openbravo.client.application/src/org/openbravo/client/application/window/OBViewGridComponent.java
| 66 +++++
modules/org.openbravo.client.application/web/org.openbravo.client.application/js/form/ob-view-form.js
| 32 ++-
modules/org.openbravo.client.application/web/org.openbravo.client.application/js/grid/ob-grid.js
| 5 +-
modules/org.openbravo.client.application/web/org.openbravo.client.application/js/grid/ob-view-grid.js
| 123 ++++++++-
modules/org.openbravo.client.application/web/org.openbravo.client.application/js/main/ob-standard-view-datasource.js
| 13 +
modules/org.openbravo.client.application/web/org.openbravo.client.application/js/main/ob-standard-view.js
| 35 ++-
modules/org.openbravo.client.application/web/org.openbravo.client.application/js/toolbar/ob-toolbar.js
| 11 +-
11 files changed, 341 insertions(+), 36 deletions(-)
diffs (truncated from 685 to 300 lines):
diff -r 43459dd69e37 -r 94d0fb151919
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
Mon Oct 07 15:22:32 2013 +0200
+++
b/modules/org.openbravo.client.application/src-db/database/sourcedata/AD_MESSAGE.xml
Mon Oct 07 17:17:08 2013 +0200
@@ -1266,6 +1266,18 @@
<!--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>
diff -r 43459dd69e37 -r 94d0fb151919
modules/org.openbravo.client.application/src/org/openbravo/client/application/templates/ob-view-grid.js.ftl
---
a/modules/org.openbravo.client.application/src/org/openbravo/client/application/templates/ob-view-grid.js.ftl
Mon Oct 07 15:22:32 2013 +0200
+++
b/modules/org.openbravo.client.application/src/org/openbravo/client/application/templates/ob-view-grid.js.ftl
Mon Oct 07 17:17:08 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-2011 Openbravo SLU
+ * All portions are Copyright (C) 2010-2013 Openbravo SLU
* All Rights Reserved.
* Contributor(s): ______________________________________.
************************************************************************
@@ -38,7 +38,11 @@
<#if data.filterName != "">
filterName: '${data.filterName?js_string}',
</#if>
-
+ //List of properties that must be always included in this grid
+ requiredGridProperties: [
+ <#list data.requiredGridProperties as property>
+ '${property?js_string}'<#if property_has_next>,</#if>
+ </#list>],
// the this is the view instance
fields: this.gridFields
})
diff -r 43459dd69e37 -r 94d0fb151919
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
Mon Oct 07 15:22:32 2013 +0200
+++
b/modules/org.openbravo.client.application/src/org/openbravo/client/application/window/FormInitializationComponent.java
Mon Oct 07 17:17:08 2013 +0200
@@ -169,6 +169,10 @@
if (jsContent.has("_visibleProperties")) {
visibleProperties =
convertJSONArray(jsContent.getJSONArray("_visibleProperties"));
}
+ List<String> gridVisibleProperties = new ArrayList<String>();
+ if (jsContent.has("_gridVisibleProperties")) {
+ gridVisibleProperties =
convertJSONArray(jsContent.getJSONArray("_gridVisibleProperties"));
+ }
// If the table is based in a datasource, don't try to create a
BaseOBObject
if (!dataSourceBasedTable) {
@@ -242,7 +246,7 @@
long t5 = System.currentTimeMillis();
computeColumnValues(mode, tab, allColumns, columnValues, parentRecord,
parentId,
changedColumn, jsContent, changeEventCols, calloutsToCall,
lastfieldChanged,
- visibleProperties);
+ visibleProperties, gridVisibleProperties);
if (mode.equals("NEW")) {
// In the case of NEW mode, we compute auxiliary inputs again to take
into account that
@@ -537,7 +541,8 @@
private void computeColumnValues(String mode, Tab tab, List<String>
allColumns,
Map<String, JSONObject> columnValues, BaseOBObject parentRecord, String
parentId,
String changedColumn, JSONObject jsContent, List<String> changeEventCols,
- List<String> calloutsToCall, List<String> lastfieldChanged, List<String>
visibleProperties) {
+ List<String> calloutsToCall, List<String> lastfieldChanged, List<String>
visibleProperties,
+ List<String> gridVisibleProperties) {
boolean forceComboReload = (mode.equals("CHANGE") && changedColumn ==
null);
if (mode.equals("CHANGE") && changedColumn != null) {
RequestContext.get().setRequestParameter("donotaddcurrentelement",
"true");
@@ -654,12 +659,23 @@
changedCols.add(field.getColumn().getDBColumnName());
}
}
+
columnValues
.put("inp" +
Sqlc.TransformaNombreColumna(field.getColumn().getDBColumnName()),
jsonobject);
setRequestContextParameter(field, jsonobject);
+
+ String fullPropertyName = null;
+ if (field.getProperty() != null) {
+ fullPropertyName = field.getProperty().replace('.', '$');
+ } else {
+ fullPropertyName = prop.getName();
+ }
+
// We also set the session value for the column in Edit or
SetSession mode
- if (mode.equals("NEW") || mode.equals("EDIT") ||
mode.equals("SETSESSION")) {
+ if (gridVisibleProperties.contains(fullPropertyName)
+ && (mode.equals("NEW") || mode.equals("EDIT") ||
mode.equals("SETSESSION"))) {
+
if (field.getColumn().isStoredInSession() ||
field.getColumn().isKeyColumn()) {
setSessionValue(tab.getWindow().getId() + "|"
+ field.getColumn().getDBColumnName().toUpperCase(),
@@ -821,13 +837,22 @@
// database
if (mode.equals("EDIT") && !dataSourceBasedTable) {
// In EDIT mode we initialize them from the database
- for (Field field : fields) {
- if (field.getColumn() == null) {
- continue;
- }
- setValueOfColumnInRequest(row, field,
field.getColumn().getDBColumnName());
+ List<Column> columns = getADColumnList(tab.getTable().getId());
+
+ for (Column column : columns) {
+ setValueOfColumnInRequest(row, null, column.getDBColumnName());
}
}
+
+ List<String> gridVisibleProperties = new ArrayList<String>();
+ if (jsContent.has("_gridVisibleProperties")) {
+ 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
@@ -835,7 +860,20 @@
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());
+ String fullPropertyName = null;
+ if (field.getProperty() != null) {
+ fullPropertyName = field.getProperty().replace('.', '$');
+ } else {
+ fullPropertyName = prop.getName();
+ }
+ if ((mode.equals("EDIT") || mode.equals("SETSESSION"))
+ && !gridVisibleProperties.contains(fullPropertyName)) {
+ continue;
+ }
String inpColName = "inp"
+
Sqlc.TransformaNombreColumna(field.getColumn().getDBColumnName());
try {
diff -r 43459dd69e37 -r 94d0fb151919
modules/org.openbravo.client.application/src/org/openbravo/client/application/window/OBViewFieldHandler.java
---
a/modules/org.openbravo.client.application/src/org/openbravo/client/application/window/OBViewFieldHandler.java
Mon Oct 07 15:22:32 2013 +0200
+++
b/modules/org.openbravo.client.application/src/org/openbravo/client/application/window/OBViewFieldHandler.java
Mon Oct 07 17:17:08 2013 +0200
@@ -73,6 +73,7 @@
private List<String> windowEntities = null;
private List<OBViewFieldDefinition> fields;
+ private List<String> propertiesInButtonFieldDisplayLogic = new
ArrayList<String>();
private List<Field> ignoredFields = new ArrayList<Field>();
@@ -94,7 +95,8 @@
}
public List<OBViewFieldDefinition> getFields() {
-
+ final Entity entity = ModelProvider.getInstance().getEntityByTableId(
+ getTab().getTable().getId());
if (fields != null) {
return fields;
}
@@ -129,6 +131,15 @@
if (!fieldsInDynamicExpression.contains(fieldExpression)) {
fieldsInDynamicExpression.add(fieldExpression);
}
+ // All the properties that are used in the display logic of the
buttons must be included in
+ // the list of grid mandatory columns
+ if ("Button".equals(f.getColumn().getReference().getName())) {
+ Property property =
entity.getPropertyByColumnName(fieldExpression.getColumn()
+ .getDBColumnName());
+ if
(!propertiesInButtonFieldDisplayLogic.contains(property.getName())) {
+ propertiesInButtonFieldDisplayLogic.add(property.getName());
+ }
+ }
}
}
@@ -2043,4 +2054,9 @@
getFields(); // initializes stuff
return ignoredFields;
}
+
+ public List<String> getPropertiesInButtonFieldDisplayLogic() {
+ return propertiesInButtonFieldDisplayLogic;
+ }
+
}
diff -r 43459dd69e37 -r 94d0fb151919
modules/org.openbravo.client.application/src/org/openbravo/client/application/window/OBViewGridComponent.java
---
a/modules/org.openbravo.client.application/src/org/openbravo/client/application/window/OBViewGridComponent.java
Mon Oct 07 15:22:32 2013 +0200
+++
b/modules/org.openbravo.client.application/src/org/openbravo/client/application/window/OBViewGridComponent.java
Mon Oct 07 17:17:08 2013 +0200
@@ -18,14 +18,19 @@
*/
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.application.window.OBViewTab.ButtonField;
import org.openbravo.client.kernel.BaseTemplateComponent;
+import org.openbravo.client.kernel.KernelUtils;
import org.openbravo.client.kernel.RequestContext;
import org.openbravo.client.kernel.Template;
import org.openbravo.dal.core.DalUtil;
@@ -231,4 +236,65 @@
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
+ * - client and organization
+ * - all the properties that compose the identifier of the entity
+ * - all button fields with label values
+ * - the link to parent properties
+ * - 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");
+ requiredGridProperties.add("client");
+ requiredGridProperties.add("organization");
+
+ for (Property identifierProperty : this.entity.getIdentifierProperties()) {
+ requiredGridProperties.add(identifierProperty.getName());
+ }
+
+ List<ButtonField> buttonFields = getViewTab().getButtonFields();
+ for (ButtonField buttonField : buttonFields) {
+ if (!buttonField.getLabelValues().isEmpty()) {
+ requiredGridProperties.add(buttonField.getPropertyName());
+ }
+ }
+
+ List<String> propertiesInButtonFieldDisplayLogic =
getViewTab().getFieldHandler()
+ .getPropertiesInButtonFieldDisplayLogic();
+
+ for (String propertyName : propertiesInButtonFieldDisplayLogic) {
+ requiredGridProperties.add(propertyName);
+ }
+
+ String linkToParentPropertyName = this.getLinkToParentPropertyName();
+ if (linkToParentPropertyName != null &&
!linkToParentPropertyName.isEmpty()) {
+ requiredGridProperties.add(linkToParentPropertyName);
+ }
+
+ return requiredGridProperties;
+ }
+
+ private String getLinkToParentPropertyName() {
+ Tab parentTab = KernelUtils.getInstance().getParentTab(tab);
+ if (parentTab == null) {
+ return null;
+ }
+ List<Property> linkToparentPropertyList = entity.getParentProperties();
+ if (linkToparentPropertyList.isEmpty()) {
+ return null;
+ }
+ String parentTableId = parentTab.getTable().getId();
+ for (Property linkToParentProperty : linkToparentPropertyList) {
+ Property referencedProperty =
linkToParentProperty.getReferencedProperty();
+ String referencedTableId = referencedProperty.getEntity().getTableId();
+ if (parentTableId.equals(referencedTableId)) {
+ return linkToParentProperty.getName();
+ }
+ }
+ return null;
+ }
}
diff -r 43459dd69e37 -r 94d0fb151919
modules/org.openbravo.client.application/web/org.openbravo.client.application/js/form/ob-view-form.js
---
a/modules/org.openbravo.client.application/web/org.openbravo.client.application/js/form/ob-view-form.js
Mon Oct 07 15:22:32 2013 +0200
+++
b/modules/org.openbravo.client.application/web/org.openbravo.client.application/js/form/ob-view-form.js
Mon Oct 07 17:17:08 2013 +0200
@@ -543,6 +543,22 @@
return this.fieldsByColumnName[columnName.toLowerCase()];
},
+ getFieldFromFieldName: function (fieldName) {
+ var i, length, localResult, fields;
+ if (!this.fieldsByFieldName) {
------------------------------------------------------------------------------
October Webinars: Code for Performance
Free Intel webinars can help you accelerate application performance.
Explore tips for MPI, OpenMP, advanced profiling, and more. Get the most from
the latest Intel processors and coprocessors. See abstracts and register >
http://pubads.g.doubleclick.net/gampad/clk?id=60134791&iu=/4140/ostg.clktrk
_______________________________________________
Openbravo-commits mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/openbravo-commits