details:   https://code.openbravo.com/erp/devel/pi/rev/37976c35e0cb
changeset: 17868:37976c35e0cb
user:      Augusto Mauch <augusto.mauch <at> openbravo.com>
date:      Fri Sep 07 11:03:34 2012 +0200
summary:   Fixes issue 21553: mapDisplayToValue supports valuemap with 
non-unique values

If mapDisplayValue is called with the currently displayed value (i.e. name) , 
the currently selected value (id) will be returned.

diffstat:

 
modules/org.openbravo.client.application/web/org.openbravo.client.application/js/form/formitem/ob-formitem-list.js
 |  14 +++++++--
 1 files changed, 11 insertions(+), 3 deletions(-)

diffs (34 lines):

diff -r 6ab1c8f8f009 -r 37976c35e0cb 
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
        Thu Sep 06 13:27:51 2012 +0200
+++ 
b/modules/org.openbravo.client.application/web/org.openbravo.client.application/js/form/formitem/ob-formitem-list.js
        Fri Sep 07 11:03:34 2012 +0200
@@ -142,6 +142,7 @@
   mapValueToDisplay: function (value) {
     var ret = this.Super('mapValueToDisplay', arguments);
     if (this.valueMap && this.valueMap[value]) {
+      this.lastSelectedValue = value;
       return this.valueMap[value];
     }
 
@@ -162,11 +163,18 @@
     return ret;
   },
 
-  mapDisplayToValue: function (value) {
-    if (value === '') {
+  mapDisplayToValue: function (display) {
+    if (display === '') {
       return null;
     }
-    return this.Super('mapDisplayToValue', arguments);
+    if (this.lastSelectedValue && display === 
this.mapValueToDisplay(this.lastSelectedValue)) {
+      // Prevents mapDisplayToValue from failing when there are several
+      // entries in the valuemap with the same value
+      // See issue https://issues.openbravo.com/view.php?id=21553
+      return this.lastSelectedValue;
+    } else {
+      return this.Super('mapDisplayToValue', arguments);
+    }
   }
 
 });
\ No newline at end of file

------------------------------------------------------------------------------
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and 
threat landscape has changed and how IT managers can respond. Discussions 
will include endpoint security, mobile security and the latest in malware 
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
_______________________________________________
Openbravo-commits mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/openbravo-commits

Reply via email to