← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 14932: ER, synced with new analytics syntax.

 

Merge authors:
  Jan Henrik Øverland (janhenrik-overland)
------------------------------------------------------------
revno: 14932 [merge]
committer: Jan Henrik Overland <janhenrik.overland@xxxxxxxxx>
branch nick: dhis2
timestamp: Mon 2014-04-21 20:19:28 +0200
message:
  ER, synced with new analytics syntax.
modified:
  dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/startup/TableAlteror.java
  dhis-2/dhis-web/dhis-web-event-reports/src/main/webapp/dhis-web-event-reports/app/scripts/app.js
  dhis-2/dhis-web/dhis-web-event-reports/src/main/webapp/dhis-web-event-reports/app/scripts/core.js


--
lp:dhis2
https://code.launchpad.net/~dhis2-devs-core/dhis2/trunk

Your team DHIS 2 developers is subscribed to branch lp:dhis2.
To unsubscribe from this branch go to https://code.launchpad.net/~dhis2-devs-core/dhis2/trunk/+edit-subscription
=== modified file 'dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/startup/TableAlteror.java'
--- dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/startup/TableAlteror.java	2014-04-21 11:05:22 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/startup/TableAlteror.java	2014-04-21 18:18:01 +0000
@@ -488,6 +488,8 @@
         executeSql( "update chart set userorganisationunitchildren = false where userorganisationunitchildren is null" );
         executeSql( "update chart set userorganisationunitgrandchildren = false where userorganisationunitgrandchildren is null" );
         executeSql( "update chart set hidetitle = false where hidetitle is null" );
+        
+        executeSql( "update eventreport set showhierarchy = false where showhierarchy is null" );
 
         // Move chart filters to chart_filters table
 

=== modified file 'dhis-2/dhis-web/dhis-web-event-reports/src/main/webapp/dhis-web-event-reports/app/scripts/app.js'
--- dhis-2/dhis-web/dhis-web-event-reports/src/main/webapp/dhis-web-event-reports/app/scripts/app.js	2014-04-14 22:02:30 +0000
+++ dhis-2/dhis-web/dhis-web-event-reports/src/main/webapp/dhis-web-event-reports/app/scripts/app.js	2014-04-21 18:18:01 +0000
@@ -3674,8 +3674,6 @@
 					}
 				}
 			}
-
-			console.log(recordMap);
         };
 
         dataElement = Ext.create('Ext.panel.Panel', {

=== modified file 'dhis-2/dhis-web/dhis-web-event-reports/src/main/webapp/dhis-web-event-reports/app/scripts/core.js'
--- dhis-2/dhis-web/dhis-web-event-reports/src/main/webapp/dhis-web-event-reports/app/scripts/core.js	2014-04-14 20:13:04 +0000
+++ dhis-2/dhis-web/dhis-web-event-reports/src/main/webapp/dhis-web-event-reports/app/scripts/core.js	2014-04-21 18:18:01 +0000
@@ -602,6 +602,22 @@
 				return array;
 			};
 
+            support.prototype.array.uniqueByProperty = function(array, property) {
+                var names = [],
+                    uniqueItems = [];
+
+                for (var i = 0, item; i < array.length; i++) {
+                    item = array[i];
+
+                    if (!Ext.Array.contains(names, item[property])) {
+                        uniqueItems.push(item);
+                        names.push(item[property]);
+                    }
+                }
+
+                return uniqueItems;
+            };
+
 				// object
 			support.prototype.object = {};
 
@@ -878,6 +894,8 @@
 
 				// columns, rows, filters
 				if (layout.columns) {
+                    layout.columns = support.prototype.array.uniqueByProperty(layout.columns, 'dimension');
+
 					for (var i = 0, dim, items, xDim; i < layout.columns.length; i++) {
 						dim = layout.columns[i];
 						items = dim.items;
@@ -914,6 +932,8 @@
 				}
 
 				if (layout.rows) {
+                    layout.rows = support.prototype.array.uniqueByProperty(layout.rows, 'dimension');
+
 					for (var i = 0, dim, items, xDim; i < layout.rows.length; i++) {
 						dim = Ext.clone(layout.rows[i]);
 						items = dim.items;
@@ -950,6 +970,8 @@
 				}
 
 				if (layout.filters) {
+                    layout.filters = support.prototype.array.uniqueByProperty(layout.filters, 'dimension');
+
 					for (var i = 0, dim, items, xDim; i < layout.filters.length; i++) {
 						dim = layout.filters[i];
 						items = dim.items;
@@ -1775,7 +1797,8 @@
                     dataTypeMap = {
                         'aggregated_values': 'aggregate',
                         'individual_cases': 'query'
-                    };
+                    },
+                    nameItemsMap;
 
                 format = format || 'json';
 
@@ -1786,6 +1809,8 @@
 
                 // dimensions
                 if (dimensions) {
+                    nameItemsMap = {};
+
 					for (var i = 0, dim; i < dimensions.length; i++) {
 						dim = dimensions[i];
 
@@ -1793,20 +1818,38 @@
 							continue;
 						}
 
-						paramString += '&dimension=' + dim.dimension;
-
-						if (dim.items && dim.items.length) {
-							paramString += ':';
-
-							for (var j = 0, item; j < dim.items.length; j++) {
-								item = dim.items[j];
-
-								paramString += encodeURIComponent(item.id) + ((j < (dim.items.length - 1)) ? ';' : '');
-							}
-						}
-						else if (dim.operator && !Ext.isEmpty(dim.filter)) {
-							paramString += ':' + dim.operator + ':' + encodeURIComponent(dim.filter);
-						}
+                        if (!nameItemsMap[dim.dimension]) {
+                            nameItemsMap[dim.dimension] = [];
+                        }
+
+                        nameItemsMap[dim.dimension].push(dim);
+                    }
+
+                    for (var key in nameItemsMap) {
+                        var dimArray;
+
+                        if (nameItemsMap.hasOwnProperty(key)) {
+                            dimArray = nameItemsMap[key];
+
+                            paramString += '&dimension=' + key;
+
+                            for (var i = 0, dim; i < dimArray.length; i++) {
+                                dim = dimArray[i];
+
+                                if (dim.items && dim.items.length) {
+                                    paramString += ':';
+
+                                    for (var j = 0, item; j < dim.items.length; j++) {
+                                        item = dim.items[j];
+
+                                        paramString += encodeURIComponent(item.id) + ((j < (dim.items.length - 1)) ? ';' : '');
+                                    }
+                                }
+                                else if (dim.operator && !Ext.isEmpty(dim.filter)) {
+                                    paramString += ':' + dim.operator + ':' + encodeURIComponent(dim.filter);
+                                }
+                            }
+                        }
 					}
 				}