details:   /erp/devel/pi/rev/c47a172f66bd
changeset: 9873:c47a172f66bd
user:      Martin Taal <martin.taal <at> openbravo.com>
date:      Mon Jan 17 17:12:37 2011 +0100
summary:   Autosave, improved performance of row selection

diffstat:

 
modules/org.openbravo.client.application/web/org.openbravo.client.application/js/ob-standard-view.js
             |  133 ++++-----
 
modules/org.openbravo.client.application/web/org.openbravo.client.application/js/ob-standard-window.js
           |   11 +-
 
modules/org.openbravo.client.application/web/org.openbravo.client.application/js/ob-view-form.js
                 |   73 ++++-
 
modules/org.openbravo.client.application/web/org.openbravo.client.application/js/ob-view-grid.js
                 |   74 ++++-
 
modules/org.openbravo.userinterface.smartclient/web/org.openbravo.userinterface.smartclient/js/ob-smartclient.js
 |    5 +-
 5 files changed, 188 insertions(+), 108 deletions(-)

diffs (truncated from 621 to 300 lines):

diff -r 23abfc8cd60e -r c47a172f66bd 
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 17 17:09:12 2011 +0100
+++ 
b/modules/org.openbravo.client.application/web/org.openbravo.client.application/js/ob-standard-view.js
      Mon Jan 17 17:12:37 2011 +0100
@@ -277,7 +277,7 @@
           _noActiveFilter: true
         };
         isc.addProperties(newRequestProperties.params, additionalPara);
-        this.Super('performDSOperation', arguments);
+        this.Super('performDSOperation', [operationType, data, callback, 
newRequestProperties]);
       },
       
       transformResponse: function(dsResponse, dsRequest, jsonData){
@@ -586,10 +586,6 @@
     if (this.refreshContents && !ignoreRefreshContents) {
       return;
     }
-    // don't change when saving data 
-    if (this.preventActiveViewChange) {
-      return;
-    }
     this.standardWindow.setActiveView(this);
   },
   
@@ -606,30 +602,67 @@
       // to another tab, this handles the case that the grid
       // is shown but the underlying form has errors
       if (this.isShowingForm) {
-        this.viewForm.autoSave();
+        this.viewForm.autoSave(null, true);
       }
     }
     this.setTabButtonState(state);
   },
   
