details: https://code.openbravo.com/erp/devel/pi/rev/71df089998c4
changeset: 13291:71df089998c4
user: Martin Taal <martin.taal <at> openbravo.com>
date: Tue Jul 26 23:01:25 2011 +0200
summary: Related to issue 18072: Focus handling in form and grid editing
needs to be cleaned up, results in unpredictable behavior
List item was showing strange behavior on select, field change event should
only be fired when a value is
selected explicitly from the picklist
diffstat:
modules/org.openbravo.client.application/src/org/openbravo/client/application/templates/ob-view-field.js.ftl
| 3 +
modules/org.openbravo.client.application/src/org/openbravo/client/application/templates/ob-view-grid.js.ftl
| 3 +
modules/org.openbravo.client.application/web/org.openbravo.client.application/js/form/formitem/ob-formitem-list.js
| 55 ++++++----
3 files changed, 39 insertions(+), 22 deletions(-)
diffs (149 lines):
diff -r c5c36112a9b5 -r 71df089998c4
modules/org.openbravo.client.application/src/org/openbravo/client/application/templates/ob-view-field.js.ftl
---
a/modules/org.openbravo.client.application/src/org/openbravo/client/application/templates/ob-view-field.js.ftl
Tue Jul 26 20:13:02 2011 +0200
+++
b/modules/org.openbravo.client.application/src/org/openbravo/client/application/templates/ob-view-field.js.ftl
Tue Jul 26 23:01:25 2011 +0200
@@ -43,6 +43,9 @@
<#if fieldDefinition.redrawOnChange?string = "true" &&
fieldDefinition.displayed>
redrawOnChange: true,
changed: function(form, item, value) {
+ if (this.pickValue && !this._pickedValue) {
+ return;
+ }
this.Super('changed', arguments);
form.onFieldChanged(form, item, value);
form.view.toolBar.refreshCustomButtonsView(form.view);
diff -r c5c36112a9b5 -r 71df089998c4
modules/org.openbravo.client.application/src/org/openbravo/client/application/templates/ob-view-grid.js.ftl
---
a/modules/org.openbravo.client.application/src/org/openbravo/client/application/templates/ob-view-grid.js.ftl
Tue Jul 26 20:13:02 2011 +0200
+++
b/modules/org.openbravo.client.application/src/org/openbravo/client/application/templates/ob-view-grid.js.ftl
Tue Jul 26 23:01:25 2011 +0200
@@ -39,6 +39,9 @@
<#if field.redrawOnChange?string = "true" >
, redrawOnChange: true
, changed: function(form, item, value) {
+ if (this.pickValue && !this._pickedValue) {
+ return;
+ }
this.Super('changed', arguments);
form.onFieldChanged(form, item, value);
form.view.toolBar.refreshCustomButtonsView(form.view);
diff -r c5c36112a9b5 -r 71df089998c4
modules/org.openbravo.client.application/web/org.openbravo.client.application/js/form/formitem/ob-formitem-list.js
---
a/modules/org.openbravo.client.application/web/org.openbravo.client.application/js/form/formitem/ob-formitem-list.js
Tue Jul 26 20:13:02 2011 +0200
+++
b/modules/org.openbravo.client.application/web/org.openbravo.client.application/js/form/formitem/ob-formitem-list.js
Tue Jul 26 23:01:25 2011 +0200
@@ -24,30 +24,40 @@
isc.OBListItem.addProperties({
operator: 'equals',
hasPickList: true,
- showPickListOnKeypress: true,
+ showPickListOnKeypress: true,
cachePickListResults: false,
completeOnTab: true,
validateOnExit: true,
-
+
// textMatchStyle is used for the client-side picklist
textMatchStyle: 'substring',
- // NOTE: Setting this property to false fixes the issue when using the mouse
to pick a value
+ // NOTE: Setting this property to false fixes the issue when using the mouse
+ // to pick a value
// FIXME: Sometimes the field label gets a red color (a blink)
// if set to false then the picklist is shown at focus:
// https://issues.openbravo.com/view.php?id=18075
-// addUnknownValues: true,
- changeOnKeyPress: false,
+ // addUnknownValues: true,
+ // changeOnKeypress should not be set to false together
+ // with addUnknownValues (to false) as this will
+ // cause the picklist not to show
+ // changeOnKeypress: false,
- // if select on focus is true then only one character is selected all the
time
- selectOnFocus: false,
- // let it be selected explicitly when needed
- doExplicitSelectOnFocus: true,
-
moveFocusOnPickValue: true,
-
+
+ // needed when selectOnFocus is true
+ // otherwise a single typed in char is selected
+ // all the time so that you can only type in
+ // one character
+ handleChange: function() {
+ if (!this._pickedValue) {
+ return;
+ }
+ return this.Super('handleChange', arguments);
+ },
+
// is overridden to keep track that a value has been explicitly picked
- pickValue: function (value) {
+ pickValue: function(value) {
this._pickedValue = true;
this.Super('pickValue', arguments);
delete this._pickedValue;
@@ -67,14 +77,14 @@
this.form.handleItemChange(this);
}
},
-
+
pickListProperties: {
showHeaderContextMenu: false
},
// to solve: https://issues.openbravo.com/view.php?id=17800
// in chrome the order of the valueMap object is not retained
- // the solution is to keep a separate entries array with the
+ // the solution is to keep a separate entries array with the
// records in the correct order, see also the setEntries/setEntry
// methods
getClientPickListData: function() {
@@ -83,9 +93,9 @@
}
return this.Super('getClientPickListData', arguments);
},
-
+
setEntries: function(entries) {
- var valueField = this.getValueFieldName(), valueMap = {};
+ var valueField = this.getValueFieldName(), valueMap = {};
this.entries = [];
for (i = 0; i < entries.length; i++) {
id = entries[i][OB.Constants.ID] || '';
@@ -96,24 +106,25 @@
}
this.setValueMap(valueMap);
},
-
+
setEntry: function(id, identifier) {
- var i, entries = this.entries || [], entry = {}, valueField =
this.getValueFieldName();
+ var i, entries = this.entries || [], entry = {}, valueField = this
+ .getValueFieldName();
for (i = 0; i < entries.length; i++) {
if (entries[i][valueField] === id) {
return;
}
}
-
+
// not found add/create a new one
entry[valueField] = id;
entries.push(entry);
-
+
this.setEntries(entries);
},
// prevent ids from showing up
- mapValueToDisplay: function (value) {
+ mapValueToDisplay: function(value) {
var ret = this.Super('mapValueToDisplay', arguments);
if (this.valueMap && this.valueMap[value]) {
return this.valueMap[value];
@@ -128,5 +139,5 @@
}
return ret;
}
-
+
});
------------------------------------------------------------------------------
Got Input? Slashdot Needs You.
Take our quick survey online. Come on, we don't ask for help often.
Plus, you'll get a chance to win $100 to spend on ThinkGeek.
http://p.sf.net/sfu/slashdot-survey
_______________________________________________
Openbravo-commits mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/openbravo-commits