details:   /erp/devel/pi/rev/aaa5eb1c735e
changeset: 9845:aaa5eb1c735e
user:      Martin Taal <martin.taal <at> openbravo.com>
date:      Mon Jan 17 00:07:47 2011 +0100
summary:   Popup now also shown when save fails without showing error field

diffstat:

 
modules/org.openbravo.client.application/web/org.openbravo.client.application/js/ob-standard-view.js
 |   5 +
 
modules/org.openbravo.client.application/web/org.openbravo.client.application/js/ob-view-form.js
     |  42 +++++++--
 2 files changed, 37 insertions(+), 10 deletions(-)

diffs (88 lines):

diff -r eb8bec559d6b -r aaa5eb1c735e 
modules/org.openbravo.client.application/web/org.openbravo.client.application/js/ob-standard-view.js
--- 
a/modules/org.openbravo.client.application/web/org.openbravo.client.application/js/ob-standard-view.js
      Sun Jan 16 23:16:58 2011 +0100
+++ 
b/modules/org.openbravo.client.application/web/org.openbravo.client.application/js/ob-standard-view.js
      Mon Jan 17 00:07:47 2011 +0100
@@ -279,6 +279,11 @@
         this.Super('performDSOperation', arguments);
       },
       
+      fireResponseCallbacks: function() {
+        var ret = this.Super('fireResponseCallbacks', arguments);
+        return ret;
+      },
+      
       transformResponse: function(dsResponse, dsRequest, jsonData){
         if (dsRequest.clientContext && 
dsRequest.clientContext.progressIndicatorSelectedRecord) {
           
this.hideProgress(dsRequest.clientContext.progressIndicatorSelectedRecord);
diff -r eb8bec559d6b -r aaa5eb1c735e 
modules/org.openbravo.client.application/web/org.openbravo.client.application/js/ob-view-form.js
--- 
a/modules/org.openbravo.client.application/web/org.openbravo.client.application/js/ob-view-form.js
  Sun Jan 16 23:16:58 2011 +0100
+++ 
b/modules/org.openbravo.client.application/web/org.openbravo.client.application/js/ob-view-form.js
  Mon Jan 17 00:07:47 2011 +0100
@@ -425,6 +425,11 @@
     isc.ask(OB.I18N.getLabel('OBUIAPP_AutoSaveNotPossibleExecuteAction'), 
callback);
   },
   
+  // always let the saveRow callback handle the error
+  saveEditorReply : function (response, data, request) {
+    return true;
+  },
+  
   saveRow: function(action, autoSave, forceDialogOnFailure){
     var i, length, flds, form = this;
     
@@ -515,8 +520,17 @@
     if (errors) {
       this.setErrors(errors, true);
     }
+    var msg = OB.I18N.getLabel('OBUIAPP_ErrorInFields');
+    var errorFld = this.getFirstErrorItem();
+    // special case
+    // if there is only an error on the id and no error on any field
+    // display that message then
+    if (errors && errors.id && !errorFld) {
+      msg = errors.id.errorMessage;
+    }
+       
     // set the error message
-    this.view.messageBar.setMessage(isc.OBMessageBar.TYPE_ERROR, null, 
OB.I18N.getLabel('OBUIAPP_ErrorInFields'));
+    this.view.messageBar.setMessage(isc.OBMessageBar.TYPE_ERROR, null, msg);
     
     // and focus to the first error field
     this.setFocusInErrorField(autoSave || this.inAutoSave);
@@ -524,21 +538,29 @@
   },
   
   setFocusInErrorField: function(autoSave){
+    var errorFld = this.getFirstErrorItem();
+    if (errorFld) {
+      if (autoSave) {
+        // otherwise the focus results in infinite cycles
+        // with views getting activated all the time
+        this.view.lastFocusedItem = errorFld;
+      } else {
+        errorFld.focusInItem();
+      }
+      return;
+    }
+    this.resetFocusItem();
+  },
+  
+  getFirstErrorItem: function() {
     flds = this.getFields();
     length = flds.length;
     for (i = 0; i < length; i++) {
       if (flds[i].getErrors()) {
-        if (autoSave) {
-          // otherwise the focus results in infinite cycles
-          // with views getting activated all the time
-          this.view.lastFocusedItem = flds[i];
-        } else {
-          flds[i].focusInItem();
-        }
-        return;
+        return flds[i];
       }
     }
-    this.resetFocusItem();
+    return null;
   },
   
   // overridden to show the error when hovering over items

------------------------------------------------------------------------------
Protect Your Site and Customers from Malware Attacks
Learn about various malware tactics and how to avoid them. Understand 
malware threats, the impact they can have on your business, and how you 
can protect your company and customers by using code signing.
http://p.sf.net/sfu/oracle-sfdevnl
_______________________________________________
Openbravo-commits mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/openbravo-commits

Reply via email to