details: /erp/devel/pi/rev/3e2d582fe956
changeset: 10763:3e2d582fe956
user: Martin Taal <martin.taal <at> openbravo.com>
date: Fri Feb 18 08:18:39 2011 +0100
summary: Several changes to prevent many http requests
diffstat:
modules/org.openbravo.client.application/web/org.openbravo.client.application/js/ob-grid.js
| 1 +
modules/org.openbravo.client.application/web/org.openbravo.client.application/js/ob-standard-view.js
| 51 +++---
modules/org.openbravo.client.application/web/org.openbravo.client.application/js/ob-standard-window.js
| 2 +-
modules/org.openbravo.client.application/web/org.openbravo.client.application/js/ob-toolbar.js
| 10 +-
modules/org.openbravo.client.application/web/org.openbravo.client.application/js/ob-view-form.js
| 80 ++++------
modules/org.openbravo.client.application/web/org.openbravo.client.application/js/ob-view-grid.js
| 31 ++-
6 files changed, 84 insertions(+), 91 deletions(-)
diffs (truncated from 487 to 300 lines):
diff -r b645d3ca3d0c -r 3e2d582fe956
modules/org.openbravo.client.application/web/org.openbravo.client.application/js/ob-grid.js
---
a/modules/org.openbravo.client.application/web/org.openbravo.client.application/js/ob-grid.js
Fri Feb 18 07:47:27 2011 +0100
+++
b/modules/org.openbravo.client.application/web/org.openbravo.client.application/js/ob-grid.js
Fri Feb 18 08:18:39 2011 +0100
@@ -28,6 +28,7 @@
recordComponentPosition: 'within',
poolComponentsPerColumn: true,
showRecordComponents: true,
+ canSelectText: true,
createRecordComponent: function(record, colNum){
var field = this.getField(colNum), rowNum = this.getRecordIndex(record);
diff -r b645d3ca3d0c -r 3e2d582fe956
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
Fri Feb 18 07:47:27 2011 +0100
+++
b/modules/org.openbravo.client.application/web/org.openbravo.client.application/js/ob-standard-view.js
Fri Feb 18 08:18:39 2011 +0100
@@ -141,6 +141,7 @@
// set if one record has been selected
lastRecordSelected: null,
lastRecordSelectedCount: 0,
+ fireOnPauseDelay: 200,
// ** {{{ refreshContents }}} **
// Should the contents listgrid/forms be refreshed when the tab
@@ -214,7 +215,7 @@
var ret = this.Super('initWidget', arguments);
- this.toolBar.updateButtonState();
+ this.toolBar.updateButtonState(true);
return ret;
},
@@ -505,8 +506,8 @@
}
if (this.isShowingForm && this.viewForm && this.viewForm.getFocusItem()) {
- object = this.viewForm;
- functionName = 'focus';
+ object = this.viewForm.getFocusItem();
+ functionName = 'focusInItem';
} else if (this.isEditingGrid && this.viewGrid.getEditForm() &&
this.viewGrid.getEditForm().getFocusItem()) {
object = this.viewGrid.getEditForm();
functionName = 'focus';
@@ -574,21 +575,6 @@
this.setTabButtonState(state);
},
- // do refresh contents with a small delay to not refresh child views
- // to quick when walking through a grid with arrow keys
- // only do this if this view is not in a dirty state
- doPausedRefreshContents: function(doRefreshWhenVisible) {
- if (this.isShowingForm && this.viewForm.hasChanged) {
- this.doRefreshContents(doRefreshWhenVisible);
- } else {
- var me = this, callback = function () {
- me.doRefreshContents(doRefreshWhenVisible);
- };
- // wait 2 times longer than the fire on pause delay default
- this.fireOnPause('doRefreshContents_' + this.ID, callback,
this.fireOnPauseDelay * 2);
- }
- },
-
doRefreshContents: function(doRefreshWhenVisible){
// update this one at least before bailing out
@@ -925,10 +911,19 @@
if (!this.hasSelectionStateChanged()) {
return;
}
+ var me = this, callback = function () {
+ me.delayedRecordSelected();
+ };
+ // wait 2 times longer than the fire on pause delay default
+ this.fireOnPause('delayedRecordSelected_' + this.ID, callback,
this.fireOnPauseDelay * 2);
+ },
+
+ // function is called with a small delay to handle the case that a user
+ // navigates quickly over a grid
+ delayedRecordSelected: function() {
this.updateLastSelectedState();
- this.updateTabTitle();
-
- this.toolBar.updateButtonState();
+ this.updateTabTitle();
+ this.toolBar.updateButtonState(this.isEditingGrid || this.isShowingForm);
var tabViewPane = null;
@@ -936,12 +931,11 @@
if (this.childTabSet) {
for (var i = 0; i < this.childTabSet.tabs.length; i++) {
tabViewPane = this.childTabSet.tabs[i].pane;
- tabViewPane.doPausedRefreshContents(true);
+ tabViewPane.doRefreshContents(true);
}
}
// and recompute the count:
this.updateChildCount();
- this.updateTabTitle();
},
hasSelectionStateChanged: function() {
@@ -976,6 +970,7 @@
},
updateChildCount: function(){
+ // note disabled for now
if (true) {
return;
}
@@ -1129,10 +1124,12 @@
},
isViewVisible: function(){
+ // this prevents data requests for minimized tabs
+ return this.isVisible();
// note this.tab.isVisible is done as the tab is visible earlier than
// the pane
- return (!this.tab || this.tab.isVisible()) && (!this.parentTabSet ||
this.parentTabSet.getSelectedTabNumber() ===
- this.parentTabSet.getTabNumber(this.tab));
+// return (!this.tab || this.tab.isVisible()) && (!this.parentTabSet ||
this.parentTabSet.getSelectedTabNumber() ===
+// this.parentTabSet.getTabNumber(this.tab));
},
// ++++++++++++++++++++ Button Actions ++++++++++++++++++++++++++
@@ -1567,6 +1564,10 @@
},
setContextInfo: function(sessionProperties, callbackFunction){
+ // no need to set the context in this case
+ if (this.isEditingGrid || this.isShowingForm) {
+ return;
+ }
if (!sessionProperties) {
sessionProperties = this.getContextInfo(true, true);
}
diff -r b645d3ca3d0c -r 3e2d582fe956
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
Fri Feb 18 07:47:27 2011 +0100
+++
b/modules/org.openbravo.client.application/web/org.openbravo.client.application/js/ob-standard-window.js
Fri Feb 18 08:18:39 2011 +0100
@@ -123,7 +123,7 @@
this.views[i].setReadOnly(data.uiPattern[this.views[i].tabId] ===
isc.OBStandardView.UI_PATTERN_READONLY);
this.views[i].setSingleRecord(data.uiPattern[this.views[i].tabId] ===
isc.OBStandardView.UI_PATTERN_SINGLERECORD);
- this.views[i].toolBar.updateButtonState();
+ this.views[i].toolBar.updateButtonState(true);
}
},
diff -r b645d3ca3d0c -r 3e2d582fe956
modules/org.openbravo.client.application/web/org.openbravo.client.application/js/ob-toolbar.js
---
a/modules/org.openbravo.client.application/web/org.openbravo.client.application/js/ob-toolbar.js
Fri Feb 18 07:47:27 2011 +0100
+++
b/modules/org.openbravo.client.application/web/org.openbravo.client.application/js/ob-toolbar.js
Fri Feb 18 08:18:39 2011 +0100
@@ -244,7 +244,7 @@
//
// NOTE: new buttons should implement the updateState method.
//
- updateButtonState: function() {
+ updateButtonState: function(noSetSession) {
for (i = 0; i < this.leftMembers.length; i++) {
if (this.leftMembers[i].updateState) {
this.leftMembers[i].updateState();
@@ -252,7 +252,7 @@
}
// and refresh the process toolbar buttons
- this.refreshCustomButtons();
+ this.refreshCustomButtons(noSetSession);
},
// ** {{{ getLeftMember(member) }}} **
@@ -682,7 +682,7 @@
//
// Refreshes all the custom buttons in the toolbar based on current record
selection
//
- refreshCustomButtons: function(){
+ refreshCustomButtons: function(noSetSession){
function doRefresh(buttons, currentValues, hideAllButtons, me){
for (var i = 0; i < buttons.length; i++) {
if (buttons[i].updateState) {
@@ -703,8 +703,8 @@
if (this.view.viewGrid.getSelectedRecords()) {
numOfSelRecords = this.view.viewGrid.getSelectedRecords().length;
}
-
- if (this.view.buttonsHaveSessionLogic && !this.view.isShowingForm &&
!hideAllButtons && !isNew) {
+
+ if (!noSetSession && this.view.buttonsHaveSessionLogic &&
!this.view.isShowingForm && !hideAllButtons && !isNew) {
var formView = this.view.viewForm, me = this;
// Call FIC to obtain possible session attributes and set them in form
requestParams = {
diff -r b645d3ca3d0c -r 3e2d582fe956
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
Fri Feb 18 07:47:27 2011 +0100
+++
b/modules/org.openbravo.client.application/web/org.openbravo.client.application/js/ob-view-form.js
Fri Feb 18 08:18:39 2011 +0100
@@ -44,8 +44,6 @@
autoComplete: true,
redrawOnDisable: true,
- autoFocus: true,
-
// ** {{ Layout Settings }} **
numCols: 4,
colWidths: ['24%', '24%', '24%', '24%'],
@@ -128,14 +126,14 @@
// focus is done automatically, prevent the focus event if needed
// the focus event will set the active view
- this.ignoreFirstFocusEvent = preventFocus;
this.clearErrors();
if (!isNew) {
this.validateAfterFicReturn = true;
}
- this.view.toolBar.updateButtonState();
-
+ // note buttons are updated after fic return
+// this.view.toolBar.updateButtonState(true);
+ this.ignoreFirstFocusEvent = preventFocus;
this.retrieveInitialValues(isNew);
// note on purpose using this.isNew, also takes into account the _new flag
@@ -144,9 +142,6 @@
} else {
this.view.statusBar.setStateLabel();
}
- if (!preventFocus) {
- this.resetFocusItem();
- }
},
editNewRecord: function(preventFocus){
@@ -194,6 +189,14 @@
// reset the focus item to the first item which can get focus
resetFocusItem: function() {
var items = this.getItems(), length = items.length, item;
+
+ if(this.firstFocusedField) {
+ item = this.getItem(this.firstFocusedField);
+ if(item && item.getCanFocus()) {
+ this.setFocusInItem(item);
+ return;
+ }
+ }
// is set for inline grid editing for example
if (this.getFocusItem() && this.getFocusItem().getCanFocus()) {
@@ -201,28 +204,23 @@
this.view.lastFocusedField = this.getFocusItem();
return;
}
-
- if(this.firstFocusedField) {
- item = this.getItem(this.firstFocusedField);
- if(item && item.getCanFocus()) {
- item.focusInItem();
- this.view.lastFocusedField = item;
- return;
- }
- }
if (items) {
for (var i = 0; i < length; i++) {
item = items[i];
if (item.getCanFocus() && !item.isDisabled()) {
- this.focusInItem(item);
- this.view.lastFocusedItem = item;
+ this.setFocusInItem(item);
return;
}
}
}
},
+ setFocusInItem: function(item) {
+ this.setFocusItem(item);
+ this.view.lastFocusedField = item;
+ },
+
setFindNewFocusItem: function() {
var focusItem = this.getFocusItem(), item, items = this.getItems(),
length = items.length;
@@ -324,6 +322,15 @@
// remember the initial values, if we are still editing the same row
me.rememberValues();
}
+ // do some focus stuff
+ me.resetFocusItem();
+ if (me.ignoreFirstFocusEvent) {
+ delete this.ignoreFirstFocusEvent;
+ return;
+ }
+ if (me.getFocusItem()) {
+ me.getFocusItem().focusInItem();
+ }
});
},
@@ -415,14 +422,13 @@
this.markForRedraw();
if (this.showFormOnFICReturn) {
if (!this.isVisible()) {
- this.setFocusItem(null);
- this.resetFocusItem();
------------------------------------------------------------------------------
The ultimate all-in-one performance toolkit: Intel(R) Parallel Studio XE:
Pinpoint memory and threading errors before they happen.
Find and fix more than 250 security defects in the development cycle.
Locate bottlenecks in serial and parallel code that limit performance.
http://p.sf.net/sfu/intel-dev2devfeb
_______________________________________________
Openbravo-commits mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/openbravo-commits