details: /erp/devel/pi/rev/1c3a638a6b50
changeset: 12139:1c3a638a6b50
user: Iván Perdomo <ivan.perdomo <at> openbravo.com>
date: Thu May 12 18:52:58 2011 +0200
summary: Issue 17113: Add a copy of showIf definition to obShowIf
- This reference copy is used in the showIf of the section. Somehow the item
showIf function definition gets set to null
- Fixes several JSLint warnings
details: /erp/devel/pi/rev/67e716398e7a
changeset: 12140:67e716398e7a
user: Iván Perdomo <ivan.perdomo <at> openbravo.com>
date: Thu May 12 18:55:45 2011 +0200
summary: Fixes issue 17113: Use a copy of showIf in the sections
- Use a copy of showIf defined at Item level, to see if the section needs to
be shown or not
- Solve several JSLint warnings
- Remove the logic on processFICReturn since is not used anymore
diffstat:
modules/org.openbravo.client.application/web/org.openbravo.client.application/js/ob-formitem-widgets.js
| 43 +++++++--
modules/org.openbravo.client.application/web/org.openbravo.client.application/js/ob-view-form.js
| 39 ---------
modules/org.openbravo.userinterface.smartclient/web/org.openbravo.userinterface.smartclient/js/ob-smartclient.js
| 19 ++-
3 files changed, 45 insertions(+), 56 deletions(-)
diffs (204 lines):
diff -r ab9973f3e5b8 -r 67e716398e7a
modules/org.openbravo.client.application/web/org.openbravo.client.application/js/ob-formitem-widgets.js
---
a/modules/org.openbravo.client.application/web/org.openbravo.client.application/js/ob-formitem-widgets.js
Thu May 12 18:52:55 2011 +0200
+++
b/modules/org.openbravo.client.application/web/org.openbravo.client.application/js/ob-formitem-widgets.js
Thu May 12 18:55:45 2011 +0200
@@ -203,7 +203,7 @@
var height, width, top, left;
var complementsNS4 = '';
var auxField = '';
- var hidden;
+ var hidden, i;
if (url.indexOf('Location') !== -1) {
height = 300;
@@ -226,7 +226,7 @@
}
if (parameters) {
var total = parameters.length;
- for (var i = 0; i < total; i++) {
+ for (i = 0; i < total; i++) {
if (auxField !== '') {
auxField += '&';
}
@@ -353,7 +353,7 @@
src :
'[SKIN]/../../org.openbravo.client.application/images/form/search_picker.png',
click: function(form, item) {
var url = item.getValue();
- if(!url || url.indexOf('://') == -1) {
+ if(!url || url.indexOf('://') === -1) {
return;
}
window.open(url);
@@ -476,8 +476,8 @@
},
setNewFocusItemExpanding: function(){
- var newFocusItem = null;
- for (var i = 0; i < this.itemIds.length; i++) {
+ var newFocusItem = null, i;
+ for (i = 0; i < this.itemIds.length; i++) {
var itemName = this.itemIds[i], item = this.form.getItem(itemName);
// isFocusable is a method added in ob-smartclient.js
if (item.isFocusable()) {
@@ -492,6 +492,31 @@
} else {
newFocusItem.focusInItem();
}
+ },
+
+ showIf: function(item, value, form, values) {
+ var i, field;
+
+ if(!this.itemIds || !isAn.Array(this.itemIds)) {
+ return false;
+ }
+
+ for (i = 0; i < this.itemIds.length; i++) {
+ field = form.getItem(this.itemIds[i]);
+
+ if(!field) {
+ continue;
+ }
+
+ if (field.showIf) {
+ if(field.showIf(field, value, form)) {
+ return true;
+ }
+ } else {
+ return true;
+ }
+ }
+ return false;
}
});
@@ -1107,10 +1132,10 @@
init: function(){
this.setKeyPressFilter(this.keyPressFilterNumeric);
this.typeInstance = SimpleType.getType(this.type);
- var newValidators = [];
+ var newValidators = [], i;
// get rid of the isFloat validators, as we have
// specific validation based on the format definition
- for (var i = 0; i < this.validators.length; i++) {
+ for (i = 0; i < this.validators.length; i++) {
if (this.validators[i].type !== 'isFloat') {
newValidators.push(this.validators[i]);
}
@@ -1147,8 +1172,8 @@
},
returnNewCaretPosition: function(numberStr, oldCaretPosition){
- var newCaretPosition = oldCaretPosition;
- for (var i = oldCaretPosition; i > 0; i--) {
+ var newCaretPosition = oldCaretPosition, i;
+ for (i = oldCaretPosition; i > 0; i--) {
if (numberStr.substring(i - 1, i) === this.getGroupSeparator()) {
newCaretPosition = newCaretPosition - 1;
}
diff -r ab9973f3e5b8 -r 67e716398e7a
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 18:52:55 2011 +0200
+++
b/modules/org.openbravo.client.application/web/org.openbravo.client.application/js/ob-view-form.js
Thu May 12 18:55:45 2011 +0200
@@ -616,45 +616,6 @@
}
}
- // Hiding sections that where all fields are not visible
- for(i = 0; i < this.getItems().length; i++) {
- item = this.getItem(i);
- if(item && item.getClassName() === 'OBSectionItem') {
-
- section = item;
-
- // Keep whether it was expanded and expand in case it was not.
Collapsed
- // sections keep all its fields as not visible, so they were hidden.
- var wasExpanded = section.isExpanded();
- if (!wasExpanded) {
- section.expandSection();
- }
-
- section.visible = false;
- for(j = 0; j < section.itemIds.length; j++) {
- item = this.getItem(section.itemIds[j]);
- if(item && item.visible && item.editorType !== 'HiddenItem') {
- section.visible = true;
- break;
- }
- }
-
- if(!section.visible) {
- for(j = 0; j < section.itemIds.length; j++) {
- item = this.getItem(section.itemIds[j]);
- if(item) {
- item.alwaysTakeSpace = false;
- }
- }
- }
-
- // Restore previous expand mode
- if (!wasExpanded) {
- section.collapseSection();
- }
- }
- }
-
this.markForRedraw();
this.view.toolBar.updateButtonState(true);
diff -r ab9973f3e5b8 -r 67e716398e7a
modules/org.openbravo.userinterface.smartclient/web/org.openbravo.userinterface.smartclient/js/ob-smartclient.js
---
a/modules/org.openbravo.userinterface.smartclient/web/org.openbravo.userinterface.smartclient/js/ob-smartclient.js
Thu May 12 18:52:55 2011 +0200
+++
b/modules/org.openbravo.userinterface.smartclient/web/org.openbravo.userinterface.smartclient/js/ob-smartclient.js
Thu May 12 18:55:45 2011 +0200
@@ -70,6 +70,7 @@
_original_init: isc.FormItem.getPrototype().init,
init: function() {
+ this.obShowIf = this.showIf; // Copy the reference of showIf definition
OB.Utilities.addRequiredSuffixToBaseStyle(this);
// and continue with the original init
this._original_init();
@@ -188,19 +189,21 @@
// Shows or hides the quantity box and updates the hint to reflect the
current value.
// overridden to solve: https://issues.openbravo.com/view.php?id=16295
updateEditor : function () {
-
- if (!this.valueField || !this.quantityField) return;
-
+
+ if (!this.valueField || !this.quantityField) {
+ return;
+ }
+
var focusItem,
selectionRange,
mustRefocus = false;
-
+
if (this.valueField.hasFocus) {
focusItem = this.valueField;
selectionRange = this.valueField.getSelectionRange();
} else if (this.quantityField.hasFocus) {
focusItem = this.quantityField;
- selectionRange = this.quantityField.getSelectionRange()
+ selectionRange = this.quantityField.getSelectionRange();
}
var value = this.valueField.getValue(),
@@ -242,8 +245,8 @@
// If we redrew the form to show or hide the qty field, we may need to
refocus and
// reset the selection range
- if (mustRefocus && focusItem != null) {
- if (!showQuantity && focusItem == this.quantityField) {
+ if (mustRefocus && focusItem !== null) {
+ if (!showQuantity && focusItem === this.quantityField) {
this.valueField.focusInItem();
} else {
if (selectionRange) {
@@ -286,7 +289,7 @@
this._handleError(response, request);
}
}
-})
+});
// uncomment this code and put a breakpoint to get a better control
// on from where async operations are started
------------------------------------------------------------------------------
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