Related to issue 30812: Improve the functions.
authorNaroa Iriarte <naroa.iriarte@openbravo.com>
Fri, 25 Sep 2015 14:32:13 +0200
changeset 27763 8a4a90af8109
parent 27762 48eb02e9f5f7
child 27841 c3cbd0206e45
child 28625 a84ee9e96086
Related to issue 30812: Improve the functions.

The function filterDialogCallback of the "ob-formitem-tree-filter.js" is improved.
This function calls the "updateCriterion" function which updates the criterion of
the tree filter deleting the old criterion and adding the new criterion.
The crieteria of the rest of the columns in the grid is taken into account.
modules/org.openbravo.client.application/web/org.openbravo.client.application/js/form/formitem/ob-formitem-tree-filter.js
--- a/modules/org.openbravo.client.application/web/org.openbravo.client.application/js/form/formitem/ob-formitem-tree-filter.js	Thu Sep 24 15:50:19 2015 +0200
+++ b/modules/org.openbravo.client.application/web/org.openbravo.client.application/js/form/formitem/ob-formitem-tree-filter.js	Fri Sep 25 14:32:13 2015 +0200
@@ -302,35 +302,22 @@
     }
   },
 
-  filterDialogCallback: function (criteria) {
-    var finalCriteria, theCriteria;
-    this.setCurrentCriterion(criteria);
-    theCriteria = this.grid.parentElement.getFilterEditorCriteria();
-    if (theCriteria && theCriteria.criteria) {
-      finalCriteria = theCriteria;
-    } else {
-      if (criteria.operator === 'or') {
-        finalCriteria = {};
-        finalCriteria.operator = "and";
-        finalCriteria._constructor = "AdvancedCriteria";
-        finalCriteria.criteria = [];
-        finalCriteria = theCriteria;
-      } else {
-        finalCriteria = criteria;
-      }
-    }
-    this.grid.parentElement.setFilterEditorCriteria(finalCriteria);
+  filterDialogCallback: function (criterion) {
+    this.updateCriterion(criterion);
     this.lastValueFromPopup = this.getValue();
     this.form.grid.performAction();
   },
 
-  setCurrentCriterion: function (criteria) {
-    if (!criteria.criteria) {
+  //This function updates the criterion of the tree filter, deletes the old
+  //criterion and adds the new criterion.
+  updateCriterion: function (criterion) {
+    if (!criterion.criteria) {
       this.setValue(null);
     } else {
-      this.setCriterion(criteria);
+      this.setCriterion(criterion);
     }
   },
+
   init: function () {
     var field;
     this.pickerIconSrc = OB.Styles.OBFormField.DefaultSearch.pickerIconSrc;