Fixed issue 29978: Enable tree reference selectors in Pick & Exectute windows.
authorNaroa Iriarte <naroa.iriarte@openbravo.com>
Wed, 24 Jun 2015 16:56:47 +0200
changeset 27066 f6dcfa9328cf
parent 27065 e45f0f903a95
child 27067 2268a549839c
Fixed issue 29978: Enable tree reference selectors in Pick & Exectute windows.

It was not possible to use tree reference selectors in the pick & execute windows.

To enable this the "ob-formitem-tree-filter.js" has been changed.
Before, there was a function which copied the functions from the view grid, the problem was that this
doesn't exist for the Pick and Execute windows.

Now, it takes into account the pick and execute windows, this has been done by a
condition which checks if "paramWindow" is true, which means that is a pick and execute window.

A new function has been developed too, for granting the correct behavior of this new functionality.
This function, copies some functions from the grid of the pick and execute windows.
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 Jun 25 17:04:28 2015 +0200
+++ b/modules/org.openbravo.client.application/web/org.openbravo.client.application/js/form/formitem/ob-formitem-tree-filter.js	Wed Jun 24 16:56:47 2015 +0200
@@ -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):  ______________________________________.
  ************************************************************************
@@ -75,24 +75,36 @@
       sortField: this.displayField,
 
       init: function () {
+        var theGrid;
         OB.Datasource.get(this.dataSourceId, this, null, true);
-        this.copyFunctionsFromViewGrid();
+        if (this.view.paramWindow) {
+          // the checkShowFilterFunnelIcon implementation of OBPickAndExecuteGrid requires the contentView to be defined
+          theGrid = this.view.theForm.getField(this.treePopup.filterItem.containerWidget.grid.parentElement.parameterName).canvas.viewGrid;
+          this.contentView = theGrid.contentView;
+          this.copyFunctionsFromGrid(theGrid);
+        } else {
+          this.copyFunctionsFromViewGrid();
+        }
         this.Super('init', arguments);
         this.filterNoRecordsEmptyMessage = '<span class="' + this.emptyMessageStyle + '">' + OB.I18N.getLabel('OBUIAPP_GridFilterNoResults') + '</span>' + '<span onclick="window[\'' + this.ID + '\'].clearFilter();" class="' + this.emptyMessageLinkStyle + '">' + OB.I18N.getLabel('OBUIAPP_GridClearFilter') + '</span>';
       },
 
       copyFunctionsFromViewGrid: function () {
-        this.filterEditorProperties = this.view.viewGrid.filterEditorProperties;
-        this.checkShowFilterFunnelIcon = this.view.viewGrid.checkShowFilterFunnelIcon;
-        this.isGridFiltered = this.view.viewGrid.isGridFiltered;
-        this.isGridFilteredWithCriteria = this.view.viewGrid.isGridFilteredWithCriteria;
-        this.isValidFilterField = this.view.viewGrid.isValidFilterField;
-        this.convertCriteria = this.view.viewGrid.convertCriteria;
-        this.resetEmptyMessage = this.view.viewGrid.resetEmptyMessage;
-        this.filterData = this.view.viewGrid.filterData;
-        this.loadingDataMessage = this.view.viewGrid.loadingDataMessage;
-        this.emptyMessage = this.view.viewGrid.emptyMessage;
-        this.noDataEmptyMessage = this.view.viewGrid.noDataEmptyMessage;
+        this.copyFunctionsFromGrid(this.view.viewGrid);
+      },
+
+      copyFunctionsFromGrid: function (grid) {
+        this.filterEditorProperties = grid.filterEditorProperties;
+        this.checkShowFilterFunnelIcon = grid.checkShowFilterFunnelIcon;
+        this.isGridFiltered = grid.isGridFiltered;
+        this.isGridFilteredWithCriteria = grid.isGridFilteredWithCriteria;
+        this.isValidFilterField = grid.isValidFilterField;
+        this.convertCriteria = grid.convertCriteria;
+        this.resetEmptyMessage = grid.resetEmptyMessage;
+        this.filterData = grid.filterData;
+        this.loadingDataMessage = grid.loadingDataMessage;
+        this.emptyMessage = grid.emptyMessage;
+        this.noDataEmptyMessage = grid.noDataEmptyMessage;
       },
 
       onFetchData: function (criteria, requestProperties) {
@@ -274,6 +286,7 @@
   filterDialogConstructor: isc.OBTreeItemPopupFilterWindow,
   lastValueFromPopup: null,
   pickerConstructor: 'ImgButton',
+  allowExpressions: true,
   pickerIconDefaults: {
     name: 'showDateRange',
     width: 21,