fixed bug 30297: selectors with display field property fail
authorAsier Lostalé <asier.lostale@openbravo.com>
Mon, 06 Jul 2015 11:20:55 +0200
changeset 27083 22f85795e81f
parent 27082 b815e49be324
child 27084 2cb16178b888
fixed bug 30297: selectors with display field property fail

They failed in case the display field property was not in the main property but
in a referenced one. In this case, the property was tried to be obtained from the
record object in an incorrect manner (path to the referred entity was removed).

The fix preserves path to referred entity and checks for not null value before
doing replacements in the string.
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	Fri Jul 03 15:04:14 2015 +0200
+++ b/modules/org.openbravo.userinterface.selector/web/org.openbravo.userinterface.selector/js/ob-selector-item.js	Mon Jul 06 11:20:55 2015 +0200
@@ -752,7 +752,7 @@
     var currentValue = this.getValue(),
         identifierFieldName = this.name + OB.Constants.FIELDSEPARATOR + OB.Constants.IDENTIFIER,
         valueMapObj = {},
-        displayFieldValue, i;
+        valueToDisplay, i;
     this._notUpdatingManually = true;
     if (!record) {
       this.storeValue(null);
@@ -799,12 +799,11 @@
       }
 
       if (record[this.valueField]) { // it can be undefined in case of empty (null) entry
-        if (this.displayField.indexOf(OB.Constants.FIELDSEPARATOR) !== -1) {
-          displayFieldValue = this.displayField.substring(this.displayField.indexOf(OB.Constants.FIELDSEPARATOR) + 1, this.displayField.length);
-        } else {
-          displayFieldValue = this.displayField;
+        valueToDisplay = record[this.displayField];
+        if (valueToDisplay) {
+          valueToDisplay = valueToDisplay.replace(/[\n\r]/g, '');
         }
-        this.valueMap[record[this.valueField]] = record[displayFieldValue].replace(/[\n\r]/g, '');
+        this.valueMap[record[this.valueField]] = valueToDisplay;
       }
 
       this.updateValueMap();