details: /erp/devel/pi/rev/22fec75d81c6
changeset: 9849:22fec75d81c6
user: Martin Taal <martin.taal <at> openbravo.com>
date: Mon Jan 17 09:35:54 2011 +0100
summary: Solved issues with selection even being fired to often
diffstat:
modules/org.openbravo.client.application/web/org.openbravo.client.application/js/ob-standard-view.js
| 43 +++++--
modules/org.openbravo.client.application/web/org.openbravo.client.application/js/ob-view-grid.js
| 52 ++++-----
2 files changed, 50 insertions(+), 45 deletions(-)
diffs (189 lines):
diff -r 6ede775930f7 -r 22fec75d81c6
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 08:43:42 2011 +0100
+++
b/modules/org.openbravo.client.application/web/org.openbravo.client.application/js/ob-standard-view.js
Mon Jan 17 09:35:54 2011 +0100
@@ -136,6 +136,7 @@
// set if one record has been selected
lastRecordSelected: null,
+ lastRecordSelectedCount: 0,
// ** {{{ refreshContents }}} **
// Should the contents listgrid/forms be refreshed when the tab
@@ -283,18 +284,19 @@
if (dsRequest.clientContext &&
dsRequest.clientContext.progressIndicatorSelectedRecord) {
this.hideProgress(dsRequest.clientContext.progressIndicatorSelectedRecord);
}
-
- var errorStatus = !jsonData.response || jsonData.response.status ===
'undefined' || jsonData.response.status !== isc.RPCResponse.STATUS_SUCCESS;
- if (errorStatus) {
- var handled = this.view.setErrorMessageFromResponse(dsResponse,
jsonData, dsRequest);
-
- if (!handled && !dsRequest.willHandleError) {
- OB.KernelUtilities.handleSystemException(error.message);
+ if (jsonData) {
+ var errorStatus = !jsonData.response || jsonData.response.status ===
'undefined' || jsonData.response.status !== isc.RPCResponse.STATUS_SUCCESS;
+ if (errorStatus) {
+ var handled = this.view.setErrorMessageFromResponse(dsResponse,
jsonData, dsRequest);
+
+ if (!handled && !dsRequest.willHandleError) {
+ OB.KernelUtilities.handleSystemException(error.message);
+ }
+ } else {
+ // there are some cases where the jsonData is not passed, in case
of errors
+ // make it available through the response object
+ dsResponse.dataObject = jsonData;
}
- } else {
- // there are some cases where the jsonData is not passed, in case of
errors
- // make it available through the response object
- dsResponse.dataObject = jsonData;
}
return this.Super('transformResponse', arguments);
}
@@ -879,11 +881,13 @@
// which will again refresh their children.
recordSelected: function(){
// no change go away
- if (this.viewGrid.getSelectedRecords().length === 1 &&
this.viewGrid.getSelectedRecord() === this.lastRecordSelected) {
+ if (!this.hasSelectionStateChanged()) {
return;
}
- this.lastRecordSelected = this.viewGrid.getSelectedRecord();
-
+ this.updateLastSelectedState();
+
+ this.toolBar.setLeftMemberDisabled(isc.OBToolbar.TYPE_DELETE,
(!this.viewGrid.getSelection() || this.viewGrid.getSelection().length === 0));
+
var tabViewPane = null;
// refresh the tabs
@@ -900,6 +904,17 @@
this.toolBar.refreshToolbarButtons();
},
+ hasSelectionStateChanged: function() {
+ return (this.viewGrid.getSelectedRecords().length !==
this.lastRecordSelectedCount ||
+ (this.viewGrid.getSelectedRecord() &&
this.viewGrid.getSelectedRecord().id !== this.lastRecordSelected.id)) ||
+ (this.lastRecordSelected && !this.viewGrid.getSelectedRecord());
+ },
+
+ updateLastSelectedState: function() {
+ this.lastRecordSelectedCount = this.viewGrid.getSelectedRecords().length;
+ this.lastRecordSelected = this.viewGrid.getSelectedRecord();
+ },
+
// ** {{{ parentRecordSelected }}} **
// Is called when a selection change occurs in the parent.
parentRecordSelected: function(){
diff -r 6ede775930f7 -r 22fec75d81c6
modules/org.openbravo.client.application/web/org.openbravo.client.application/js/ob-view-grid.js
---
a/modules/org.openbravo.client.application/web/org.openbravo.client.application/js/ob-view-grid.js
Mon Jan 17 08:43:42 2011 +0100
+++
b/modules/org.openbravo.client.application/web/org.openbravo.client.application/js/ob-view-grid.js
Mon Jan 17 09:35:54 2011 +0100
@@ -237,12 +237,16 @@
deselectAllRecords: function(){
this.allSelected = false;
- return this.Super('deselectAllRecords', arguments);
+ var ret = this.Super('deselectAllRecords', arguments);
+ this.selectionUpdated();
+ return ret;
},
selectAllRecords: function(){
this.allSelected = true;
- return this.Super('selectAllRecords', arguments);
+ var ret = this.Super('selectAllRecords', arguments);
+ this.selectionUpdated();
+ return ret;
},
updateRowCountDisplay: function(){
@@ -491,23 +495,10 @@
},
recordClick: function(viewer, record, recordNum, field, fieldNum, value,
rawValue){
- var me = this, EH = isc.EventHandler;
- if (EH.isMouseEvent(EH.getEventType())) {
- record._dblClickWaiting = true;
- isc.Timer.setTimeout(function(){
- // if no double click happened then do the single click
- if (record._dblClickWaiting) {
- record._dblClickWaiting = false;
- me.handleRecordSelection(viewer, record, recordNum, field, fieldNum,
value, rawValue, false);
- }
- }, OB.Constants.DBL_CLICK_DELAY);
- } else {
- me.handleRecordSelection(viewer, record, recordNum, field, fieldNum,
value, rawValue, false);
- }
+ this.handleRecordSelection(viewer, record, recordNum, field, fieldNum,
value, rawValue, false);
},
recordDoubleClick: function(viewer, record, recordNum, field, fieldNum,
value, rawValue){
- record._dblClickWaiting = false;
this.view.editRecord(record);
},
@@ -577,28 +568,22 @@
}
},
- selectionUpdated: function(record, recordList){
+ getCheckboxField: function() {
+ var ret = this.Super('getCheckboxField', arguments);
+ return ret;
+ },
+ // note when solving selection issues in the future also
+ // consider using the selectionChanged method, but that
+ // one has as disadvantage that it is called multiple times
+ // for one select/deselect action
+ selectionUpdated: function(record, recordList){
this.stopHover();
this.updateSelectedCountDisplay();
-
- // nothing changed, go away then, happens when saving
- if (this.singleRecordSelection && this.view.lastRecordSelected &&
this.getSelection().length === 1 && this.getSelection()[0].id ===
this.view.lastRecordSelected.id) {
- // instance may have been updated, update the instance in the view
- this.view.lastRecordSelected = this.getSelection()[0];
- return;
- }
-
- isc.Log.logDebug('Selection updated ' + record, 'OB');
-
this.view.recordSelected();
-
- // enable/disable the delete if there are records selected
- this.view.toolBar.setLeftMemberDisabled(isc.OBToolbar.TYPE_DELETE,
(!this.getSelection() || this.getSelection().length === 0));
},
selectOnMouseDown: function(record, recordNum, fieldNum){
-
// don't change selection on right mouse down
var EH = isc.EventHandler, eventType;
if (EH.rightButtonDown()) {
@@ -671,7 +656,9 @@
this.deselectAllRecords();
}
// click in checkbox field is done by standard logic
+ // in the selectOnMouseDown
this.singleRecordSelection = false;
+ this.selectionUpdated();
} else if (isc.EventHandler.ctrlKeyDown()) {
// only do something if record clicked and not from selectOnMouseDown
// this method got called twice from one clicK: through recordClick and
@@ -692,6 +679,8 @@
// click on the record which was already selected
this.doSelectSingleRecord(record);
}
+
+ this.updateSelectedCountDisplay();
// mark some redraws if there are lines which don't
// have a checkbox flagged, so if we move from single record selection
@@ -954,6 +943,7 @@
},
doOpen: function(){
+ this.grid.endEditing();
this.grid.view.editRecord(this.record);
},
------------------------------------------------------------------------------
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