details: https://code.openbravo.com/erp/devel/main/rev/b3d59ac71557 changeset: 15692:b3d59ac71557 user: Augusto Mauch <augusto.mauch <at> openbravo.com> date: Thu Mar 08 13:22:38 2012 +0100 summary: Fixes issue 19694: Wrong behaviour when introducing a date in grid
The function update value of ob-formitem-date.js was only meant to be called in the cellEditEnd in the grid view or when the item loses focus in the form view. The behaviour was wrong because the updateValue function was also being called while the field was being edited. A flag (_preventDateParsing) has been added to the grid to ensure that the updateValue function is only called when needed. details: https://code.openbravo.com/erp/devel/main/rev/91b919ad8410 changeset: 15693:91b919ad8410 user: Augusto Mauch <augusto.mauch <at> openbravo.com> date: Mon Mar 12 13:33:49 2012 +0100 summary: Related to issue 19694: Date value is now always updated after losing focus After applying the previous fix (changeset 15739), if the date field had a callback, its value was not being updated correctly if it had the focus and the tab key was pressed. In the previous fix, if the _preventDateParsing tag was true, the date was neither parsed nor updated. Now if the flag is active the date is not parsed, but the value is updated anyway. details: https://code.openbravo.com/erp/devel/main/rev/25845513c389 changeset: 15694:25845513c389 user: Augusto Mauch <augusto.mauch <at> openbravo.com> date: Tue Mar 13 10:08:31 2012 +0100 summary: Related to issue 19694: All date grid fields are updated correctly The previous commit (changeset 15758) fixed the behaviour of the date grid fields that had a callback, but broke the date grid fields that did not. Now the way to update a date field is the following: - If parsing is prevent (while the field is being entered, for example) do not update the field either. If the parsing is not done but the field is updated anyway, the field gets to store invalid values. The update will only be done after the value has been parsed. - After parsing and updating, force the new value to be updated in grid.getEnteredValues(). This had to be explicitly done because otherwise the field is not yet updated in that structure when making the FIC call, causing the previous value to be re-entered. diffstat: modules/org.openbravo.client.application/web/org.openbravo.client.application/js/form/formitem/ob-formitem-date.js | 13 +++++++++- modules/org.openbravo.client.application/web/org.openbravo.client.application/js/form/ob-view-form.js | 11 ++++++- modules/org.openbravo.client.application/web/org.openbravo.client.application/js/grid/ob-view-grid.js | 2 + 3 files changed, 23 insertions(+), 3 deletions(-) diffs (66 lines): diff -r 54d69d910b38 -r 25845513c389 modules/org.openbravo.client.application/web/org.openbravo.client.application/js/form/formitem/ob-formitem-date.js --- a/modules/org.openbravo.client.application/web/org.openbravo.client.application/js/form/formitem/ob-formitem-date.js Wed Mar 07 10:39:18 2012 +0100 +++ b/modules/org.openbravo.client.application/web/org.openbravo.client.application/js/form/formitem/ob-formitem-date.js Tue Mar 13 10:08:31 2012 +0100 @@ -207,12 +207,23 @@ }, // update the value in update value as this is called from cellEditEnd in the - // grid + // grid, or after losing the focus on the form updateValue: function () { + if (this.grid && this.grid._preventDateParsing) { + return; + } this.expandValue(); this.Super('updateValue', arguments); + // 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 + // See issue 19694 (https://issues.openbravo.com/view.php?id=19694) + if (this.grid) { + this.grid.getEditValues(this.grid.getEditRow())[this.name] = this.getValue(); + } }, + blurValue: function () { return this.dateTextField.getElementValue(); }, diff -r 54d69d910b38 -r 25845513c389 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 Wed Mar 07 10:39:18 2012 +0100 +++ b/modules/org.openbravo.client.application/web/org.openbravo.client.application/js/form/ob-view-form.js Tue Mar 13 10:08:31 2012 +0100 @@ -1706,11 +1706,18 @@ // has only been edited half, only do this if we are in change // handling (to enable buttons etc.) updateFocusItemValue: function () { - var focusItem = this.getFocusSubItem(); + var ret, focusItem = this.getFocusSubItem(); if (this.inChangeHandling && focusItem && !focusItem.changeOnKeypress) { return; } - return this.Super('updateFocusItemValue', arguments); + if (this.grid) { + this.grid._preventDateParsing = true; + ret = this.Super('updateFocusItemValue', arguments); + delete this.grid._preventDateParsing; + } else { + ret = this.Super('updateFocusItemValue', arguments); + } + return ret; }, enableShortcuts: function () { diff -r 54d69d910b38 -r 25845513c389 modules/org.openbravo.client.application/web/org.openbravo.client.application/js/grid/ob-view-grid.js --- a/modules/org.openbravo.client.application/web/org.openbravo.client.application/js/grid/ob-view-grid.js Wed Mar 07 10:39:18 2012 +0100 +++ b/modules/org.openbravo.client.application/web/org.openbravo.client.application/js/grid/ob-view-grid.js Tue Mar 13 10:08:31 2012 +0100 @@ -2329,8 +2329,10 @@ // https://issues.openbravo.com/view.php?id=16611 storeUpdatedEditorValue: function (suppressChange, editCol) { this._storingUpdatedEditorValue = true; + this._preventDateParsing = true; this.Super('storeUpdatedEditorValue', arguments); delete this._storingUpdatedEditorValue; + delete this._preventDateParsing; }, // the form gets recreated many times, maintain the already read valuemap ------------------------------------------------------------------------------ Keep Your Developer Skills Current with LearnDevNow! The most comprehensive online learning library for Microsoft developers is just $99.99! Visual Studio, SharePoint, SQL - plus HTML5, CSS3, MVC3, Metro Style Apps, more. Free future releases when you subscribe now! http://p.sf.net/sfu/learndevnow-d2d _______________________________________________ Openbravo-commits mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/openbravo-commits
