details: /erp/devel/pi/rev/4092392748d8
changeset: 11571:4092392748d8
user: Martin Taal <martin.taal <at> openbravo.com>
date: Wed Apr 13 10:59:01 2011 +0200
summary: Fixes issue 16777: Autosave is triggered when using the Create new
widget from the navigation tool bar. Sales order
diffstat:
modules/org.openbravo.client.application/src/org/openbravo/client/application/window/FormInitializationComponent.java
| 64 +++++----
modules/org.openbravo.client.application/web/org.openbravo.client.application/js/ob-standard-view.js
| 2 +-
modules/org.openbravo.client.application/web/org.openbravo.client.application/js/ob-toolbar.js
| 4 +-
modules/org.openbravo.client.application/web/org.openbravo.client.application/js/ob-view-form.js
| 4 +-
modules/org.openbravo.client.kernel/src/org/openbravo/client/kernel/reference/NumberUIDefinition.java
| 6 +
modules/org.openbravo.userinterface.selector/web/org.openbravo.userinterface.selector/js/ob-selector-item.js
| 3 +-
6 files changed, 49 insertions(+), 34 deletions(-)
diffs (250 lines):
diff -r b5630110dd82 -r 4092392748d8
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 Apr 13 10:19:45 2011 +0200
+++
b/modules/org.openbravo.client.application/src/org/openbravo/client/application/window/FormInitializationComponent.java
Wed Apr 13 10:59:01 2011 +0200
@@ -157,7 +157,13 @@
if (property.getColumnName() != null) {
final String inpName = "inp" +
Sqlc.TransformaNombreColumna(property.getColumnName());
if (jsContent.has(inpName)) {
- convertedJson.put(property.getName(), jsContent.get(inpName));
+ final UIDefinition uiDef =
UIDefinitionController.getInstance().getUIDefinition(
+ property.getColumnId());
+ Object jsonValue = jsContent.get(inpName);
+ if (jsonValue instanceof String) {
+ jsonValue = uiDef.createFromClassicString((String) jsonValue);
+ }
+ convertedJson.put(property.getName(), jsonValue);
}
}
}
@@ -241,15 +247,17 @@
if (mode.equals("NEW") || mode.equals("EDIT") || mode.equals("CHANGE")) {
JSONObject jsonColumnValues = new JSONObject();
for (Field field : tab.getADFieldList()) {
- jsonColumnValues.put(field.getColumn().getDBColumnName(),
columnValues.get("inp"
- +
Sqlc.TransformaNombreColumna(field.getColumn().getDBColumnName())));
+ jsonColumnValues.put(
+ field.getColumn().getDBColumnName(),
+ columnValues.get("inp"
+ +
Sqlc.TransformaNombreColumna(field.getColumn().getDBColumnName())));
}
finalObject.put("columnValues", jsonColumnValues);
}
JSONObject jsonAuxiliaryInputValues = new JSONObject();
for (AuxiliaryInput auxIn : tab.getADAuxiliaryInputList()) {
- jsonAuxiliaryInputValues.put(auxIn.getName(), columnValues.get("inp"
- + Sqlc.TransformaNombreColumna(auxIn.getName())));
+ jsonAuxiliaryInputValues.put(auxIn.getName(),
+ columnValues.get("inp" +
Sqlc.TransformaNombreColumna(auxIn.getName())));
}
finalObject.put("auxiliaryInputValues", jsonAuxiliaryInputValues);
@@ -271,8 +279,8 @@
// Adding session attributes in a dynamic expression
// This session attributes could be a preference
if (field.getDisplayLogic() != null && field.isDisplayed() &&
field.isActive()) {
- final DynamicExpressionParser parser = new
DynamicExpressionParser(field
- .getDisplayLogic(), tab);
+ final DynamicExpressionParser parser = new DynamicExpressionParser(
+ field.getDisplayLogic(), tab);
for (String attrName : parser.getSessionAttributes()) {
if (!sessionAttributesMap.containsKey(attrName)) {
@@ -422,15 +430,16 @@
changedCols.add(field.getColumn().getDBColumnName());
}
}
- columnValues.put("inp"
- +
Sqlc.TransformaNombreColumna(field.getColumn().getDBColumnName()), jsonobject);
+ columnValues
+ .put("inp" +
Sqlc.TransformaNombreColumna(field.getColumn().getDBColumnName()),
+ jsonobject);
setRequestContextParameter(field, jsonobject);
// 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 (field.getColumn().isStoredInSession() ||
field.getColumn().isKeyColumn()) {
setSessionValue(tab.getWindow().getId() + "|"
- + field.getColumn().getDBColumnName().toUpperCase(),
jsonobject
- .has("classicValue") ? jsonobject.get("classicValue") :
null);
+ + field.getColumn().getDBColumnName().toUpperCase(),
+ jsonobject.has("classicValue") ?
jsonobject.get("classicValue") : null);
}
}
}
@@ -456,8 +465,7 @@
"Couldn't get data for column " +
field.getColumn().getDBColumnName(), e);
}
if (((mode.equals("NEW") && !classicValue.equals("") && (uiDef
instanceof EnumUIDefinition || uiDef instanceof ForeignKeyUIDefinition)) ||
(mode
- .equals("CHANGE")
- && changedCols.contains(field.getColumn().getDBColumnName()) &&
changedColumn != null))
+ .equals("CHANGE") &&
changedCols.contains(field.getColumn().getDBColumnName()) && changedColumn !=
null))
&& field.getColumn().isValidateOnNew()) {
if (field.getColumn().getCallout() != null) {
addCalloutToList(field.getColumn(), calloutsToCall,
lastfieldChanged);
@@ -498,8 +506,9 @@
JSONObject jsonobject = null;
if (value != null) {
jsonobject = new JSONObject(value);
- columnValues.put("inp"
- +
Sqlc.TransformaNombreColumna(field.getColumn().getDBColumnName()), jsonobject);
+ columnValues
+ .put("inp" +
Sqlc.TransformaNombreColumna(field.getColumn().getDBColumnName()),
+ jsonobject);
setRequestContextParameter(field, jsonobject);
}
} catch (Exception e) {
@@ -576,8 +585,8 @@
final Object propValue =
JsonToDataConverter.convertJsonToPropertyValue(prop,
jsContent.get(inpColName));
// convert to a valid classic string
- value = UIDefinitionController.getInstance().getUIDefinition(
- field.getColumn().getId()).convertToClassicString(propValue);
+ value = UIDefinitionController.getInstance()
+
.getUIDefinition(field.getColumn().getId()).convertToClassicString(propValue);
} else {
value = (String) jsonValue;
}
@@ -891,8 +900,8 @@
RequestContext.get().setRequestParameter("inpLastFieldChanged",
lastFieldChanged);
// We then execute the callout
- CalloutServletConfig config = new
CalloutServletConfig(calloutClassName, RequestContext
- .getServletContext());
+ CalloutServletConfig config = new
CalloutServletConfig(calloutClassName,
+ RequestContext.getServletContext());
Object[] initArgs = { config };
init.invoke(calloutInstance, initArgs);
CalloutHttpServletResponse fakeResponse = new
CalloutHttpServletResponse(rq.getResponse());
@@ -986,16 +995,16 @@
} else {
rq.setRequestParameter(colId,
uiDef.convertToClassicString(el));
}
- JSONObject jsonobj = new
JSONObject(uiDef.getFieldProperties(inpFields
- .get(name), true));
+ JSONObject jsonobj = new
JSONObject(uiDef.getFieldProperties(
+ inpFields.get(name), true));
if (jsonobj.has("classicValue")) {
String newValue = jsonobj.getString("classicValue");
log.debug("Modified column: " + col.getDBColumnName()
+ " Value: " + el);
if ((oldValue == null && newValue != null)
|| (oldValue != null && newValue == null)
|| (oldValue != null && newValue != null &&
!oldValue.equals(newValue))) {
- columnValues.put("inp"
- +
Sqlc.TransformaNombreColumna(col.getDBColumnName()), jsonobj);
+ columnValues.put(
+ "inp" +
Sqlc.TransformaNombreColumna(col.getDBColumnName()), jsonobj);
changed = true;
if (dynamicCols.contains(colId)) {
changedCols.add(col.getDBColumnName());
@@ -1003,8 +1012,7 @@
rq.setRequestParameter(colId,
jsonobj.getString("classicValue"));
}
} else {
- log
- .debug("Column value didn't change. We do not
attempt to execute any additional callout");
+ log.debug("Column value didn't change. We do not
attempt to execute any additional callout");
}
}
if (changed && col.getCallout() != null) {
@@ -1040,9 +1048,9 @@
*/
private void createNewPreferenceForWindow(Window window) {
- OBCriteria<Preference> prefCriteria =
OBDao.getFilteredCriteria(Preference.class, Expression
- .eq(Preference.PROPERTY_PROPERTY, "OBUIAPP_UseClassicMode"),
Expression.eq(
- Preference.PROPERTY_WINDOW, window));
+ OBCriteria<Preference> prefCriteria =
OBDao.getFilteredCriteria(Preference.class,
+ Expression.eq(Preference.PROPERTY_PROPERTY, "OBUIAPP_UseClassicMode"),
+ Expression.eq(Preference.PROPERTY_WINDOW, window));
if (prefCriteria.count() > 0) {
// Preference already exists. We don't create a new one.
return;
diff -r b5630110dd82 -r 4092392748d8
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 Apr 13 10:19:45 2011 +0200
+++
b/modules/org.openbravo.client.application/web/org.openbravo.client.application/js/ob-standard-view.js
Wed Apr 13 10:59:01 2011 +0200
@@ -1706,7 +1706,7 @@
return;
}
if (!sessionProperties) {
- sessionProperties = this.getContextInfo(true, true);
+ sessionProperties = this.getContextInfo(true, true, false, true);
}
OB.RemoteCallManager.call('org.openbravo.client.application.window.FormInitializationComponent',
sessionProperties, {
MODE: 'SETSESSION',
diff -r b5630110dd82 -r 4092392748d8
modules/org.openbravo.client.application/web/org.openbravo.client.application/js/ob-toolbar.js
---
a/modules/org.openbravo.client.application/web/org.openbravo.client.application/js/ob-toolbar.js
Wed Apr 13 10:19:45 2011 +0200
+++
b/modules/org.openbravo.client.application/web/org.openbravo.client.application/js/ob-toolbar.js
Wed Apr 13 10:59:01 2011 +0200
@@ -846,7 +846,7 @@
TAB_ID: this.view.tabId,
ROW_ID: currentValues.id
};
- var allProperties = this.view.getContextInfo(false, true, false, false);
+ var allProperties = this.view.getContextInfo(false, true, false, true);
OB.RemoteCallManager.call('org.openbravo.client.application.window.FormInitializationComponent',
allProperties, requestParams, function(response, data, request){
var sessionAttributes = data.sessionAttributes, auxInputs =
data.auxiliaryInputValues;
if (sessionAttributes) {
@@ -1113,7 +1113,7 @@
return;
}
- var popupParams = 'Command=DEFAULT', allProperties =
view.getContextInfo(false, true), sessionProperties = view.getContextInfo(true,
true);
+ var popupParams = 'Command=DEFAULT', allProperties =
view.getContextInfo(false, true, false, true), sessionProperties =
view.getContextInfo(true, true, false, true);
for (var param in allProperties) {
if (allProperties.hasOwnProperty(param)) {
diff -r b5630110dd82 -r 4092392748d8
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 Apr 13 10:19:45 2011 +0200
+++
b/modules/org.openbravo.client.application/web/org.openbravo.client.application/js/ob-view-form.js
Wed Apr 13 10:59:01 2011 +0200
@@ -395,7 +395,7 @@
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);
+ var allProperties = this.view.getContextInfo(false, true, false, true);
if (isNew) {
mode = 'NEW';
@@ -752,7 +752,7 @@
// note item can be null, is also called when the form is re-shown
// to recompute combos
doChangeFICCall: function(item){
- var parentId = null, me = this, requestParams, allProperties =
this.view.getContextInfo(false, true, false, false);
+ var parentId = null, me = this, requestParams, allProperties =
this.view.getContextInfo(false, true, false, true);
if (this.view.parentProperty) {
parentId = this.view.getParentId();
}
diff -r b5630110dd82 -r 4092392748d8
modules/org.openbravo.client.kernel/src/org/openbravo/client/kernel/reference/NumberUIDefinition.java
---
a/modules/org.openbravo.client.kernel/src/org/openbravo/client/kernel/reference/NumberUIDefinition.java
Wed Apr 13 10:19:45 2011 +0200
+++
b/modules/org.openbravo.client.kernel/src/org/openbravo/client/kernel/reference/NumberUIDefinition.java
Wed Apr 13 10:59:01 2011 +0200
@@ -163,6 +163,12 @@
public String getFormat() {
return "integerEdition";
}
+
+ @Override
+ public Object createFromClassicString(String value) {
+ final BigDecimal superValue = (BigDecimal)
super.createFromClassicString(value);
+ return superValue.longValue();
+ }
}
public static class AmountUIDefinition extends NumberUIDefinition {
diff -r b5630110dd82 -r 4092392748d8
modules/org.openbravo.userinterface.selector/web/org.openbravo.userinterface.selector/js/ob-selector-item.js
---
a/modules/org.openbravo.userinterface.selector/web/org.openbravo.userinterface.selector/js/ob-selector-item.js
Wed Apr 13 10:19:45 2011 +0200
+++
b/modules/org.openbravo.userinterface.selector/web/org.openbravo.userinterface.selector/js/ob-selector-item.js
Wed Apr 13 10:59:01 2011 +0200
@@ -370,6 +370,7 @@
},
setValueFromRecord: function(record){
+ var currentValue = this.getValue();
if (!record) {
this.setValue(null);
this.form.setValue(this.name + '.' + this.displayField, null);
@@ -387,7 +388,7 @@
this.form.focusInNextItem(this.name);
}
}
- if (this.form && this.form.handleItemChange) {
+ if (currentValue !== this.getValue() && this.form &&
this.form.handleItemChange) {
this._hasChanged = true;
this.form.handleItemChange(this);
}
------------------------------------------------------------------------------
Forrester Wave Report - Recovery time is now measured in hours and minutes
not days. Key insights are discussed in the 2010 Forrester Wave Report as
part of an in-depth evaluation of disaster recovery service providers.
Forrester found the best-in-class provider in terms of services and vision.
Read this report now! http://p.sf.net/sfu/ibm-webcastpromo
_______________________________________________
Openbravo-commits mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/openbravo-commits