fixed bug 30316: selectors with display field property fail
authorAsier Lostalé <asier.lostale@openbravo.com>
Mon, 06 Jul 2015 11:20:55 +0200
changeset 27080 c95251b3e0b5
parent 27079 b8a65b22f95f
child 27081 613b06e82db5
fixed bug 30316: 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	Thu Jul 02 22:07:27 2015 +0530
+++ 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();