details: https://code.openbravo.com/erp/devel/pi/rev/b878d4b1ee9a changeset: 25657:b878d4b1ee9a user: Naroa Iriarte <naroa.iriarte <at> openbravo.com> date: Mon Dec 29 11:13:30 2014 +0100 summary: Related with issue 28466: Autosave was executed when creating a new record.
The function "saveEditorReply" of the "ob-view-form.js" class has been changed in order to not having duplicate code. details: https://code.openbravo.com/erp/devel/pi/rev/8965d2c4301b changeset: 25658:8965d2c4301b user: Naroa Iriarte <naroa.iriarte <at> openbravo.com> date: Wed Dec 24 16:42:09 2014 +0100 summary: Fixed issue 28466: Autosave was executed when creating a new record. When a window only has one subtab, and that subtab has a display logic, just after clicking the proper button to create a new record in the header tab (both in grid and in form mode), the autosave is executed. This happens only the first time that a record is created. The problem was in the "updateSubtabVisibility" function of the "ob-standard-view.js". The problem was that at first, in the function, there was a logic that was not taking into account the fact that if it was the record selected in the header tab has not been saved yet, its subtabs are empty, and it is not neccesary to refresh them. Before the fix it tried to refresh the subtabs, which resulted in a call to autosave. For fixing it a new condition has been added to the "updateSubtabVisibility" function. With this new condition now, the call to the autosave is avoided in the case of the new record. A new function called "isEditingNewRecord" has been created too. This function returns true if a new record is being edited in the view. diffstat: modules/org.openbravo.client.application/web/org.openbravo.client.application/js/form/ob-view-form.js | 5 ++--- modules/org.openbravo.client.application/web/org.openbravo.client.application/js/main/ob-standard-view.js | 8 +++++++- 2 files changed, 9 insertions(+), 4 deletions(-) diffs (40 lines): diff -r e96a15e0c289 -r 8965d2c4301b 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 Fri Jan 02 13:01:06 2015 +0100 +++ b/modules/org.openbravo.client.application/web/org.openbravo.client.application/js/form/ob-view-form.js Wed Dec 24 16:42:09 2014 +0100 @@ -1605,9 +1605,8 @@ // always let the saveRow callback handle the error saveEditorReply: function (response, data, request) { - var form, isNewRecord; - form = request.editor.view.isShowingForm ? request.editor.view.viewForm : request.editor.view.viewGrid.getEditForm(); - isNewRecord = form === null ? false : form.isNew; + var isNewRecord; + isNewRecord = request.editor.view.isEditingNewRecord(); if (request.editor && request.editor.view && isNewRecord) { delete request.editor.view._savingNewRecord; } diff -r e96a15e0c289 -r 8965d2c4301b modules/org.openbravo.client.application/web/org.openbravo.client.application/js/main/ob-standard-view.js --- a/modules/org.openbravo.client.application/web/org.openbravo.client.application/js/main/ob-standard-view.js Fri Jan 02 13:01:06 2015 +0100 +++ b/modules/org.openbravo.client.application/web/org.openbravo.client.application/js/main/ob-standard-view.js Wed Dec 24 16:42:09 2014 +0100 @@ -1700,7 +1700,7 @@ } else { if (this.childTabSet.visibility === 'hidden') { this.childTabSet.show(); - if (tabViewPane.showTabIf && !tabViewPane.data && !tabViewPane.refreshingData && tabViewPane.isVisible()) { + if (tabViewPane.showTabIf && !tabViewPane.data && !tabViewPane.refreshingData && tabViewPane.isVisible() && !this.isEditingNewRecord()) { // If the child tab does not have data yet, refresh it tabViewPane.refreshingData = true; tabViewPane.refresh(); @@ -1736,6 +1736,12 @@ } }, + //This function returns true if it is a new record and it is being edited + isEditingNewRecord: function () { + var form = this.isShowingForm ? this.viewForm : this.viewGrid.getEditForm(); + return form === null ? false : form.isNew; + }, + // Adds to contextInfo the session attributes of the childView, // unless the session attribute is an auxiliary input of its parent tab addPreferenceValues: function (contextInfo, childView) { ------------------------------------------------------------------------------ Dive into the World of Parallel Programming! The Go Parallel Website, sponsored by Intel and developed in partnership with Slashdot Media, is your hub for all things parallel software development, from weekly thought leadership blogs to news, videos, case studies, tutorials and more. Take a look and join the conversation now. http://goparallel.sourceforge.net _______________________________________________ Openbravo-commits mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/openbravo-commits
