--- a/modules/org.openbravo.client.application/web/org.openbravo.client.application/js/form/formitem/ob-formitem-date.js Sun Feb 03 20:41:23 2013 +0100
+++ b/modules/org.openbravo.client.application/web/org.openbravo.client.application/js/form/formitem/ob-formitem-date.js Mon Feb 04 03:21:41 2013 +0100
@@ -11,7 +11,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) 2011-2012 Openbravo SLU
+ * All portions are Copyright (C) 2011-2013 Openbravo SLU
* All Rights Reserved.
* Contributor(s): ______________________________________.
************************************************************************
@@ -236,6 +236,26 @@
this.doInit();
},
+ getDateWithNewTime: function (date, time) {
+ var newDate, newTime, ret = date;
+ if (time) {
+ newTime = isc.Time.parseInput(time);
+ }
+ if (date && isc.isA.Date(date) && newTime && isc.isA.Date(newTime)) {
+ date.setHours(newTime.getHours(), newTime.getMinutes(), newTime.getSeconds());
+ ret = date;
+ }
+ return ret;
+ },
+
+ setValue: function () {
+ var newArguments = arguments;
+ if (this.fixedTime && arguments[0] && isc.isA.Date(arguments[0])) {
+ newArguments[0] = this.getDateWithNewTime(newArguments[0], this.fixedTime);
+ }
+ return this.Super('setValue', newArguments);
+ },
+
expandValue: function () {
var newValue = this.parseValue(),
oldValue = this.blurValue();
@@ -260,6 +280,9 @@
if (this.textField._textChanged) {
this.expandValue();
this.Super('updateValue', arguments);
+ if (this.fixedTime && this.getValue() && isc.isA.Date(this.getValue())) {
+ this.setValue(this.getValue()); // To force change the time with the fixed time (if exists) after expandValue
+ }
// when the date field has a callout and all the mandatory fields have been entered,
// the grid does not save the value before making the FIC call, so the value has to
// be saved explicitly
--- a/modules/org.openbravo.client.application/web/org.openbravo.client.application/js/form/formitem/ob-formitem-datetime.js Sun Feb 03 20:41:23 2013 +0100
+++ b/modules/org.openbravo.client.application/web/org.openbravo.client.application/js/form/formitem/ob-formitem-datetime.js Mon Feb 04 03:21:41 2013 +0100
@@ -11,7 +11,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) 2011-2012 Openbravo SLU
+ * All portions are Copyright (C) 2011-2013 Openbravo SLU
* All Rights Reserved.
* Contributor(s): ______________________________________.
************************************************************************
@@ -126,15 +126,24 @@
// == OBDateItem properties ==
isc.OBDateTimeItem.addProperties({
showTime: true,
+ fixedTime: null,
blurValue: function () {
- var value = OB.Utilities.Date.OBToJS(this.dateTextField.getElementValue(), OB.Format.dateTime);
- this.setValue(value);
- return value;
+ if (this.showTime) {
+ var value = OB.Utilities.Date.OBToJS(this.dateTextField.getElementValue(), OB.Format.dateTime);
+ this.setValue(value);
+ return value;
+ } else {
+ return this.Super('blurValue', arguments);
+ }
},
parseValue: function () {
- return this.dateTextField.getElementValue();
+ if (this.showTime) {
+ return this.dateTextField.getElementValue();
+ } else {
+ return this.Super('parseValue', arguments);
+ }
},
// ** {{{ change }}} **
@@ -145,9 +154,14 @@
return;
}
// prevent change events from happening
- var completedDate = isc.OBDateTimeItem.autoCompleteDate(item.dateFormat, value, this);
- if (completedDate !== oldValue) {
- item.setValue(completedDate);
+ if (!this.fixedTime || !this.getValue()) {
+ //FIXME: autoCompleteDate works wrong if partial time has been set
+ var completedDate = isc.OBDateTimeItem.autoCompleteDate(item.dateFormat, value, this);
+ if (completedDate !== oldValue) {
+ item.setValue(completedDate);
+ }
+ } else if (this.showTime && this.fixedTime) {
+ this.setValue(this.getValue()); // To force change the time with the fixed time (if exists)
}
},