fixes issue 32474: [object Object] appears after clearing value in selector
authorCarlos Aristu <carlos.aristu@openbravo.com>
Tue, 15 Mar 2016 19:12:36 +0100
changeset 28712 330cd48c5a70
parent 28711 8d0b0cebab04
child 28804 a58e284a2ce0
fixes issue 32474: [object Object] appears after clearing value in selector

Having singleDateMode as false after clearing the filter content of the date causes the return of an empty object in the getValuesAsCriteria method of the grid. The this.singleDateMode was being set to true in clearFilterValues function, but this statement was deleted to solve issue 31705, because it was preventing to show the range dialog after clearing the filters, when pressing the Enter key.

To solve both problems the change regarding setting singleDateMode in clearFilterValues has been reverted, and in order to ensure that the range dialog is displayed when it should be, a new check has been included in the keyPress method.
modules/org.openbravo.client.application/web/org.openbravo.client.application/js/form/formitem/ob-formitem-minidaterange.js
--- a/modules/org.openbravo.client.application/web/org.openbravo.client.application/js/form/formitem/ob-formitem-minidaterange.js	Mon Mar 14 10:42:09 2016 +0100
+++ b/modules/org.openbravo.client.application/web/org.openbravo.client.application/js/form/formitem/ob-formitem-minidaterange.js	Tue Mar 15 19:12:36 2016 +0100
@@ -459,6 +459,7 @@
   clearFilterValues: function () {
     this.singleDateValue = null;
     this.singleDateDisplayValue = '';
+    this.singleDateMode = true;
     this.rangeItemValue = null;
     this.rangeItem.setValue(null);
     this.setElementValue('', '');
@@ -725,11 +726,15 @@
   },
 
   keyPress: function (item, form, keyName, characterValue) {
+    var enterOnEmptyItem;
     if (keyName === 'Enter') {
       if (this.singleDateMode) {
+        enterOnEmptyItem = !item.getValue() && !item.getEnteredValue();
         this.expandSingleValue();
         this.form.grid.performAction();
-        return false;
+        if (!enterOnEmptyItem) {
+          return false;
+        }
       }
       this.showRangeDialog();
       return false;