details:   /erp/devel/pi/rev/06dff9ac98cb
changeset: 12467:06dff9ac98cb
user:      Iván Perdomo <ivan.perdomo <at> openbravo.com>
date:      Thu May 26 13:21:20 2011 +0200
summary:   Fixes issue 17336 and fixes Issue 17265: Validate the form before 
switching view

diffstat:

 
modules/org.openbravo.client.application/web/org.openbravo.client.application/js/form/ob-statusbar.js
  |   3 +
 
modules/org.openbravo.client.application/web/org.openbravo.client.application/js/form/ob-view-form.js
  |  20 +++++++---
 
modules/org.openbravo.client.application/web/org.openbravo.client.application/js/toolbar/ob-toolbar.js
 |   5 ++-
 3 files changed, 21 insertions(+), 7 deletions(-)

diffs (65 lines):

diff -r 2356fbef64a6 -r 06dff9ac98cb 
modules/org.openbravo.client.application/web/org.openbravo.client.application/js/form/ob-statusbar.js
--- 
a/modules/org.openbravo.client.application/web/org.openbravo.client.application/js/form/ob-statusbar.js
     Thu May 26 12:37:52 2011 +0200
+++ 
b/modules/org.openbravo.client.application/web/org.openbravo.client.application/js/form/ob-statusbar.js
     Thu May 26 13:21:20 2011 +0200
@@ -84,6 +84,9 @@
     } else if (this.buttonType === 'next') {
       this.view.editNextPreviousRecord(true);
     } else if (this.buttonType === 'close') {
+      if(!this.view.viewForm.validateForm()) {
+        return;
+      }
       this.view.switchFormGridVisibility();
       this.view.messageBar.hide();
     } else if (this.buttonType === 'maximizeRestore') {
diff -r 2356fbef64a6 -r 06dff9ac98cb 
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
     Thu May 26 12:37:52 2011 +0200
+++ 
b/modules/org.openbravo.client.application/web/org.openbravo.client.application/js/form/ob-view-form.js
     Thu May 26 13:21:20 2011 +0200
@@ -1110,11 +1110,7 @@
     
     // note validate will also set the formfocus, this is 
     // done by calling showErrors without the third parameter to true
-    if (!this.validate()) {
-      this.handleFieldErrors(null);
-      form.view.standardWindow.autoSaveDone(form.view, false);
-      form.isSaving = false;
-      form.view.toolBar.updateButtonState(true);
+    if (!form.validateForm()) {
       return;
     }
     
@@ -1128,7 +1124,19 @@
       }, true);
     }
   },
-  
+
+  validateForm: function() {
+    var form = this;
+    if (!form.validate()) {
+      form.handleFieldErrors(null);
+      form.view.standardWindow.autoSaveDone(form.view, false);
+      form.isSaving = false;
+      form.view.toolBar.updateButtonState(true);
+      return false;
+    }
+    return true;
+  },
+
   focusInNextItem: function(currentItem) {
     var flds = (this.grid ? this.grid.getFields() : this.getFields());
     var chooseNextItem, i, nextItem, length = flds.length;
diff -r 2356fbef64a6 -r 06dff9ac98cb 
modules/org.openbravo.client.application/web/org.openbravo.client.application/js/toolbar/ob-toolbar.js
--- 
a/modules/org.openbravo.client.application/web/org.openbravo.client.application/js/toolbar/ob-toolbar.js
    Thu May 26 12:37:52 2011 +0200
+++ 
b/modules/org.openbravo.client.application/web/org.openbravo.client.application/js/toolbar/ob-toolbar.js
    Thu May 26 13:21:20 2011 +0200
@@ -67,7 +67,10 @@
       this.view.standardWindow.doActionAfterAutoSave(actionObject, true, 
true);      
     },
     
-    saveAndClose: function(){
+    saveAndClose: function() {
+      if(!this.view.viewForm.validateForm()) {
+        return;
+      }
       this.view.switchFormGridVisibility();
       this.view.messageBar.hide();
     },

------------------------------------------------------------------------------
vRanger cuts backup time in half-while increasing security.
With the market-leading solution for virtual backup and recovery, 
you get blazing-fast, flexible, and affordable data protection.
Download your free trial now. 
http://p.sf.net/sfu/quest-d2dcopy1
_______________________________________________
Openbravo-commits mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/openbravo-commits

Reply via email to