=== modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/eventreport/EventReport.java' --- dhis-2/dhis-api/src/main/java/org/hisp/dhis/eventreport/EventReport.java 2014-04-14 21:14:18 +0000 +++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/eventreport/EventReport.java 2014-05-12 23:03:35 +0000 @@ -61,6 +61,10 @@ public static final String DATA_TYPE_INDIVIDUAL_CASES = "individual_cases"; + public static final String COUNT_TYPE_EVENTS = "events"; + + public static final String COUNT_TYPE_TRACKED_ENTITY_INSTANCES = "tracked_entity_instances"; + /** * Program. Required. */ @@ -112,6 +116,11 @@ private boolean subtotals; /** + * Indicates count type. + */ + private String countType; + + /** * Indicates rendering of empty rows for the table. */ private boolean hideEmptyRows; @@ -191,6 +200,7 @@ totals = report.isTotals(); subtotals = report.isSubtotals(); hideEmptyRows = report.isHideEmptyRows(); + countType = report.getCountType(); showHierarchy = report.isShowHierarchy(); displayDensity = report.getDisplayDensity(); fontSize = report.getFontSize(); @@ -361,6 +371,19 @@ @JsonProperty @JsonView( { DetailedView.class, ExportView.class, DimensionalView.class } ) @JacksonXmlProperty( namespace = DxfNamespaces.DXF_2_0 ) + public String getCountType() + { + return countType; + } + + public void setCountType( String countType ) + { + this.countType = countType; + } + + @JsonProperty + @JsonView( { DetailedView.class, ExportView.class, DimensionalView.class } ) + @JacksonXmlProperty( namespace = DxfNamespaces.DXF_2_0 ) public boolean isShowHierarchy() { return showHierarchy; === 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 18:18:01 +0000 +++ dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/startup/TableAlteror.java 2014-05-11 15:39:09 +0000 @@ -490,6 +490,7 @@ executeSql( "update chart set hidetitle = false where hidetitle is null" ); executeSql( "update eventreport set showhierarchy = false where showhierarchy is null" ); + executeSql( "update eventreport set counttype = 'events' where counttype is null" ); // Move chart filters to chart_filters table === modified file 'dhis-2/dhis-services/dhis-service-tracker/src/main/resources/org/hisp/dhis/eventreport/EventReport.hbm.xml' --- dhis-2/dhis-services/dhis-service-tracker/src/main/resources/org/hisp/dhis/eventreport/EventReport.hbm.xml 2014-04-13 20:08:51 +0000 +++ dhis-2/dhis-services/dhis-service-tracker/src/main/resources/org/hisp/dhis/eventreport/EventReport.hbm.xml 2014-05-11 15:39:09 +0000 @@ -112,6 +112,8 @@ + + === modified file 'dhis-2/dhis-web/dhis-web-event-reports/src/main/resources/org/hisp/dhis/eventreport/i18n_module.properties' --- dhis-2/dhis-web/dhis-web-event-reports/src/main/resources/org/hisp/dhis/eventreport/i18n_module.properties 2014-04-09 11:45:21 +0000 +++ dhis-2/dhis-web/dhis-web-event-reports/src/main/resources/org/hisp/dhis/eventreport/i18n_module.properties 2014-05-12 23:03:35 +0000 @@ -155,4 +155,7 @@ start_end_dates=Start-end dates top=Top bottom=Bottom -limit=Limit \ No newline at end of file +limit=Limit +events=Events +tracked_entity_instances=Tracked entity instances +count_type=Count type \ No newline at end of file === modified file 'dhis-2/dhis-web/dhis-web-event-reports/src/main/webapp/dhis-web-event-reports/app/i18n.json' --- dhis-2/dhis-web/dhis-web-event-reports/src/main/webapp/dhis-web-event-reports/app/i18n.json 2014-04-09 11:45:21 +0000 +++ dhis-2/dhis-web/dhis-web-event-reports/src/main/webapp/dhis-web-event-reports/app/i18n.json 2014-05-12 23:03:35 +0000 @@ -155,5 +155,8 @@ "start_end_dates", "top", "bottom", -"limit" +"limit", +"events", +"tracked_entity_instances", +"count_type" ] === 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-05-06 12:23:34 +0000 +++ dhis-2/dhis-web/dhis-web-event-reports/src/main/webapp/dhis-web-event-reports/app/scripts/app.js 2014-05-12 23:03:35 +0000 @@ -819,11 +819,14 @@ this.activateCmp.setValue(!!(sortOrder > 0 && topLimit > 0)); }, initComponent: function() { - var container = this; + var container = this, + activateWidth = 135, + sortWidth = (this.comboboxWidth - activateWidth) / 2; + this.activateCmp = Ext.create('Ext.form.field.Checkbox', { boxLabel: container.boxLabel, - width: 135, + width: activateWidth, style: 'margin-bottom:4px', listeners: { change: function(cmp, newValue) { @@ -835,7 +838,7 @@ this.sortOrderCmp = Ext.create('Ext.form.field.ComboBox', { cls: 'ns-combo', style: 'margin-bottom:2px', - width: 70, + width: sortWidth, queryMode: 'local', valueField: 'id', editable: false, @@ -850,7 +853,7 @@ }); this.topLimitCmp = Ext.create('Ext.form.field.Number', { - width: 56, + width: sortWidth - 1, style: 'margin-bottom:2px; margin-left:1px', minValue: 1, maxValue: 10000, @@ -1556,6 +1559,8 @@ var showTotals, showSubTotals, hideEmptyRows, + limit, + countType, aggregationType, showHierarchy, digitGroupSeparator, @@ -1569,7 +1574,7 @@ style, parameters, - comboboxWidth = 262, + comboboxWidth = 280, window; showTotals = Ext.create('Ext.form.field.Checkbox', { @@ -1593,9 +1598,30 @@ limit = Ext.create('Ext.ux.container.LimitContainer', { boxLabel: NS.i18n.limit, sortOrder: 1, - topLimit: 10 + topLimit: 10, + comboboxWidth: comboboxWidth }); + countType = Ext.create('Ext.form.field.ComboBox', { + cls: 'ns-combo', + style: 'margin-bottom:2px', + width: comboboxWidth, + labelWidth: 130, + fieldLabel: NS.i18n.count_type, + labelStyle: 'color:#333', + queryMode: 'local', + valueField: 'id', + editable: false, + value: 'events', + store: Ext.create('Ext.data.Store', { + fields: ['id', 'text'], + data: [ + {id: 'events', text: NS.i18n.events}, + {id: 'tracked_entity_instances', text: NS.i18n.tracked_entity_instances} + ] + }) + }); + showHierarchy = Ext.create('Ext.form.field.Checkbox', { boxLabel: NS.i18n.show_hierarchy, style: 'margin-bottom:4px' @@ -1684,7 +1710,8 @@ showTotals, showSubTotals, hideEmptyRows, - limit + limit, + countType //aggregationType ] }; @@ -1723,6 +1750,7 @@ hideEmptyRows: hideEmptyRows.getValue(), sortOrder: limit.getSortOrder(), topLimit: limit.getTopLimit(), + countType: countType.getValue(), showHierarchy: showHierarchy.getValue(), displayDensity: displayDensity.getValue(), fontSize: fontSize.getValue(), @@ -1735,6 +1763,7 @@ showSubTotals.setValue(Ext.isBoolean(layout.showSubTotals) ? layout.showSubTotals : true); hideEmptyRows.setValue(Ext.isBoolean(layout.hideEmptyRows) ? layout.hideEmptyRows : false); limit.setValues(layout.sortOrder, layout.topLimit); + countType.setValue(Ext.isString(layout.countType) ? layout.countType : 'events'); //aggregationType.setValue(Ext.isString(layout.aggregationType) ? layout.aggregationType : 'default'); showHierarchy.setValue(Ext.isBoolean(layout.showHierarchy) ? layout.showHierarchy : false); displayDensity.setValue(Ext.isString(layout.displayDensity) ? layout.displayDensity : 'normal'); @@ -1818,6 +1847,7 @@ w.showSubTotals = showSubTotals; w.hideEmptyRows = hideEmptyRows; w.limit = limit; + w.countType = countType; w.showHierarchy = showHierarchy; w.displayDensity = displayDensity; w.fontSize = fontSize; @@ -1842,7 +1872,7 @@ style, parameters, - comboboxWidth = 262, + comboboxWidth = 280, window; //showHierarchy = Ext.create('Ext.form.field.Checkbox', { === 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-05-10 16:06:42 +0000 +++ dhis-2/dhis-web/dhis-web-event-reports/src/main/webapp/dhis-web-event-reports/app/scripts/core.js 2014-05-12 23:03:35 +0000 @@ -270,6 +270,8 @@ // hideEmptyRows: boolean (false) + // countType: string ('events') - 'events', 'tracked_entity_instance' + // aggregationType: string ('default') - 'default', 'count', 'sum' // showHierarchy: boolean (false) @@ -434,6 +436,7 @@ layout.showTotals = Ext.isBoolean(config.totals) ? config.totals : (Ext.isBoolean(config.showTotals) ? config.showTotals : true); layout.showSubTotals = Ext.isBoolean(config.subtotals) ? config.subtotals : (Ext.isBoolean(config.showSubTotals) ? config.showSubTotals : true); layout.hideEmptyRows = Ext.isBoolean(config.hideEmptyRows) ? config.hideEmptyRows : false; + layout.countType = Ext.isString(config.countType) && !Ext.isEmpty(config.countType) ? config.countType : 'events'; layout.aggregationType = Ext.isString(config.aggregationType) ? config.aggregationType : 'default'; layout.showHierarchy = Ext.isBoolean(config.showHierarchy) ? config.showHierarchy : false; @@ -1881,6 +1884,13 @@ paramString += '&limit=' + view.topLimit + '&sortOrder=' + (view.sortOrder < 0 ? 'ASC' : 'DESC'); } + // count type + if (view.dataType === 'aggregated_values' && view.countType) { + if (view.countType === 'tracked_entity_instances') { + paramString += '&uniqueInstances=true'; + } + } + // sorting if (view.dataType === 'individual_cases' && view.sorting) { if (view.sorting.id && view.sorting.direction) {