details: /erp/devel/pi/rev/19eaac5626ce
changeset: 11465:19eaac5626ce
user: Antonio Moreno <antonio.moreno <at> openbravo.com>
date: Mon Apr 04 18:41:52 2011 +0200
summary: Fixed issue 16399. Date defaults will be set differently so they
don't require a date reference.
Two changes have been done:
- In the UIDefinition, if the default is '@#Date', we will first check if the
UIDefinition is a Date one, and if not, we will find one that is. Then, we will
use its specific methods to correctly parse the date into a correctly defined
date.
- In the UI, if the column value has 'hasDateDefault' set, then we will use the
classic value (which has the nice looking date, instead of the JSON one)
diffstat:
modules/org.openbravo.client.application/web/org.openbravo.client.application/js/ob-view-form.js
| 2 +
modules/org.openbravo.client.kernel/src/org/openbravo/client/kernel/reference/UIDefinition.java
| 24 +++++++++-
2 files changed, 25 insertions(+), 1 deletions(-)
diffs (53 lines):
diff -r ed872a6860b6 -r 19eaac5626ce
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
Mon Apr 04 17:27:16 2011 +0200
+++
b/modules/org.openbravo.client.application/web/org.openbravo.client.application/js/ob-view-form.js
Mon Apr 04 18:41:52 2011 +0200
@@ -615,6 +615,8 @@
isc.SimpleType.getType(field.type).inheritsFrom === 'datetime');
if (isDate) {
this.setValue(field.name, isc.Date.parseSchemaDate(columnValue.value));
+ } else if(columnValue.hasDateDefault){
+ this.setValue(field.name, columnValue.classicValue);
} else {
// set the identifier/display field if the identifier is passed also
diff -r ed872a6860b6 -r 19eaac5626ce
modules/org.openbravo.client.kernel/src/org/openbravo/client/kernel/reference/UIDefinition.java
---
a/modules/org.openbravo.client.kernel/src/org/openbravo/client/kernel/reference/UIDefinition.java
Mon Apr 04 17:27:16 2011 +0200
+++
b/modules/org.openbravo.client.kernel/src/org/openbravo/client/kernel/reference/UIDefinition.java
Mon Apr 04 18:41:52 2011 +0200
@@ -164,7 +164,7 @@
defaultS = "";
}
if (defaultS.equalsIgnoreCase("@#Date@")) {
- columnValue = this.convertToClassicString(new Date());
+ return setNOWDefault();
} else if (!defaultS.startsWith("@SQL=")) {
columnValue = Utility.getDefault(new DalConnectionProvider(false), rq
.getVariablesSecureApp(), field.getColumn().getDBColumnName(),
defaultS, field
@@ -217,6 +217,28 @@
return jsnobject.toString();
}
+ private String setNOWDefault() {
+ JSONObject jsnobject = new JSONObject();
+ try {
+ UIDefinition uiDef = this;
+ if (!(this instanceof DateUIDefinition)) {
+ for (UIDefinition def :
UIDefinitionController.getInstance().getAllUIDefinitions()) {
+ if (def instanceof DateUIDefinition) {
+ uiDef = def;
+ break;
+ }
+ }
+ }
+ String columnValue = uiDef.convertToClassicString(new Date());
+ jsnobject.put("value", uiDef.createFromClassicString(columnValue));
+ jsnobject.put("classicValue", columnValue);
+ jsnobject.put("hasDateDefault", true);
+ } catch (JSONException e) {
+ log.error("Couldn't get field property value");
+ }
+ return jsnobject.toString();
+ }
+
/**
* Convert a string value as used in classic OB to a type safe value.
*
------------------------------------------------------------------------------
Create and publish websites with WebMatrix
Use the most popular FREE web apps or write code yourself;
WebMatrix provides all the features you need to develop and
publish your website. http://p.sf.net/sfu/ms-webmatrix-sf
_______________________________________________
Openbravo-commits mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/openbravo-commits