details:   https://code.openbravo.com/erp/devel/pi/rev/0c740ea71313
changeset: 35034:0c740ea71313
user:      Atul Gaware <atul.gaware <at> openbravo.com>
date:      Wed Jul 22 10:25:06 2015 +0530
summary:   Fixes Issue 29314:Clicking select all and after that unselect all 
records in
Credit to Use grid in AddPayment window has performance issues

The problem was that on every selection/deselection of record in creditUseGrid
it was triggering the execution of these three methods:
* OB.APRM.AddPayment.updateCreditTotal(view.theForm);
* OB.APRM.AddPayment.updateActualExpected(view.theForm);
* OB.APRM.AddPayment.distributeAmount(view, view.theForm, true);

Actually it is not necessary to execute these functions on every record, because
in the end they are updating total values, so just executing them after the
iteration of the last record selected/deselected it would be enough.

To implement this, 'userSelectAllRecords' and 'deselectAllRecords' ListGrid
methods have been overriden, to set a flag to true, in order to know when a
record is changed while clicking selected/deselect all records, and in this
case the three methods will be executed in the last record of the grid.
The 'OB.APRM.AddPayment.userSelectAllRecords' is executed only when clicking
in select all records checkbox, but 'OB.APRM.AddPayment.deselectAllRecords' is
executed while unchecking the previous checkbox and when fetching data in the
grid using 'invalidateCache()' method. In this last case these functions will
not be executed on every deselection neither in the last record, because they
are already invoked directly in 'invalidateCache()', so in this case they will
be avoided.

While executing invalidateCache() function to reload CreditUse grid it
internally calls to 'OB.APRM.AddPayment.deselectAllRecords' overriden method
that sets obaprmAllRecordsSelectedByUser property to true. This property is
only needed when manually the select/unselect all checkbox is clicked.In order
to avoid this in creditOnLoadGrid function, if the property
'obaprmAllRecordsSelectedByUser' exists, it will be deleted.

details:   https://code.openbravo.com/erp/devel/pi/rev/b08cf6ab13a4
changeset: 35035:b08cf6ab13a4
user:      Sandra Huguet <sandra.huguet <at> openbravo.com>
date:      Mon Nov 19 12:28:51 2018 +0100
summary:   related to issue 29314 code review: apply formatting

diffstat:

 
modules/org.openbravo.advpaymentmngt/web/org.openbravo.advpaymentmngt/js/ob-aprm-addPayment.js
 |  15 +++++++--
 1 files changed, 11 insertions(+), 4 deletions(-)

diffs (39 lines):

diff -r 2f2207a2ba72 -r b08cf6ab13a4 
modules/org.openbravo.advpaymentmngt/web/org.openbravo.advpaymentmngt/js/ob-aprm-addPayment.js
--- 
a/modules/org.openbravo.advpaymentmngt/web/org.openbravo.advpaymentmngt/js/ob-aprm-addPayment.js
    Mon Nov 19 12:23:31 2018 +0100
+++ 
b/modules/org.openbravo.advpaymentmngt/web/org.openbravo.advpaymentmngt/js/ob-aprm-addPayment.js
    Mon Nov 19 12:28:51 2018 +0100
@@ -128,6 +128,8 @@
   orderInvoiceGrid.dataProperties.transformData = 
OB.APRM.AddPayment.ordInvTransformData;
   glitemGrid.removeRecordClick = OB.APRM.AddPayment.removeRecordClick;
   creditUseGrid.selectionChanged = OB.APRM.AddPayment.selectionChangedCredit;
+  creditUseGrid.userSelectAllRecords = OB.APRM.AddPayment.userSelectAllRecords;
+  creditUseGrid.deselectAllRecords = OB.APRM.AddPayment.deselectAllRecords;
   orderInvoiceGrid.dataArrived = OB.APRM.AddPayment.ordInvDataArrived;
 
   form.isCreditAllowed = form.getItem('received_from').getValue() !== 
undefined && form.getItem('received_from').getValue() !== null;
@@ -336,6 +338,9 @@
 
 OB.APRM.AddPayment.creditOnLoadGrid = function (grid) {
   grid.isReady = true;
+  if (grid.obaprmAllRecordsSelectedByUser) {
+    delete grid.obaprmAllRecordsSelectedByUser;
+  }
   OB.APRM.AddPayment.updateCreditTotal(this.view.theForm);
   OB.APRM.AddPayment.tryToUpdateActualExpected(this.view.theForm);
 };
@@ -843,10 +848,12 @@
   } else {
     grid.setEditValue(grid.getRecordIndex(record), amountField, '0');
   }
-  OB.APRM.AddPayment.updateCreditTotal(view.theForm);
-  OB.APRM.AddPayment.updateActualExpected(view.theForm);
-  if (issotrx) {
-    OB.APRM.AddPayment.distributeAmount(view, view.theForm, true);
+  if (!grid.obaprmAllRecordsSelectedByUser || 
(grid.obaprmAllRecordsSelectedByUser && (grid.getRecordIndex(record) === 
grid.getTotalRows() - 1))) {
+    OB.APRM.AddPayment.updateCreditTotal(view.theForm);
+    OB.APRM.AddPayment.updateActualExpected(view.theForm);
+    if (issotrx) {
+      OB.APRM.AddPayment.distributeAmount(view, view.theForm, true);
+    }
   }
 };
 


_______________________________________________
Openbravo-commits mailing list
Openbravo-commits@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/openbravo-commits

Reply via email to