details: /erp/devel/pi/rev/1b57600d5691
changeset: 12130:1b57600d5691
user: Martin Taal <martin.taal <at> openbravo.com>
date: Thu May 12 14:57:37 2011 +0200
summary: Fixes issue 16611: Initial request done by UI selector element in
form view does not use any filters or paging
diffstat:
modules/org.openbravo.client.application/web/org.openbravo.client.application/js/ob-view-form.js
| 13 ++
modules/org.openbravo.client.application/web/org.openbravo.client.application/js/ob-view-grid.js
| 60 ++++++---
modules/org.openbravo.userinterface.selector/web/org.openbravo.userinterface.selector/js/ob-selector-item.js
| 56 +++++++-
3 files changed, 97 insertions(+), 32 deletions(-)
diffs (258 lines):
diff -r 9c2ea7e89365 -r 1b57600d5691
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
Thu May 12 12:28:07 2011 +0200
+++
b/modules/org.openbravo.client.application/web/org.openbravo.client.application/js/ob-view-form.js
Thu May 12 14:57:37 2011 +0200
@@ -742,6 +742,10 @@
return;
}
+ if (field && field.resetCache) {
+ field.resetCache();
+ }
+
// note field can be a datasource field, see above, in that case
// don't set the entries
if (field.form && entries) {
@@ -966,6 +970,7 @@
// in contrast to other actions which are done at blur
// see: handleItemChange
itemChangeActions: function(){
+ var i = 0;
// special case, item change is called when the inline form is being hidden
if (!this.view.isShowingForm && !this.view.isEditingGrid) {
return;
@@ -975,6 +980,14 @@
this.setHasChanged(true);
this.view.messageBar.hide();
this.view.toolBar.updateButtonState(true);
+
+ // invalidate the cache of picklists on a change
+ for (i = 0; i < this.getFields().length; i++) {
+ if (this.getFields()[i].resetCache) {
+ this.getFields()[i].resetCache();
+ }
+ }
+
},
// make sure that any field errors also appear in the grid
diff -r 9c2ea7e89365 -r 1b57600d5691
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
Thu May 12 12:28:07 2011 +0200
+++
b/modules/org.openbravo.client.application/web/org.openbravo.client.application/js/ob-view-grid.js
Thu May 12 14:57:37 2011 +0200
@@ -432,6 +432,10 @@
},
deselectAllRecords: function(preventUpdateSelectInfo, autoSaveDone){
+ // if there is nothing to deselect then don't deselect
+ if (!this.getSelectedRecord()) {
+ return;
+ }
if (!autoSaveDone) {
var actionObject = {
target: this,
@@ -684,24 +688,6 @@
this.doSelectSingleRecord(gridRecord);
},
- // overridden to prevent extra firing of selection updated event
- selectSingleRecord: function(record){
- if (this.getSelectedRecord() && this.getSelectedRecord() !== record) {
- this.deselectAllRecords(true);
- }
- this.selectRecord(record);
-
- // keep it to try to get it back when the selection gets lost when
- // loading data
- this.lastSelectedRecord = record;
- },
-
- // overridden to prevent extra firing of selection updated event
- // selectrecords will fire it once
- selectRecord: function(record, state, colNum){
- this.selectRecords(record, state, colNum);
- },
-
filterData: function(criteria, callback, requestProperties){
if (!requestProperties) {
requestProperties = {};
@@ -1120,6 +1106,9 @@
// one has as disadvantage that it is called multiple times
// for one select/deselect action
selectionUpdated: function(record, recordList){
+ if (record === this.lastSelectedRecord && (this.lastSelectedRecord ||
record)) {
+ return;
+ }
// close any editors, but only if it is different from the one we are
editing
if (this.isEditingGrid) {
@@ -1581,7 +1570,10 @@
this.Super('cellEditEnd', [editCompletionEvent,
this.getEditValue(rowNum, colNum)]);
return;
} else {
- if (focusItem) {
+ // only needed for non picklist fields
+ // as picklist fields will always have picked a value
+ // note that focusItem updatevalue for picklist can result in extra
datasource requests
+ if (focusItem && !focusItem.hasPickList) {
focusItem.updateValue();
editForm.handleItemChange(focusItem);
if (editForm.inFicCall) {
@@ -1701,6 +1693,7 @@
hideInlineEditor: function(focusInBody, suppressCMHide) {
var rowNum = this.getEditRow(), record = this.getRecord(rowNum);
+ this._hidingInlineEditor = true;
if (rowNum === 0 || rowNum) {
if (!this.rowHasErrors(rowNum)) {
record[this.recordBaseStyleProperty] = null;
@@ -1727,9 +1720,10 @@
this.getEditForm().clearValues();
}
}
-
// always hide the clickmask, as it needs to be re-applied
- return this.Super('hideInlineEditor', [focusInBody, false]);
+ var ret = this.Super('hideInlineEditor', [focusInBody, false]);
+ delete this._hidingInlineEditor;
+ return ret;
},
getEditDisplayValue: function(rowNum, colNum, record){
@@ -1740,6 +1734,9 @@
},
showInlineEditor: function(rowNum, colNum, newCell, newRow, suppressFocus){
+
+ this._showingEditor = true;
+
if (newRow) {
if (this.getEditForm()) {
this.getEditForm().clearErrors();
@@ -1750,6 +1747,8 @@
}
var ret = this.Super('showInlineEditor', [rowNum, colNum, newCell, newRow,
suppressFocus]);
+
+ delete this._showingEditor;
if (!newRow) {
return ret;
}
@@ -1821,6 +1820,25 @@
}
},
+ // having a valueMap property results in setValueMap to be called
+ // on an item. On items with a picklist this causes calls to the
+ // server side
+ getEditItem: function() {
+ var result = this.Super('getEditItem', arguments);
+ if (result.hasOwnProperty('valueMap') && !result.valueMap) {
+ delete result.valueMap;
+ }
+ return result;
+ },
+
+ // set some flags to prevent the picklist fields from doing extra datasource
+ // requests
+ storeUpdatedEditorValue : function (suppressChange, editCol) {
+ this._storingUpdatedEditorValue = true;
+ this.Super('storeUpdatedEditorValue', arguments);
+ delete this._storingUpdatedEditorValue;
+ },
+
// the form gets recreated many times, maintain the already read valuemap
getEditorValueMap: function(field, values){
var editRow = this.getEditRow(), editValues = this.getEditValues(editRow);
diff -r 9c2ea7e89365 -r 1b57600d5691
modules/org.openbravo.userinterface.selector/web/org.openbravo.userinterface.selector/js/ob-selector-item.js
---
a/modules/org.openbravo.userinterface.selector/web/org.openbravo.userinterface.selector/js/ob-selector-item.js
Thu May 12 12:28:07 2011 +0200
+++
b/modules/org.openbravo.userinterface.selector/web/org.openbravo.userinterface.selector/js/ob-selector-item.js
Thu May 12 14:57:37 2011 +0200
@@ -286,6 +286,7 @@
isc.ClassFactory.mixInInterface('OBSelectorItem', 'OBLinkTitleItem');
isc.OBSelectorItem.addProperties({
+ hasPickList: true,
popupTextMatchStyle: 'startswith',
suggestionTextMatchStyle: 'startswith',
selectOnFocus: true,
@@ -314,6 +315,36 @@
}
},
+ setUpPickList: function (show, queueFetches, request) {
+ // Set the pickListWidth just before being shown.
+ this.setPickListWidth();
+ this.Super('setUpPickList', arguments);
+ },
+
+ // don't do update value in all cases, updatevalue results in a data source
request
+ // to the server, so only do updatevalue when the user changes information
+ updateValue: function () {
+ if (this.form && this.form.grid &&
+ (this.form.grid._storingUpdatedEditorValue ||
this.form.grid._showingEditor || this.form.grid._hidingInlineEditor)) {
+ // prevent updatevalue while the form is being shown or hidden
+ return;
+ }
+ this.Super('updateValue', arguments);
+ },
+
+ // at setvalue set the display value in a valuemap to prevent datasource
requests to
+ // get the display value
+ setValue: function(newValue) {
+ if (this.form && this.form.getValues() && this.form.getValues()[this.name]
=== newValue &&
+ this.form.getValues()[this.name + '._identifier']) {
+ if (!this.valueMap) {
+ this.valueMap = {};
+ }
+ this.valueMap[newValue] = this.form.getValues()[this.name +
'._identifier'];
+ }
+ this.Super('setValue', arguments);
+ },
+
setPickListWidth: function(){
var extraWidth = 0,
fieldWidth = this.getVisibleWidth();
@@ -324,15 +355,6 @@
this.pickListWidth = (fieldWidth < 150 ? 150 : fieldWidth) + extraWidth;
},
- showPickList: function() {
- if (this.pickList) {
- this.pickList.invalidateCache();
- }
- // Set the pickListWidth just before being shown.
- this.setPickListWidth();
- this.Super('showPickList', arguments);
- },
-
init: function(){
this.icons = [{
src: this.popupIconSrc,
@@ -377,6 +399,16 @@
return this.Super('init', arguments);
},
+ // reset the cache without reloading directly
+ resetCache: function() {
+ if (this.pickList && this.pickList.data) {
+ // don't use field.pickList.invalidateCache as it will force a fetch
+ // the fetch is only needed later when someone really changes the value
+ this.pickList.data.invalidateRows();
+ this.pickList.data.totalRows = 0;
+ }
+ },
+
setValueFromRecord: function(record, fromPopup){
var currentValue = this.getValue();
if (!record) {
@@ -439,8 +471,10 @@
},
pickValue: function(value){
- var ret = this.Super('pickValue', arguments);
- this.setValueFromRecord(this.pickList.getSelectedRecord());
+ // get the selected record before calling the super, as this super call
+ // will deselect the record
+ var selectedRecord = this.pickList.getSelectedRecord(), ret =
this.Super('pickValue', arguments);
+ this.setValueFromRecord(selectedRecord);
return ret;
},
------------------------------------------------------------------------------
Achieve unprecedented app performance and reliability
What every C/C++ and Fortran developer should know.
Learn how Intel has extended the reach of its next-generation tools
to help boost performance applications - inlcuding clusters.
http://p.sf.net/sfu/intel-dev2devmay
_______________________________________________
Openbravo-commits mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/openbravo-commits