Fixed issue 20352. Fixed also in case of combos. Provided a better solution which doesn't cancel previous fix.
authorAntonio Moreno <antonio.moreno@openbravo.com>
Thu, 26 Apr 2012 18:37:11 +0200
changeset 16472 3ea76694b4f9
parent 16471 b8bc23efec15
child 16473 01ec47428462
Fixed issue 20352. Fixed also in case of combos. Provided a better solution which doesn't cancel previous fix.
- After the previous fix, we've realized that the same problem happened in the case of combos.
- Also, the previous fix reverted the fix of issue 19724, which could still be reproduceable in very specific circumstances.
Due to this, a new fix has been done. Instead of never removing the value if it didn't comply with any of the values in the map, we remove it if and only if the value is a UUID. This way, we avoid the problem in issue 19724 while still fixing the problem which happens when the user types a value.
modules/org.openbravo.client.application/web/org.openbravo.client.application/js/form/formitem/ob-formitem-list.js
modules/org.openbravo.client.application/web/org.openbravo.client.application/js/utilities/ob-utilities.js
modules/org.openbravo.userinterface.selector/web/org.openbravo.userinterface.selector/js/ob-selector-item.js
--- a/modules/org.openbravo.client.application/web/org.openbravo.client.application/js/form/formitem/ob-formitem-list.js	Thu Apr 26 17:29:26 2012 +0200
+++ b/modules/org.openbravo.client.application/web/org.openbravo.client.application/js/form/formitem/ob-formitem-list.js	Thu Apr 26 18:37:11 2012 +0200
@@ -148,7 +148,7 @@
         this.valueMap = {};
         this.valueMap[value] = '';
         return '';
-      } else if (!this.valueMap[value]) {
+      } else if (!this.valueMap[value] && OB.Utilities.isUUID(value)) {
         return '';
       }
     }
--- a/modules/org.openbravo.client.application/web/org.openbravo.client.application/js/utilities/ob-utilities.js	Thu Apr 26 17:29:26 2012 +0200
+++ b/modules/org.openbravo.client.application/web/org.openbravo.client.application/js/utilities/ob-utilities.js	Thu Apr 26 18:37:11 2012 +0200
@@ -909,4 +909,18 @@
 // is a reserved javascript word
 OB.Utilities.getValue = function (object, property) {
   return object[property];
+};
+
+/* This function will return true if it receives a string parameter, and 
+ * which complies with the OB UUID format (that is, its a
+ * hexadecimal number of length 32)
+ */
+OB.Utilities.isUUID = function(object) {
+  if(typeof object !=='string'){
+    return false;
+  }
+  if(object.length!==32){
+    return false;
+  }
+  return (/[A-Fa-f0-9]{32,32}/).test(object);
 };
\ No newline at end of file
--- a/modules/org.openbravo.userinterface.selector/web/org.openbravo.userinterface.selector/js/ob-selector-item.js	Thu Apr 26 17:29:26 2012 +0200
+++ b/modules/org.openbravo.userinterface.selector/web/org.openbravo.userinterface.selector/js/ob-selector-item.js	Thu Apr 26 18:37:11 2012 +0200
@@ -647,10 +647,14 @@
     if (ret === value && this.isDisabled()) {
       return '';
     }
-    if (ret === value && !this.valueMap) {
-      this.valueMap = {};
-      this.valueMap[value] = '';
-      return '';
+    if (ret === value) {
+      if (!this.valueMap) {
+        this.valueMap = {};
+        this.valueMap[value] = '';
+        return '';
+      } else if (!this.valueMap[value] && OB.Utilities.isUUID(value)) {
+        return '';
+      }
     }
     return ret;
   },