[OBCQL] Visualization improvements to include the total number of rows.
authorGorka Ion Damián <gorkaion.damian@openbravo.com>
Wed, 12 Jan 2011 19:17:20 +0100
changeset 9746 b13641344c05
parent 9745 e87bcc4cd174
child 9747 f0b714bacbef
[OBCQL] Visualization improvements to include the total number of rows.
modules/org.openbravo.client.querylist/src-db/database/sourcedata/AD_MESSAGE.xml
modules/org.openbravo.client.querylist/web/org.openbravo.client.querylist/js/ob-querylist-widget.js
modules/org.openbravo.client.querylist/web/org.openbravo.userinterface.smartclient/openbravo/skins/3.00/org.openbravo.client.querylist/ob-querylist-styles.css
modules/org.openbravo.client.querylist/web/org.openbravo.userinterface.smartclient/openbravo/skins/3.00/org.openbravo.client.querylist/ob-querylist-styles.js
--- a/modules/org.openbravo.client.querylist/src-db/database/sourcedata/AD_MESSAGE.xml	Wed Jan 12 16:29:16 2011 +0100
+++ b/modules/org.openbravo.client.querylist/src-db/database/sourcedata/AD_MESSAGE.xml	Wed Jan 12 19:17:20 2011 +0100
@@ -1,5 +1,16 @@
 <?xml version='1.0' encoding='UTF-8'?>
 <data>
+<!--18EE399F2AF54EA3BEB5086D4BF6D4B1--><AD_MESSAGE>
+<!--18EE399F2AF54EA3BEB5086D4BF6D4B1-->  <AD_MESSAGE_ID><![CDATA[18EE399F2AF54EA3BEB5086D4BF6D4B1]]></AD_MESSAGE_ID>
+<!--18EE399F2AF54EA3BEB5086D4BF6D4B1-->  <AD_CLIENT_ID><![CDATA[0]]></AD_CLIENT_ID>
+<!--18EE399F2AF54EA3BEB5086D4BF6D4B1-->  <AD_ORG_ID><![CDATA[0]]></AD_ORG_ID>
+<!--18EE399F2AF54EA3BEB5086D4BF6D4B1-->  <ISACTIVE><![CDATA[Y]]></ISACTIVE>
+<!--18EE399F2AF54EA3BEB5086D4BF6D4B1-->  <VALUE><![CDATA[OBCQL_RowsNumber]]></VALUE>
+<!--18EE399F2AF54EA3BEB5086D4BF6D4B1-->  <MSGTEXT><![CDATA[Showing %0 of %1 rows.]]></MSGTEXT>
+<!--18EE399F2AF54EA3BEB5086D4BF6D4B1-->  <MSGTYPE><![CDATA[E]]></MSGTYPE>
+<!--18EE399F2AF54EA3BEB5086D4BF6D4B1-->  <AD_MODULE_ID><![CDATA[0A060B2AF1974E8EAA8DB61388E9AECC]]></AD_MODULE_ID>
+<!--18EE399F2AF54EA3BEB5086D4BF6D4B1--></AD_MESSAGE>
+
 <!--51E3AB93D32F488E896F1E03654B89F3--><AD_MESSAGE>
 <!--51E3AB93D32F488E896F1E03654B89F3-->  <AD_MESSAGE_ID><![CDATA[51E3AB93D32F488E896F1E03654B89F3]]></AD_MESSAGE_ID>
 <!--51E3AB93D32F488E896F1E03654B89F3-->  <AD_CLIENT_ID><![CDATA[0]]></AD_CLIENT_ID>
--- a/modules/org.openbravo.client.querylist/web/org.openbravo.client.querylist/js/ob-querylist-widget.js	Wed Jan 12 16:29:16 2011 +0100
+++ b/modules/org.openbravo.client.querylist/web/org.openbravo.client.querylist/js/ob-querylist-widget.js	Wed Jan 12 19:17:20 2011 +0100
@@ -30,6 +30,8 @@
   grid: null,
   gridProperties: {},
   viewMode: 'widget',
+  totalRows: null,
+  widgetTitle: null,
 
   showAllLabel: null,
   OBQueryListShowAllLabelHeight: null,
