details:   https://code.openbravo.com/erp/devel/pi/rev/3ae59cee1ac2
changeset: 25871:3ae59cee1ac2
user:      Augusto Mauch <augusto.mauch <at> openbravo.com>
date:      Thu Feb 05 12:33:34 2015 +0100
summary:   Fixes issue 28843: Characteristic selector does not filter by the 
selected item

The problem was that if a value was selected in a form item that uses the tree 
references, when the user opened the drop down the values were filtered using 
the selected value. This is not the correct behaviour, if the user opens 
manually the dropdown all the values that comply with the where clause should 
be shown.

This happened because each time the picklist was shown, its values were 
retrieved filtering the selected value. Now if the user is manually opening the 
tree item, the result records will not be filtered by the selected record.

Also a couple of changes have been done in the getCriteriaFromTreeItem function:
- For the criteria the entered value (the text currently shown in the tree 
item) is used, instead of the selected value.
- A not-null check has been added for the valueMap of the item before trying to 
use it.

diffstat:

 
modules/org.openbravo.client.application/web/org.openbravo.client.application/js/form/formitem/ob-formitem-tree.js
 |  24 ++++++---
 1 files changed, 16 insertions(+), 8 deletions(-)

diffs (69 lines):

diff -r c4f2df763a97 -r 3ae59cee1ac2 
modules/org.openbravo.client.application/web/org.openbravo.client.application/js/form/formitem/ob-formitem-tree.js
--- 
a/modules/org.openbravo.client.application/web/org.openbravo.client.application/js/form/formitem/ob-formitem-tree.js
        Thu Feb 05 12:51:09 2015 +0100
+++ 
b/modules/org.openbravo.client.application/web/org.openbravo.client.application/js/form/formitem/ob-formitem-tree.js
        Thu Feb 05 12:33:34 2015 +0100
@@ -11,7 +11,7 @@
  * under the License.
  * The Original Code is Openbravo ERP.
  * The Initial Developer of the Original Code is Openbravo SLU
- * All portions are Copyright (C) 2013-2014 Openbravo SLU
+ * All portions are Copyright (C) 2013-2015 Openbravo SLU
  * All Rights Reserved.
  * Contributor(s):  ______________________________________.
  ************************************************************************
@@ -130,7 +130,9 @@
     if (this.tree.isVisible()) {
       this.tree.hide();
     } else {
-      this.tree.show();
+      // when the tree picker is opened manually, use an empty criterion not to
+      // filter the selected record (see issue 
https://issues.openbravo.com/view.php?id=28843)
+      this.tree.show(isc.OBRestDataSource.getDummyCriterion());
     }
   },
 
@@ -241,9 +243,9 @@
     }
   },
 
-  show: function () {
+  show: function (explicitCriteria) {
     this.updatePosition();
-    this.fetchData();
+    this.fetchData(explicitCriteria);
     this._pageClickID = this.ns.Page.setEvent('mouseDown', this, null, 
'clickOutsideTree');
     return this.Super('show', arguments);
   },
@@ -345,23 +347,29 @@
   },
 
   fetchData: function (criteria, callback, requestProperties) {
-    return this.Super('fetchData', [this.getCriteriaFromTreeItem(), callback, 
requestProperties]);
+    if (!criteria) {
+      // if no explicit criteria is provided, use the value entered in the 
tree item
+      criteria = this.getCriteriaFromTreeItem();
+    }
+    return this.Super('fetchData', [criteria, callback, requestProperties]);
   },
 
   getCriteriaFromTreeItem: function () {
-    var value = this.treeItem.getValue(),
+    var value = this.treeItem.getEnteredValue(),
         criteria = {};
     if (!value) {
       return null;
     }
-    if (OB.Utilities.isUUID(value)) {
+    if (OB.Utilities.isUUID(value) && this.treeItem.valueMap) {
       value = this.treeItem.valueMap[value] ? this.treeItem.valueMap[value] : 
value;
     }
     criteria.fieldName = this.getFields()[0].name;
     criteria.operator = 'iContains';
     criteria.value = value;
     return {
-      criteria: criteria
+      _constructor: "AdvancedCriteria",
+      operator: "and",
+      criteria: [criteria]
     };
   }
 });

------------------------------------------------------------------------------
Dive into the World of Parallel Programming. The Go Parallel Website,
sponsored by Intel and developed in partnership with Slashdot Media, is your
hub for all things parallel software development, from weekly thought
leadership blogs to news, videos, case studies, tutorials and more. Take a
look and join the conversation now. http://goparallel.sourceforge.net/
_______________________________________________
Openbravo-commits mailing list
Openbravo-commits@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/openbravo-commits

Reply via email to