Fixes issue 29612: FK filters with drop down disable behave like text filters
authorAugusto Mauch <augusto.mauch@openbravo.com>
Tue, 23 Jun 2015 11:50:57 +0200
changeset 27078 e9ae17759f2f
parent 27077 a9a39c837d3b
child 27079 809bf54dbb34
Fixes issue 29612: FK filters with drop down disable behave like text filters

If the "Disable Foreign Key Combo" grid configuration is enabled, then the filters of foreign key fields will not include a dropdown. In this case the filter will look like a standard text filter, so it ha
s been decided that is should act like one. This mean the following grid properties should work:
- Text Field Filter Behaviour. Allows to specify the default operator, no change was needed
- Threashold to Trigger Filter on Text Field. Prevents executing several requests to the datasource in short time span. No change was needed
- Filter On Change: Allows to specify if a filter datasource request should be done when the user types, before the filter editor loses the focus.

The changes done in this changeset fix the third case. The actOnKeypress property is set to true if the FilterOnChange grid config is enabled, otherwise the filter was only done when the filter editor lost
the focus. For this to work properly, another change was needed: the symbol of the default operator should not be shown in the filter editor.
modules/org.openbravo.client.application/web/org.openbravo.client.application/js/form/formitem/ob-formitem-fk-filter.js
modules/org.openbravo.client.kernel/src/org/openbravo/client/kernel/reference/ForeignKeyUIDefinition.java
--- a/modules/org.openbravo.client.application/web/org.openbravo.client.application/js/form/formitem/ob-formitem-fk-filter.js	Mon May 18 18:13:47 2015 +0200
+++ b/modules/org.openbravo.client.application/web/org.openbravo.client.application/js/form/formitem/ob-formitem-fk-filter.js	Tue Jun 23 11:50:57 2015 +0200
@@ -79,6 +79,9 @@
     if (this.disableFkDropdown) {
       this.showPickerIcon = false;
       this.showPickListOnKeypress = false;
+      if (this.filterOnChange) {
+        this.actOnKeypress = true;
+      }
     } else {
       this.pickListProperties = {
         // 'showOverAsSelected' and 'bodyKeyPress' defined here until issue 28475 be fixed.
@@ -529,10 +532,19 @@
           value = identifier;
         }
       }
-      if (criterion.operator !== "iContains" && criterion.operator !== "contains" && criterion.operator !== "regexp") {
-        if (operators[criterion.operator] && (operators[criterion.operator].ID === criterion.operator) && operators[criterion.operator].symbol && value && (value.indexOf(operators[criterion.operator].symbol) === -1)) {
+      if (this.disableFkDropdown) {
+        // if the fk dropdown is disabled then the filter must behave like a text filter
+        // that means that the symbol of the default operator is not shown
+        if (criterion.operator !== this.getOperator()) {
           value = operators[criterion.operator].symbol + value;
         }
+
+      } else {
+        if (criterion.operator !== "iContains" && criterion.operator !== "contains" && criterion.operator !== "regexp") {
+          if (operators[criterion.operator] && (operators[criterion.operator].ID === criterion.operator) && operators[criterion.operator].symbol && value && (value.indexOf(operators[criterion.operator].symbol) === -1)) {
+            value = operators[criterion.operator].symbol + value;
+          }
+        }
       }
       this.setValue(value);
     }
--- a/modules/org.openbravo.client.kernel/src/org/openbravo/client/kernel/reference/ForeignKeyUIDefinition.java	Mon May 18 18:13:47 2015 +0200
+++ b/modules/org.openbravo.client.kernel/src/org/openbravo/client/kernel/reference/ForeignKeyUIDefinition.java	Tue Jun 23 11:50:57 2015 +0200
@@ -66,6 +66,11 @@
     Boolean disableFkDropdown = (Boolean) readGridConfigurationSetting("disableFkDropdown");
     if (Boolean.TRUE.equals(disableFkDropdown)) {
       append = append + ", disableFkDropdown: " + disableFkDropdown.toString();
+      // if the fk drop down is disabled then the filter should behave like a text filter
+      // that means the filter could be trigger on editor change, if that configuration is enabled
+      if (Boolean.TRUE.equals(filterOnChange)) {
+        append = append + ", filterOnChange: " + filterOnChange.toString();
+      }
     } else {
       // these configurations only apply if the fk filter combo is enabled
       Boolean allowFkFilterByIdentifier = (Boolean) readGridConfigurationSetting("allowFkFilterByIdentifier");