-  doRefreshContents: function(){
-    // refresh when shown
-    if (this.parentTabSet && this.parentTabSet.state === 
isc.OBStandardView.STATE_MIN) {
+  doRefreshContents: function(doRefreshWhenVisible){
+
+    // update this one at least before bailing out
+    this.updateTabTitle();    
+    
+    if (!this.isViewVisible()) {
+      this.refreshContents = doRefreshWhenVisible;
       return;
     }
-    if (!this.refreshContents) {
+    
+    if (!this.refreshContents && !doRefreshWhenVisible) {
       return;
     }
-    var me = this;
-    this.viewForm.clearErrors();
-    this.viewForm.clearValues();
+    // can be used by others to see that we are refreshing content
+    this.refreshContents = true;
+
+    // clear all our selections..
+    this.viewGrid.deselectAllRecords();
     
+    // hide the messagebar
+    this.messageBar.hide();
+
+    // allow default edit mode again
+    this.allowDefaultEditMode = true;
+    
+    if (this.viewForm) {
+      this.viewForm.resetForm();
+    }
+        
     if (this.shouldOpenDefaultEditMode()) {
       this.openDefaultEditView();
     } else if (this.isShowingForm) {
       this.switchFormGridVisibility();
     }
     this.viewGrid.refreshContents();
+
+    // no parent disable new
+    if (!this.getParentId()) {
+      this.toolBar.setLeftMemberDisabled(isc.OBToolbar.TYPE_NEW, true);
+    } else {
+      this.toolBar.setLeftMemberDisabled(isc.OBToolbar.TYPE_NEW, 
this.readOnly);
+    }
+    
+    // if not visible or the parent also needs to be refreshed
+    // enable the following code if we don't automatically select the first
+    // record
+    if (this.childTabSet) {
+      for (var i = 0; i < this.childTabSet.tabs.length; i++) {
+        tabViewPane = this.childTabSet.tabs[i].pane;
+        // force a refresh, only the visible ones will really 
+        // be refreshed
+        tabViewPane.doRefreshContents(true);
+      }
+    }
+    // set this at false at the end
     this.refreshContents = false;
   },
   
@@ -723,7 +756,7 @@
   // Opens the edit form and selects the record in the grid, will refresh
   // child views also
   editRecord: function(record, preventFocus){
-  
+    
     this.messageBar.hide();
     
     if (!this.isShowingForm) {
@@ -738,7 +771,9 @@
       this.viewForm.editRecord(record, preventFocus);
     }
     
-    isc.Page.setEvent(isc.EH.IDLE, this.viewForm, isc.Page.FIRE_ONCE, 'focus');
+    if (!preventFocus) {
+      isc.Page.setEvent(isc.EH.IDLE, this.viewForm, isc.Page.FIRE_ONCE, 
'focus');
+    }
   },
   
   setMaximizeRestoreButtonState: function(){
@@ -832,9 +867,8 @@
           this.parentTabSet.selectTab(this.tab);
         } else {
           // make sure that the content gets refreshed
-          this.refreshContents = true;
           // refresh and open a child view when all is done
-          this.doRefreshContents();
+          this.doRefreshContents(true);
         }
         return true;
       }
@@ -894,7 +928,7 @@
     if (this.childTabSet) {
       for (var i = 0; i < this.childTabSet.tabs.length; i++) {
         tabViewPane = this.childTabSet.tabs[i].pane;
-        tabViewPane.parentRecordSelected();
+        tabViewPane.doRefreshContents(true);
       }
     }
     // and recompute the count:
@@ -914,61 +948,7 @@
     this.lastRecordSelectedCount = this.viewGrid.getSelectedRecords().length;
     this.lastRecordSelected = this.viewGrid.getSelectedRecord(); 
   },
-  
-  // ** {{{ parentRecordSelected }}} **
-  // Is called when a selection change occurs in the parent.
-  parentRecordSelected: function(){
-  
-    // clear all our selections..
-    this.viewGrid.deselectAllRecords();
     
-    // hide the messagebar
-    this.messageBar.hide();
-    
-    // allow default edit mode again
-    this.allowDefaultEditMode = true;
-    
-    if (this.viewForm) {
-      this.viewForm.resetForm();
-    }
-    
-    // no parent disable new
-    if (!this.getParentId()) {
-      this.toolBar.setLeftMemberDisabled(isc.OBToolbar.TYPE_NEW, true);
-    } else {
-      this.toolBar.setLeftMemberDisabled(isc.OBToolbar.TYPE_NEW, 
this.readOnly);
-    }
-    
-    // switch back to the grid
-    if (this.isShowingForm) {
-      this.switchFormGridVisibility();
-    }
-    
-    // clear the count from the tabtitle, will be recomputed
-    this.updateTabTitle();
-    
-    // if not visible or the parent also needs to be refreshed
-    if (!this.isViewVisible() ||
-    (this.parentView && this.parentView.refreshContents)) {
-      isc.Log.logDebug('ParentRecordSelected: View not visible ' + 
this.tabTitle, 'OB');
-      // refresh when the view get's shown
-      this.refreshContents = true;
-    } else {
-      isc.Log.logDebug('ParentRecordSelected: View visible ' + this.tabTitle, 
'OB');
-      if (this.viewGrid) {
-        this.viewGrid.refreshContents();
-      }
-    }
-    // enable the following code if we don't automatically select the first
-    // record
-    if (this.childTabSet) {
-      for (var i = 0; i < this.childTabSet.tabs.length; i++) {
-        tabViewPane = this.childTabSet.tabs[i].pane;
-        tabViewPane.parentRecordSelected();
-      }
-    }
-  },
-  
   getParentId: function(){
     if (!this.parentView || !this.parentView.viewGrid.getSelectedRecord()) {
       return null;
@@ -977,6 +957,9 @@
   },
   
   updateChildCount: function(){
+    if (true) {
+      return;
+    }
     if (!this.childTabSet) {
       return;
     }
@@ -1070,8 +1053,10 @@
   },
   
   isViewVisible: function(){
-    return this.parentTabSet.getSelectedTabNumber() ===
-    this.parentTabSet.getTabNumber(this.tab);
+    // note this.tab.isVisible is done as the tab is visible earlier than
+    // the pane
+    return (!this.tab || this.tab.isVisible()) && 
this.parentTabSet.getSelectedTabNumber() ===
+              this.parentTabSet.getTabNumber(this.tab);
   },
   
   // ++++++++++++++++++++ Button Actions ++++++++++++++++++++++++++
diff -r 23abfc8cd60e -r c47a172f66bd 
modules/org.openbravo.client.application/web/org.openbravo.client.application/js/ob-standard-window.js
--- 
a/modules/org.openbravo.client.application/web/org.openbravo.client.application/js/ob-standard-window.js
    Mon Jan 17 17:09:12 2011 +0100
+++ 
b/modules/org.openbravo.client.application/web/org.openbravo.client.application/js/ob-standard-window.js
    Mon Jan 17 17:12:37 2011 +0100
@@ -149,14 +149,17 @@
     if (!this.isDrawn()) {
       return;
     }
-    var currentActiveView = this.activeView;
     if (this.activeView === view) {
       return;
     }
-    if (currentActiveView) {
-      currentActiveView.setActiveViewVisualState(false);
+    
+    var currentView = this.activeView;
+    // note the new activeView must be set before disabling
+    // the other one
+    this.activeView = view;
+    if (currentView) {
+      currentView.setActiveViewVisualState(false);
     }
-    this.activeView = view;
     view.setActiveViewVisualState(true);
   },
   
diff -r 23abfc8cd60e -r c47a172f66bd 
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 17 17:09:12 2011 +0100
+++ 
b/modules/org.openbravo.client.application/web/org.openbravo.client.application/js/ob-view-form.js
  Mon Jan 17 17:12:37 2011 +0100
@@ -2,7 +2,7 @@
  *************************************************************************
  * The contents of this file are subject to the Openbravo  Public  License
  * Version  1.1  (the  "License"),  being   the  Mozilla   Public  License
- * Version 1.1  with a permitted attribution clause; you may not  use this
+ * Version 1.1  with a permitted attribution clause; you may not  use. this
  * file except in compliance with the License. You  may  obtain  a copy of
  * the License at http://www.openbravo.com/legal/license.html
  * Software distributed under the License  is  distributed  on  an "AS IS"
@@ -71,14 +71,16 @@
     this.view.toolBar.setLeftMemberDisabled(isc.OBToolbar.TYPE_DELETE, 
this.view.readOnly || false);
     this.view.toolBar.setLeftMemberDisabled(isc.OBToolbar.TYPE_REFRESH, 
this.view.readOnly || false);
     
-    this.resetFocusItem();
     var ret = this.Super('editRecord', arguments);
     this.clearErrors();
     this.retrieveInitialValues(false);
     
     this.setNewState(false);
     this.view.messageBar.hide();
-    
+
+    this.resetFocusItem();
+    this.focus();
+        
     return ret;
   },
   
@@ -95,12 +97,13 @@
     this.view.toolBar.setLeftMemberDisabled(isc.OBToolbar.TYPE_UNDO, true);
     this.view.toolBar.setLeftMemberDisabled(isc.OBToolbar.TYPE_DELETE, true);
     
-    this.resetFocusItem();
     var ret = this.Super('editNewRecord', arguments);
     this.clearErrors();
     this.retrieveInitialValues(true);
     
     this.setNewState(true);
+    this.resetFocusItem();
+    this.focus();
     
     this.view.messageBar.hide();
     
@@ -371,7 +374,8 @@
     if (this.getFocusItem()) {
       this.getFocusItem().focusInItem();
     }
-    return this.Super("focus", arguments);

------------------------------------------------------------------------------
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