details: https://code.openbravo.com/erp/devel/pi/rev/99a1cd55eaaa changeset: 34161:99a1cd55eaaa user: Carlos Aristu <carlos.aristu <at> openbravo.com> date: Fri Jun 01 14:53:03 2018 +0200 summary: related to issue 38661: initial code clean up
Removed some unused variables details: https://code.openbravo.com/erp/devel/pi/rev/b06b5a1512ec changeset: 34162:b06b5a1512ec user: Carlos Aristu <carlos.aristu <at> openbravo.com> date: Fri Jun 01 09:20:31 2018 +0200 summary: fixes bug 38661: False form change detection due to blur event of 'Time' fields When a blur was performed on time fields, false changes were being detected in the form. This was happening because the comparison done by SC between the value of the field and the value returned with the mapDisplayToValue() function were different. Changes were detected because time fields stores also the date, and when getting/setting the value todays date is set as date. This change was not being done in the mapDisplayToValue() function. So, now we are setting todays date in the value returned by mapDisplayToValue() in order to be consistent. This avoids the false change detection in the form. Note that we are extracting the setTodaysDate as a class method of OBTimeItem, this is because how SC TimeItem is invoking the mapDisplayToValue() function[1]. This way we ensure that the function can always be found. [1] https://code.openbravo.com/erp/mods/org.openbravo.userinterface.smartclient.dev/file/tip/web/org.openbravo.userinterface.smartclient/isomorphic/client/widgets/form/TimeItem.js#l281 diffstat: modules/org.openbravo.client.application/web/org.openbravo.client.application/js/form/formitem/ob-formitem-time.js | 44 ++++----- 1 files changed, 19 insertions(+), 25 deletions(-) diffs (119 lines): diff -r 4bd839ca0394 -r b06b5a1512ec modules/org.openbravo.client.application/web/org.openbravo.client.application/js/form/formitem/ob-formitem-time.js --- a/modules/org.openbravo.client.application/web/org.openbravo.client.application/js/form/formitem/ob-formitem-time.js Fri Jun 01 12:49:04 2018 +0200 +++ b/modules/org.openbravo.client.application/web/org.openbravo.client.application/js/form/formitem/ob-formitem-time.js Fri Jun 01 09:20:31 2018 +0200 @@ -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-2017 Openbravo SLU + * All portions are Copyright (C) 2011-2018 Openbravo SLU * All Rights Reserved. * Contributor(s): ______________________________________. ************************************************************************ @@ -25,6 +25,20 @@ // For entering times. isc.ClassFactory.defineClass('OBTimeItem', isc.TimeItem); +isc.OBTimeItem.addClassMethods({ + setTodaysDate: function (date) { + var today = new Date(); + // Set the month initially to January to prevent error like this + // provided date: 15/02/2014 + // today: 31/03/2014 + // date.setDate(today.getDate()) would result in Mon Mar 02 2014 18:00:00 GMT+0100 (CET), because february does not have 31 days + date.setMonth(0); + date.setDate(today.getDate()); + date.setMonth(today.getMonth()); + date.setYear(today.getFullYear()); + } +}); + isc.OBTimeItem.addProperties({ useTextField: true, operator: 'equals', @@ -49,6 +63,7 @@ var newValue = value; if (newValue && Object.prototype.toString.call(newValue) === '[object String]') { newValue = isc.Time.parseInput(newValue); + isc.OBTimeItem.setTodaysDate(newValue); if (this.isAbsoluteTime) { // In the case of an absolute time, the time needs to be converted in order to avoid the UTC conversion // http://forums.smartclient.com/showthread.php?p=116135 @@ -91,7 +106,7 @@ if (this.isAbsoluteTime) { value = OB.Utilities.Date.addTimezoneOffset(value); } - this.setTodaysDate(value); + isc.OBTimeItem.setTodaysDate(value); if (this.isAbsoluteTime) { value = OB.Utilities.Date.substractTimezoneOffset(value); } @@ -102,23 +117,11 @@ getValue: function () { var value = this.Super('getValue', arguments); if (value && isc.isA.Date(value) && !this.isAbsoluteTime) { - this.setTodaysDate(value); + isc.OBTimeItem.setTodaysDate(value); } return value; }, - setTodaysDate: function (date) { - var today = new Date(); - // Set the month initially to January to prevent error like this - // provided date: 15/02/2014 - // today: 31/03/2014 - // date.setDate(today.getDate()) would result in Mon Mar 02 2014 18:00:00 GMT+0100 (CET), because february does not have 31 days - date.setMonth(0); - date.setDate(today.getDate()); - date.setMonth(today.getMonth()); - date.setYear(today.getFullYear()); - }, - /* The following functions allow proper timeGrid operation */ doShowTimeGrid: function (timeValue) { @@ -271,7 +274,7 @@ _waitingForReFocus: [], dateObjToTimeString: function (dateObj) { - var lengthThreshold, tmpString, isPM = false, + var tmpString, isPM = false, dateString = ''; if (this.precission === 'hour' || this.precission === 'minute' || this.precission === 'second') { tmpString = dateObj.getHours(); @@ -313,7 +316,6 @@ return dateString; }, timeStringToDateObj: function (stringTime) { - var lengthThreshold; if (stringTime.length < 3) { stringTime = stringTime + ':00:00'; } else if (stringTime.length < 6) { @@ -355,17 +357,11 @@ }, getDiffText: function (date, reference) { var diffMs = (date - reference), - diffDays = (diffMs / 86400000), diffHrs = ((diffMs % 86400000) / 3600000), diffMins = (((diffMs % 86400000) % 3600000) / 60000), diffSecs = ((((diffMs % 86400000) % 3600000) % 60000) / 1000), diffText = ''; - if (diffDays >= 0) { - diffDays = Math.floor(diffDays); - } else { - diffDays = Math.ceil(diffDays); - } if (diffHrs >= 0) { diffHrs = Math.floor(diffHrs); } else { @@ -577,8 +573,6 @@ } }, updatePosition: function () { - var me = this, - interval; if (this.formItem) { this.placeNear(this.formItem.getPageLeft() + 2, this.formItem.getPageTop() + 26); } ------------------------------------------------------------------------------ Check out the vibrant tech community on one of the world's most engaging tech sites, Slashdot.org! http://sdm.link/slashdot _______________________________________________ Openbravo-commits mailing list Openbravo-commits@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/openbravo-commits