@@ -38,9 +40,12 @@
     this.showAllLabel = isc.HLayout.create({
       height: this.OBQueryListShowAllLabelHeight,
       members: [
-        isc.HLayout.create({
-          width: '100%'
+        isc.OBQueryListRowsNumberLabel.create({
+          contents: ''
         }),
+//        isc.HLayout.create({
+//          width: '100%'
+//        }),
         isc.OBQueryListShowAllLabel.create({
           contents: OB.I18N.getLabel('OBCQL_ShowAll'),
           widget: this,
@@ -49,6 +54,7 @@
     ]
     });
     this.Super('initWidget', arguments);
+    this.widgetTitle = this.title;
     // refresh if the dbInstanceId is set
     if (this.dbInstanceId) {
       this.refresh();
@@ -69,7 +75,8 @@
                   this.grid.summaryRowHeight + 2;
     this.grid.setHeight(newGridHeight);
 
-    var newHeight = headerHeight + newGridHeight + 13 +  this.showAllLabel.height;
+    var newHeight = headerHeight + newGridHeight + 13;
+    if (this.showAllLabel.isVisible()) { newHeight += this.showAllLabel.height; }
     this.setHeight(newHeight);
     if (this.parentElement) {
       var heightDiff = newHeight - currentHeight,
@@ -130,7 +137,7 @@
   
   maximize: function() {
     OB.Layout.ViewManager.openView('OBQueryListView',  {
-      tabTitle: this.title,
+      tabTitle: this.widgetTitle,
       widgetInstanceId: this.dbInstanceId,
       widgetId: this.widgetId,
       fields: this.maximizedFields,
@@ -139,8 +146,25 @@
       menuItems: this.menuItems,
       fieldDefinitions: this.fieldDefinitions
     });
+  },
+  
+  setTotalRows: function(totalRows) {
+    this.totalRows = totalRows;
+    if (this.viewMode === 'maximized') {
+      this.setTitle(this.widgetTitle + " (" + this.totalRows + ")");
+    }
+    this.showAllLabel.getMembers()[0].setContents(
+        OB.I18N.getLabel('OBCQL_RowsNumber', [this.parameters.RowsNumber, this.totalRows])
+      );
+    if (this.parameters.showAll || this.totalRows <= this.parameters.RowsNumber) {
+      this.showAllLabel.hide();
+    } else {
+      this.showAllLabel.show();
+    }
+    if (this.viewMode === 'widget') {
+      this.setWidgetHeight();
+    }
   }
-  
 });
 
 isc.ClassFactory.defineClass('OBQueryListGrid', isc.OBGrid);
@@ -177,7 +201,18 @@
     crit.rowsNumber = this.widget.parameters.RowsNumber;
     crit.viewMode = this.widget.viewMode;
     crit.showAll = this.widget.parameters.showAll;
-    return this.Super('filterData', [crit, callback, reqProperties]);
+
+    reqProperties.clientContext = {grid: this,
+        criteria: crit}; 
+
+    var newCallBack = function(dsResponse, data, dsRequest){
+      dsResponse.clientContext.grid.getWidgetTotalRows(dsResponse, data, dsRequest);
+      if (callback) {
+        callback();
+      }
+    };
+
+    return this.Super('filterData', [crit, newCallBack, reqProperties]);
   },
   
   fetchData: function(criteria, callback, requestProperties){
@@ -189,7 +224,18 @@
     crit.rowsNumber = this.widget.parameters.RowsNumber;
     crit.viewMode = this.widget.viewMode;
     crit.showAll = this.widget.parameters.showAll;
-    return this.Super('fetchData', [crit, callback, reqProperties]);
+
+    reqProperties.clientContext = {grid: this,
+                                   criteria: crit}; 
+
+    var newCallBack = function(dsResponse, data, dsRequest){
+      dsResponse.clientContext.grid.getWidgetTotalRows(dsResponse, data, dsRequest);
+      if (callback) {
+        callback();
+      }
+    };
+
+    return this.Super('fetchData', [crit, newCallBack, reqProperties]);
   },
 
   cellClick: function (record, rowNum, colNum) {
@@ -207,5 +253,22 @@
         });
       }
     }
+  },
+
+  getWidgetTotalRows: function(dsResponse, data, dsRequest){
+    if (this.widget.viewMode === 'widget' && !this.widget.parameters.showAll) {
+      var criteria = dsResponse.clientContext.criteria || {},
+          requestProperties = {};
+      requestProperties.showPrompt = false;
+      requestProperties.clientContext = {grid: this};
+
+      criteria.showAll = true;
+      this.dataSource.fetchData(criteria, function(dsResponse, data, dsRequest){
+          dsResponse.clientContext.grid.widget.setTotalRows(dsResponse.totalRows);
+        }, requestProperties );
+
+    } else {
+      this.widget.setTotalRows(dsResponse.totalRows);
+    }
   }
 });
--- a/modules/org.openbravo.client.querylist/web/org.openbravo.userinterface.smartclient/openbravo/skins/3.00/org.openbravo.client.querylist/ob-querylist-styles.css	Wed Jan 12 16:29:16 2011 +0100
+++ b/modules/org.openbravo.client.querylist/web/org.openbravo.userinterface.smartclient/openbravo/skins/3.00/org.openbravo.client.querylist/ob-querylist-styles.css	Wed Jan 12 19:17:20 2011 +0100
@@ -46,4 +46,12 @@
 .OBQueryListShowAllLabelFocusedDown {
   color: #004E27;
   text-decoration: underline;
+}
+
+.OBQueryListRowsNumberLabel {
+  font-family: 'lucida sans', sans-serif;
+  vertical-align: middle;
+  background: transparent;
+  text-align: left;
+  color: #00A651;
 }
\ No newline at end of file
--- a/modules/org.openbravo.client.querylist/web/org.openbravo.userinterface.smartclient/openbravo/skins/3.00/org.openbravo.client.querylist/ob-querylist-styles.js	Wed Jan 12 16:29:16 2011 +0100
+++ b/modules/org.openbravo.client.querylist/web/org.openbravo.userinterface.smartclient/openbravo/skins/3.00/org.openbravo.client.querylist/ob-querylist-styles.js	Wed Jan 12 19:17:20 2011 +0100
@@ -34,4 +34,17 @@
   height: 20,
   wrap: false,
   width: '*'
+});
+
+isc.ClassFactory.defineClass('OBQueryListRowsNumberLabel', isc.Label);
+
+isc.OBQueryListRowsNumberLabel.addProperties({
+  className: 'OBQueryListRowsNumberLabel',
+  showDown: false,
+  showFocused: false,
+  showFocusedAsOver: false,
+  showRollOver: false,
+  height: 20,
+  wrap: false,
+  width: '*'
 });
\ No newline at end of file