fixes issue 31634: use refresh button in Alert Management more than once
authorCarlos Aristu <carlos.aristu@openbravo.com>
Tue, 01 Dec 2015 19:25:04 +0100
changeset 28081 2a53c3dbf6a3
parent 28079 83f6116ba55b
child 28082 266c95c57617
fixes issue 31634: use refresh button in Alert Management more than once

A new mechanism is created for the grids in Alert Management window which notifies to the view that the data has arrived after a refresh request. The view checks if the refresh has been performed by the four grids before enabling the button again.
modules/org.openbravo.client.application/web/org.openbravo.client.application/js/alert-management/ob-alert-grid.js
modules/org.openbravo.client.application/web/org.openbravo.client.application/js/alert-management/ob-alert-management-view.js
--- a/modules/org.openbravo.client.application/web/org.openbravo.client.application/js/alert-management/ob-alert-grid.js	Tue Dec 01 18:27:51 2015 +0100
+++ b/modules/org.openbravo.client.application/web/org.openbravo.client.application/js/alert-management/ob-alert-grid.js	Tue Dec 01 19:25:04 2015 +0100
@@ -37,6 +37,7 @@
   showCellContextMenus: true,
   selectOnEdit: false,
   dataPageSize: 100,
+  isRefreshing: false,
 
   arrowKeyAction: 'select',
 
@@ -155,6 +156,11 @@
 
   dataArrived: function (startRow, endRow) {
     this.getGridTotalRows();
+    // we notify the data arrival so the view can check if the refresh button can be enabled
+    if (this.isRefreshing) {
+      this.isRefreshing = false;
+      OB.AlertManagement.notifyRefreshEnd();
+    }
     return this.Super('dataArrived', arguments);
   },
 
--- a/modules/org.openbravo.client.application/web/org.openbravo.client.application/js/alert-management/ob-alert-management-view.js	Tue Dec 01 18:27:51 2015 +0100
+++ b/modules/org.openbravo.client.application/web/org.openbravo.client.application/js/alert-management/ob-alert-management-view.js	Tue Dec 01 19:25:04 2015 +0100
@@ -73,9 +73,11 @@
       }
     }, 'setTranslatedStatus');
 
+    this.refreshButton = isc.OBToolbarIconButton.create(isc.OBToolbar.REFRESH_BUTTON_PROPERTIES);
+
     this.addMember(isc.OBToolbar.create({
       view: this,
-      leftMembers: [isc.OBToolbarIconButton.create(isc.OBToolbar.REFRESH_BUTTON_PROPERTIES)],
+      leftMembers: [this.refreshButton],
       rightMembers: []
     }));
 
@@ -268,6 +270,22 @@
       if (!OB.AlertManagement.sections[alertStatus[i]].expanded) {
         OB.AlertManagement.grids[alertStatus[i]].getGridTotalRows();
       }
+      if (OB.AlertManagement.grids[alertStatus[i]].isDrawn()) {
+        OB.AlertManagement.grids[alertStatus[i]].isRefreshing = true;
+      }
+    }
+  },
+
+  notifyRefreshEnd: function () {
+    var i, alertStatus = ['New', 'Acknowledged', 'Suppressed', 'Solved'];
+    for (i = 0; i < 4; i++) {
+      if (OB.AlertManagement.grids[alertStatus[i]].isRefreshing) {
+        return;
+      }
+    }
+    if (this.isRefreshing) {
+      delete this.isRefreshing;
+      this.refreshButton.setDisabled(false);
     }
   }
 });