fixed bug 28386: keep selected item when reopening FK drop down
authorAsier Lostalé <asier.lostale@openbravo.com>
Wed, 17 Dec 2014 17:14:25 +0100
changeset 25643 801318946d70
parent 25642 5f2410ceb9ad
child 25644 ed3565630685
fixed bug 28386: keep selected item when reopening FK drop down
modules/org.openbravo.client.application/web/org.openbravo.client.application/js/form/formitem/ob-formitem-fk-filter.js
--- a/modules/org.openbravo.client.application/web/org.openbravo.client.application/js/form/formitem/ob-formitem-fk-filter.js	Tue Dec 16 14:57:28 2014 +0100
+++ b/modules/org.openbravo.client.application/web/org.openbravo.client.application/js/form/formitem/ob-formitem-fk-filter.js	Wed Dec 17 17:14:25 2014 +0100
@@ -125,15 +125,27 @@
       // place after the first item was selected.
       // This first selection happens in ScrollingMenu.dataChanged
       dataArrived: function (startRow, endRow) {
-        var record, rowNum, i, values = this.formItem.getValue();
+        var record, rowNum, i, values = this.formItem.getValue(),
+            fixedValues = [],
+            value;
         this.Super('dataArrived', arguments);
         if (values) {
           if (!isc.isA.Array(values)) {
             values = [values];
           }
+
+          // fix selected values before checking them in the data to re-select them
+          for (i = 0; i < values.length; i++) {
+            value = values[i];
+            if (isc.isAn.Array(value)) {
+              value = value[0];
+            }
+            fixedValues.push(value.startsWith('==') ? value.substring(2) : value);
+          }
+
           for (rowNum = startRow; rowNum < (endRow + 1); rowNum++) {
             record = this.getRecord(rowNum);
-            if (record && values.contains(record[me.displayField])) {
+            if (record && fixedValues.contains(record[me.displayField])) {
               // selectRecord asynchronously invokes handleChanged, this should be
               // managed as when the value is picked from the list by pickValue
               this.formItem._pickingArrivedValue = true;