details:   https://code.openbravo.com/erp/devel/pi/rev/54e2948eb10b
changeset: 32846:54e2948eb10b
user:      Carlos Aristu <carlos.aristu <at> openbravo.com>
date:      Tue Sep 26 12:41:49 2017 +0200
summary:   fixes bug 36927: Multiple DS requests having a date item as first 
focused item

  When directly opening a record in a tab which has a date item as the first 
focused item, extra DS calls were fired which could prevent the record to be 
opened properly (the form displayed in blank)

  This has happening because a combination of different facts:

   - When the grid is redrawn, Smarclient fires an update of the first focused 
item. In the case of date items this causes that false item edition is fired 
because it detects that the value of the date item filter changes from 
undefined to empty string.

   - If the previous scenario happens while opening a record directly, the grid 
datasource detects that it needs to fetch data because at this point the number 
of cached rows is different from the total rows (see [1]).

  To avoid those extra DS requests we now ignore those false item editions 
while a target record is being opened.

[1] 
https://code.openbravo.com/erp/mods/org.openbravo.userinterface.smartclient.dev/file/66d2b640b66e/web/org.openbravo.userinterface.smartclient/isomorphic/client/application/ResultSet.js#l833

diffstat:

 
modules/org.openbravo.client.application/web/org.openbravo.client.application/js/form/formitem/ob-formitem-minidaterange.js
 |  12 ++++++++++
 1 files changed, 12 insertions(+), 0 deletions(-)

diffs (22 lines):

diff -r 900d0380bca9 -r 54e2948eb10b 
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
       Tue Oct 03 13:50:17 2017 +0200
+++ 
b/modules/org.openbravo.client.application/web/org.openbravo.client.application/js/form/formitem/ob-formitem-minidaterange.js
       Tue Sep 26 12:41:49 2017 +0200
@@ -667,6 +667,18 @@
     return this.Super('setElementValue', arguments);
   },
 
+  compareValues: function (value1, value2) {
+    if (this.isTargetRecordBeingOpened() && value1 === '' && value2 === 
undefined) {
+      // prevent extra DS requests when opening a record directly by ignoring 
false updates in the item value
+      return true;
+    }
+    return (0 === isc.Date.compareLogicalDates(value1, value2));
+  },
+
+  isTargetRecordBeingOpened: function () {
+    return this.grid && this.grid.parentElement && 
this.grid.parentElement.targetRecordId;
+  },
+
   mapDisplayToValue: function (display) {
     return display;
   },

------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
Openbravo-commits mailing list
Openbravo-commits@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/openbravo-commits

Reply via email to