details:   /erp/devel/pi/rev/8d45cbbd0970
changeset: 9666:8d45cbbd0970
user:      Martin Taal <martin.taal <at> openbravo.com>
date:      Mon Jan 10 08:46:46 2011 +0100
summary:   Solved error in next button action

details:   /erp/devel/pi/rev/fbde6bf59f23
changeset: 9667:fbde6bf59f23
user:      Martin Taal <martin.taal <at> openbravo.com>
date:      Mon Jan 10 08:51:02 2011 +0100
summary:   Solved issues with next/prev and with autosave and focus

diffstat:

 
modules/org.openbravo.client.application/web/org.openbravo.client.application/js/ob-standard-view.js
 |   8 +-
 
modules/org.openbravo.client.application/web/org.openbravo.client.application/js/ob-statusbar.js
     |   2 +-
 
modules/org.openbravo.client.application/web/org.openbravo.client.application/js/ob-view-form.js
     |  32 +++++++--
 3 files changed, 30 insertions(+), 12 deletions(-)

diffs (145 lines):

diff -r 94990ca49351 -r fbde6bf59f23 
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
      Mon Jan 10 08:29:17 2011 +0100
+++ 
b/modules/org.openbravo.client.application/web/org.openbravo.client.application/js/ob-standard-view.js
      Mon Jan 10 08:51:02 2011 +0100
@@ -99,8 +99,10 @@
   
   // is called from the main app tabset
   tabDeselected: function(tabNum, tabPane, ID, tab, newTab){
-    if (this.activeView) {
-      this.activeView.viewForm.autoSave();
+    // note: explicitly checking for grid visibility as the form
+    // may already be hidden
+    if (this.activeView && !this.activeView.viewGrid.isVisible()) {
+      this.activeView.viewForm.autoSave(null, true);
     }
   },
   
@@ -841,7 +843,7 @@
     } else {
       newRowNum = rowNum - 1;
     }
-    newRecord = this.view.viewGrid.getRecord(newRowNum);
+    newRecord = this.viewGrid.getRecord(newRowNum);
     if (!newRecord) {
       return;
     }
diff -r 94990ca49351 -r fbde6bf59f23 
modules/org.openbravo.client.application/web/org.openbravo.client.application/js/ob-statusbar.js
--- 
a/modules/org.openbravo.client.application/web/org.openbravo.client.application/js/ob-statusbar.js
  Mon Jan 10 08:29:17 2011 +0100
+++ 
b/modules/org.openbravo.client.application/web/org.openbravo.client.application/js/ob-statusbar.js
  Mon Jan 10 08:51:02 2011 +0100
@@ -60,7 +60,7 @@
     if (this.buttonType === 'previous') {
       this.view.editNextPreviousRecord(false);
     } else if (this.buttonType === 'next') {
-      this.view.editNextPreviousRecord(next);
+      this.view.editNextPreviousRecord(true);
     } else if (this.buttonType === 'close') {
       this.view.switchFormGridVisibility();
       this.view.messageBar.hide();
diff -r 94990ca49351 -r fbde6bf59f23 
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
  Mon Jan 10 08:29:17 2011 +0100
+++ 
b/modules/org.openbravo.client.application/web/org.openbravo.client.application/js/ob-view-form.js
  Mon Jan 10 08:51:02 2011 +0100
@@ -186,6 +186,8 @@
     
     
OB.RemoteCallManager.call('org.openbravo.client.application.window.FormInitializationComponent',
 {}, requestParams, function(response, data, request){
       me.processFICReturn(response, data, request);
+      // remember the initial values 
+      me.rememberValues();
     });
   },
   
@@ -349,6 +351,7 @@
   },
   
   undo: function(){
+    this.view.messageBar.hide();
     this.view.toolBar.setLeftMemberDisabled(isc.OBToolbar.TYPE_SAVE, true);
     this.view.toolBar.setLeftMemberDisabled(isc.OBToolbar.TYPE_UNDO, true);
     this.resetValues();
@@ -356,13 +359,16 @@
   },
   
   // action defines the action to call when the save succeeds
-  autoSave: function(action) {
+  // forceDialogOnFailure: if true then even if the form is visible
+  // still a dialog is shown, this becomes sometimes autosave is done
+  // before actually the form gets hidden
+  autoSave: function(action, forceDialogOnFailure) {
     
     if (!this.view.standardWindow.isAutoSave() && this.hasChanged && action) {
       this.autoSaveConfirmAction(action);
     } else if (this.view.standardWindow.isAutoSave() && this.hasChanged && 
!this.inAutoSave) {
       this.inAutoSave = true;
-      this.saveRow(action, true);
+      this.saveRow(action, true, forceDialogOnFailure);
     } else if (action) {
       action.method.call(action.target, action.parameters);
     }
@@ -370,15 +376,20 @@
   },
     
   autoSaveConfirmAction: function(action) {
+    var form = this;
     var callback = function(ok) {
       if (ok) {
         action.method.apply(action.target, action.parameters);
-      } 
+      } else {
+        // and focus to the first error field
+        form.setFocusInErrorField(true);
+        form.focus();
+      }
     };
     isc.ask(OB.I18N.getLabel('OBUIAPP_AutoSaveNotPossibleExecuteAction'), 
callback);
   },
 
-  saveRow: function(action, autoSave){
+  saveRow: function(action, autoSave, forceDialogOnFailure){
     var i, length, flds, form = this;
     
     // disable the save
@@ -437,7 +448,7 @@
         // if there is an action, ask for confirmation
         if (action) {
           this.autoSaveConfirmAction(action);
-        } else if (!view.isVisible()) {
+        } else if (!view.isVisible() || forceDialogOnFailure) {
           isc.warn(OB.I18N.getLabel('OBUIAPP_AutoSaveError', [view.tabTitle]));
         }
       }
@@ -449,7 +460,7 @@
     // done by calling showErrors without the third parameter to true
     if (!this.validate()) {
       this.handleFieldErrors(null, autoSave);
-      if (autoSave && !form.view.isVisible()) {
+      if (autoSave && !form.view.isVisible() || forceDialogOnFailure) {
         isc.warn(OB.I18N.getLabel('OBUIAPP_AutoSaveError', 
[this.view.tabTitle]));
       } else if (action) {
         this.autoSaveConfirmAction(action);
@@ -484,6 +495,10 @@
     this.view.messageBar.setMessage(isc.OBMessageBar.TYPE_ERROR, null, 
OB.I18N.getLabel('OBUIAPP_ErrorInFields'));
     
     // and focus to the first error field
+    this.setFocusInErrorField(autoSave);
+  },
+  
+  setFocusInErrorField: function(autoSave) {
     flds = this.getFields();
     length = flds.length;
     for (i = 0; i < length; i++) {
@@ -491,13 +506,14 @@
         if (autoSave) {
           // otherwise the focus results in infinite cycles
           // with views getting activated all the time
-          this.view.lastFocusedItem = flds[i];          
+          this.view.lastFocusedItem = flds[i];
         } else {
           flds[i].focusInItem();
         }
-        break;
+        return;
       }
     }
+    this.resetFocusItem();
   },
   
   // overridden to show the error when hovering over items

------------------------------------------------------------------------------
Gaining the trust of online customers is vital for the success of any company
that requires sensitive data to be transmitted over the Web.   Learn how to 
best implement a security strategy that keeps consumers' information secure 
and instills the confidence they need to proceed with transactions.
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