dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #27071
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 13425: Data set report, impl support for attributes
------------------------------------------------------------
revno: 13425
committer: Lars Helge Øverland <larshelge@xxxxxxxxx>
branch nick: dhis2
timestamp: Wed 2013-12-25 12:46:47 +0100
message:
Data set report, impl support for attributes
modified:
dhis-2/dhis-web/dhis-web-reporting/src/main/java/org/hisp/dhis/reporting/dataset/action/GetDataSetReportOptionsAction.java
dhis-2/dhis-web/dhis-web-reporting/src/main/resources/META-INF/dhis/beans.xml
dhis-2/dhis-web/dhis-web-reporting/src/main/webapp/dhis-web-reporting/dataSetReportForm.vm
dhis-2/dhis-web/dhis-web-reporting/src/main/webapp/dhis-web-reporting/javascript/dataSetReport.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-web/dhis-web-reporting/src/main/java/org/hisp/dhis/reporting/dataset/action/GetDataSetReportOptionsAction.java'
--- dhis-2/dhis-web/dhis-web-reporting/src/main/java/org/hisp/dhis/reporting/dataset/action/GetDataSetReportOptionsAction.java 2013-08-23 16:05:01 +0000
+++ dhis-2/dhis-web/dhis-web-reporting/src/main/java/org/hisp/dhis/reporting/dataset/action/GetDataSetReportOptionsAction.java 2013-12-25 11:46:47 +0000
@@ -36,6 +36,8 @@
import java.util.List;
import org.hisp.dhis.common.comparator.IdentifiableObjectNameComparator;
+import org.hisp.dhis.dataelement.DataElementCategoryCombo;
+import org.hisp.dhis.dataelement.DataElementCategoryService;
import org.hisp.dhis.dataset.DataSet;
import org.hisp.dhis.dataset.DataSetService;
import org.hisp.dhis.organisationunit.OrganisationUnitGroupService;
@@ -78,6 +80,13 @@
{
this.organisationUnitGroupService = organisationUnitGroupService;
}
+
+ private DataElementCategoryService categoryService;
+
+ public void setCategoryService( DataElementCategoryService categoryService )
+ {
+ this.categoryService = categoryService;
+ }
private SelectionTreeManager selectionTreeManager;
@@ -160,7 +169,21 @@
return periodType;
}
- private List<OrganisationUnitGroupSet> groupSets = new ArrayList<OrganisationUnitGroupSet>();
+ private DataElementCategoryCombo defaultCategoryCombo;
+
+ public DataElementCategoryCombo getDefaultCategoryCombo()
+ {
+ return defaultCategoryCombo;
+ }
+
+ private List<DataElementCategoryCombo> categoryCombos;
+
+ public List<DataElementCategoryCombo> getCategoryCombos()
+ {
+ return categoryCombos;
+ }
+
+ private List<OrganisationUnitGroupSet> groupSets;
public List<OrganisationUnitGroupSet> getGroupSets()
{
@@ -192,7 +215,14 @@
selectionTreeManager.setSelectedOrganisationUnit( organisationUnitService.getOrganisationUnit( ou ) ); //TODO set unit state in client instead
}
+ defaultCategoryCombo = categoryService.getDefaultDataElementCategoryCombo();
+
+ categoryCombos = new ArrayList<DataElementCategoryCombo>( categoryService.getAttributeCategoryCombos() );
+
groupSets = new ArrayList<OrganisationUnitGroupSet>( organisationUnitGroupService.getAllOrganisationUnitGroupSets() );
+
+ Collections.sort( categoryCombos, IdentifiableObjectNameComparator.INSTANCE );
+ Collections.sort( groupSets, IdentifiableObjectNameComparator.INSTANCE );
return SUCCESS;
}
=== modified file 'dhis-2/dhis-web/dhis-web-reporting/src/main/resources/META-INF/dhis/beans.xml'
--- dhis-2/dhis-web/dhis-web-reporting/src/main/resources/META-INF/dhis/beans.xml 2013-12-24 15:02:47 +0000
+++ dhis-2/dhis-web/dhis-web-reporting/src/main/resources/META-INF/dhis/beans.xml 2013-12-25 11:46:47 +0000
@@ -97,6 +97,7 @@
<property name="dataSetService" ref="org.hisp.dhis.dataset.DataSetService" />
<property name="organisationUnitService" ref="org.hisp.dhis.organisationunit.OrganisationUnitService" />
<property name="organisationUnitGroupService" ref="org.hisp.dhis.organisationunit.OrganisationUnitGroupService" />
+ <property name="categoryService" ref="org.hisp.dhis.dataelement.DataElementCategoryService" />
<property name="selectionTreeManager" ref="org.hisp.dhis.oust.manager.SelectionTreeManager" />
</bean>
=== modified file 'dhis-2/dhis-web/dhis-web-reporting/src/main/webapp/dhis-web-reporting/dataSetReportForm.vm'
--- dhis-2/dhis-web/dhis-web-reporting/src/main/webapp/dhis-web-reporting/dataSetReportForm.vm 2013-09-23 09:18:40 +0000
+++ dhis-2/dhis-web/dhis-web-reporting/src/main/webapp/dhis-web-reporting/dataSetReportForm.vm 2013-12-25 11:46:47 +0000
@@ -1,27 +1,43 @@
<script type="text/javascript">
- jQuery(document).ready(function() {
-
- #if( $render == true )
- var dataSetReport = {
- dataSet: "${ds}",
- periodType: "${periodType.name}",
- period: "${pe}",
- offset: ${offset}
- };
- setDataSetReport( dataSetReport );
- #else
- selectionTreeSelection.setMultipleSelectionAllowed( false );
- selectionTree.clearSelectedOrganisationUnits();
- selectionTree.buildSelectionTree();
- #end
- });
-
- var i18n_select_data_set = '$encoder.jsEscape( $i18n.getString( "select_data_set" ), "'")';
- var i18n_select_period = '$encoder.jsEscape( $i18n.getString( "select_period" ), "'")';
- var i18n_select_organisation_unit = '$encoder.jsEscape( $i18n.getString( "select_organisation_unit" ), "'")';
- var i18n_generating_report = '$encoder.jsEscape( $i18n.getString( "generating_report" ), "'")';
- var i18n_share_your_interpretation = '$encoder.jsEscape( $i18n.getString( "share_your_interpretation" ), "'")';
- var i18n_interpretation_was_shared = '$encoder.jsEscape( $i18n.getString( "interpretation_was_shared" ), "'")';
+jQuery(document).ready(function() {
+
+ #if( $render == true )
+ var dataSetReport = {
+ dataSet: "${ds}",
+ periodType: "${periodType.name}",
+ period: "${pe}",
+ offset: ${offset}
+ };
+ setDataSetReport( dataSetReport );
+ #else
+ selectionTreeSelection.setMultipleSelectionAllowed( false );
+ selectionTree.clearSelectedOrganisationUnits();
+ selectionTree.buildSelectionTree();
+ #end
+});
+
+dhis2.dsr.metaData = {
+
+"defaultCategoryCombo":"${defaultCategoryCombo.uid}",
+"categoryCombos": {
+#set( $size1 = $categoryCombos.size() )
+#foreach( $categoryCombo in $categoryCombos )
+"${categoryCombo.uid}":{"id":"${categoryCombo.uid}","name":"$encoder.jsonEncode( ${categoryCombo.displayName} )","categories":[
+#set( $size2 = $categoryCombo.categories.size() )
+#foreach( $category in $categoryCombo.categories )
+"${category.uid}"#if( $velocityCount < $size2 ),#end
+#end
+] }#if( $velocityCount < $size1 ),#end
+#end
+}
+}
+
+var i18n_select_data_set = '$encoder.jsEscape( $i18n.getString( "select_data_set" ), "'")';
+var i18n_select_period = '$encoder.jsEscape( $i18n.getString( "select_period" ), "'")';
+var i18n_select_organisation_unit = '$encoder.jsEscape( $i18n.getString( "select_organisation_unit" ), "'")';
+var i18n_generating_report = '$encoder.jsEscape( $i18n.getString( "generating_report" ), "'")';
+var i18n_share_your_interpretation = '$encoder.jsEscape( $i18n.getString( "share_your_interpretation" ), "'")';
+var i18n_interpretation_was_shared = '$encoder.jsEscape( $i18n.getString( "interpretation_was_shared" ), "'")';
</script>
<style type="text/css" media="print">
@@ -69,16 +85,19 @@
<!-- Data set -->
<div id="criteria" class="inputCriteria" style="width:360px;">
+
<div class="inputSection">
<label>$i18n.getString( "dataset" )</label><br>
-<select id="dataSetId" name="dataSetId" style="width:330px">
+<select id="dataSetId" name="dataSetId" style="width:330px" onchange="dhis2.dsr.dataSetSelected()">
<option value="">[ $i18n.getString( "select" ) ]</option>
#foreach( $dataSet in $dataSets )
- <option value="$dataSet.uid">$encoder.htmlEncode( $dataSet.displayName )</option>
+ <option value="$dataSet.uid" data-categorycombo="${dataSet.categoryCombo.uid}">$encoder.htmlEncode( $dataSet.displayName )</option>
#end
</select>
</div>
+<div id="attributeComboDiv" style="display:none"></div>
+
<!-- Period -->
<div class="inputSection">
@@ -112,7 +131,7 @@
<div id="advancedOptions" style="display:none">
#foreach( $groupSet in $groupSets )
-<select name="groupSet" data-uid="${groupSet.uid}" style="width:330px" class="advanced">
+<select class="dimension" data-uid="${groupSet.uid}" style="width:330px" class="advanced">
<option value="">[ $i18n.getString( "select" ) $encoder.htmlEncode( $groupSet.name ) / $i18n.getString( "view_all" ) ]</option>
#foreach( $group in $groupSet.organisationUnitGroups )
<option value="${group.uid}">$encoder.htmlEncode( $group.name )</option>
@@ -126,6 +145,7 @@
<input type="button" value='$i18n.getString( "get_report" )' style="width:120px" onclick="generateDataSetReport()">
<input type="button" value='$i18n.getString( "cancel" )' style="width:120px" onclick="hideCriteria()">
</div>
+
</div>
#parse( "dhis-web-commons/loader/loader.vm" )
=== modified file 'dhis-2/dhis-web/dhis-web-reporting/src/main/webapp/dhis-web-reporting/javascript/dataSetReport.js'
--- dhis-2/dhis-web/dhis-web-reporting/src/main/webapp/dhis-web-reporting/javascript/dataSetReport.js 2013-12-24 15:02:47 +0000
+++ dhis-2/dhis-web/dhis-web-reporting/src/main/webapp/dhis-web-reporting/javascript/dataSetReport.js 2013-12-25 11:46:47 +0000
@@ -21,7 +21,7 @@
var dims = [];
- $( "[name='groupSet']" ).each( function( index, value ) {
+ $( ".dimension" ).each( function( index, value ) {
var dim = $( this ).data( "uid" );
var item = $( this ).val();
@@ -58,6 +58,67 @@
}
//------------------------------------------------------------------------------
+// Data set
+//------------------------------------------------------------------------------
+
+/**
+ * Callback for changes to data set selection.
+ */
+dhis2.dsr.dataSetSelected = function()
+{
+ var ds = $( "#dataSetId" ).val();
+ var cc = $( "#dataSetId :selected" ).data( "categorycombo" );
+
+ if ( cc && cc != dhis2.dsr.metaData.defaultCategoryCombo ) {
+ var categoryCombo = dhis2.dsr.metaData.categoryCombos[cc];
+ var categoryIds = categoryCombo.categories;
+
+ dhis2.dsr.setAttributesMarkup( categoryIds );
+ }
+ else {
+ $( "#attributeComboDiv" ).html( "" ).hide();
+ }
+}
+
+/**
+* Set markup for drop down boxes to be put in the selection box for the
+* given categories.
+*/
+dhis2.dsr.setAttributesMarkup = function( categoryIds )
+{
+ if ( !categoryIds || categoryIds.length == 0 ) {
+ return;
+ }
+
+ var categoryRx = [];
+ $.each( categoryIds, function( idx, id ) {
+ categoryRx.push( $.get( "../api/dimensions/" + id + ".json" ) );
+ } );
+
+ var defer = $.when.apply( $, categoryRx ).done( function() {
+ var html = '';
+
+ $.each( arguments, function( idx, cat ) {
+ var category = cat[0];
+
+ html += '<div class="inputSection">';
+ html += '<label>' + category.name + '</label>';
+ html += '<select class="dimension" data-uid="' + category.id + '" style="width:330px">';
+ html += '<option value="-1">[ ' + 'Select option / View all' + ' ]</option>';
+
+ $.each( category.items, function( idx, option ) {
+ html += '<option value="' + option.id + '">' + option.name + '</option>';
+ } );
+
+ html += '</select>';
+ html += '</div>';
+ } );
+
+ $( "#attributeComboDiv" ).show().html( html );
+ } );
+};
+
+//------------------------------------------------------------------------------
// Period
//------------------------------------------------------------------------------