dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #28990
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 14575: Data set report, impl support for category option groups
------------------------------------------------------------
revno: 14575
committer: Lars Helge Øverland <larshelge@xxxxxxxxx>
branch nick: dhis2
timestamp: Mon 2014-03-31 20:05:12 +0200
message:
Data set report, impl support for category option groups
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/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 2014-03-31 14:28:29 +0000
+++ dhis-2/dhis-web/dhis-web-reporting/src/main/java/org/hisp/dhis/reporting/dataset/action/GetDataSetReportOptionsAction.java 2014-03-31 18:05:12 +0000
@@ -36,6 +36,7 @@
import java.util.List;
import org.hisp.dhis.common.comparator.IdentifiableObjectNameComparator;
+import org.hisp.dhis.dataelement.CategoryOptionGroupSet;
import org.hisp.dhis.dataelement.DataElementCategoryCombo;
import org.hisp.dhis.dataelement.DataElementCategoryService;
import org.hisp.dhis.dataset.DataSet;
@@ -183,6 +184,13 @@
return categoryCombos;
}
+ private List<CategoryOptionGroupSet> categoryOptionGroupSets;
+
+ public List<CategoryOptionGroupSet> getCategoryOptionGroupSets()
+ {
+ return categoryOptionGroupSets;
+ }
+
private List<OrganisationUnitGroupSet> organisationUnitGroupSets;
public List<OrganisationUnitGroupSet> getOrganisationUnitGroupSets()
@@ -195,11 +203,7 @@
// -------------------------------------------------------------------------
public String execute()
- {
- dataSets = new ArrayList<DataSet>( dataSetService.getAllDataSets() );
-
- Collections.sort( dataSets, IdentifiableObjectNameComparator.INSTANCE );
-
+ {
periodTypes = getAvailablePeriodTypes();
render = ( ds != null && pe != null && ou != null );
@@ -216,11 +220,15 @@
}
defaultCategoryCombo = categoryService.getDefaultDataElementCategoryCombo();
-
+
+ dataSets = new ArrayList<DataSet>( dataSetService.getAllDataSets() );
categoryCombos = new ArrayList<DataElementCategoryCombo>( categoryService.getAttributeCategoryCombos() );
+ categoryOptionGroupSets = new ArrayList<CategoryOptionGroupSet>( categoryService.getAllCategoryOptionGroupSets() );
organisationUnitGroupSets = new ArrayList<OrganisationUnitGroupSet>( organisationUnitGroupService.getAllOrganisationUnitGroupSets() );
+ Collections.sort( dataSets, IdentifiableObjectNameComparator.INSTANCE );
Collections.sort( categoryCombos, IdentifiableObjectNameComparator.INSTANCE );
+ Collections.sort( categoryOptionGroupSets, IdentifiableObjectNameComparator.INSTANCE );
Collections.sort( organisationUnitGroupSets, IdentifiableObjectNameComparator.INSTANCE );
return SUCCESS;
=== 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 2014-03-31 17:22:19 +0000
+++ dhis-2/dhis-web/dhis-web-reporting/src/main/webapp/dhis-web-reporting/dataSetReportForm.vm 2014-03-31 18:05:12 +0000
@@ -29,6 +29,29 @@
#end
] }#if( $velocityCount < $size1 ),#end
#end
+},
+"categoryOptionGroupSets": {
+#set( $size1 = $categoryOptionGroupSets.size() )
+#foreach( $groupSet in $categoryOptionGroupSets )
+"${groupSet.uid}":{"id":"${groupSet.uid}","name":"$encoder.jsonEncode( ${groupSet.displayName} )","members":[
+#set( $size2 = $groupSet.members.size() )
+#foreach( $group in $groupSet.members )
+"${group.uid}"#if( $velocityCount < $size2 ),#end
+#end
+] }#if( $velocityCount < $size1 ),#end
+#end
+},
+"dataSets": {
+#set( $size1 = $dataSets.size() )
+#foreach( $dataSet in $dataSets )
+"${dataSet.uid}":{"id":"{dataSet.uid}","name":"$encoder.jsonEncode( ${dataSet.displayName} )",
+"categoryCombo":"$!{dataSet.categoryCombo.uid}","categoryOptionGroupSets":[
+#set( $size2 = $dataSet.categoryOptionGroupSets.size() )
+#foreach( $cogs in $dataSet.categoryOptionGroupSets )
+"${cogs.uid}"#if( $velocityCount < $size2 ),#end
+#end
+] }#if( $velocityCount < $size1 ),#end
+#end
}
}
@@ -100,13 +123,14 @@
<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" data-categorycombo="${dataSet.categoryCombo.uid}" data-approval="${dataSet.approveData}">
+ <option value="$dataSet.uid" data-approval="${dataSet.approveData}">
$encoder.htmlEncode( $dataSet.displayName )
</option>
#end
</select>
</div>
+<div id="categoryOptionGroupSetDiv" style="display:none"></div>
<div id="attributeComboDiv" style="display:none"></div>
<!-- Period -->
=== 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 2014-03-31 17:22:19 +0000
+++ dhis-2/dhis-web/dhis-web-reporting/src/main/webapp/dhis-web-reporting/javascript/dataSetReport.js 2014-03-31 18:05:12 +0000
@@ -12,9 +12,11 @@
function getDataSetReport()
{
+ var ds = $( "#dataSetId" ).val();
+
var dataSetReport = {
- ds: $( "#dataSetId" ).val(),
- cc: $( "#dataSetId :selected" ).data( "categorycombo" ),
+ ds: ds,
+ cc: dhis2.dsr.metaData.dataSets[ds].categoryCombo,
periodType: $( "#periodType" ).val(),
pe: $( "#periodId" ).val(),
ou: selectionTreeSelection.getSelectedUid()[0],
@@ -73,7 +75,8 @@
dhis2.dsr.dataSetSelected = function()
{
var ds = $( "#dataSetId" ).val();
- var cc = $( "#dataSetId :selected" ).data( "categorycombo" );
+ var cc = dhis2.dsr.metaData.dataSets[ds].categoryCombo;
+ var cogs = dhis2.dsr.metaData.dataSets[ds].categoryOptionGroupSets;
if ( cc && cc != dhis2.dsr.metaData.defaultCategoryCombo ) {
var categoryCombo = dhis2.dsr.metaData.categoryCombos[cc];
@@ -82,9 +85,52 @@
dhis2.dsr.setAttributesMarkup( categoryIds );
}
else {
- $( "#attributeComboDiv" ).html( "" ).hide();
- }
-}
+ $( "#attributeComboDiv" ).empty().hide();
+ }
+
+ if ( cogs && cogs.length ) {
+ dhis2.dsr.setCategoryOptionGroupSetsMarkup( cogs );
+ }
+ else {
+ $( "#categoryOptionGroupSetDiv" ).empty().hide();
+ }
+}
+
+dhis2.dsr.setCategoryOptionGroupSetsMarkup = function( groupSetIds )
+{
+ if ( !groupSetIds || groupSetIds.length == 0 ) {
+ return;
+ }
+
+ var cogsRx = [];
+ $.each( groupSetIds, function( idx, id ) {
+ cogsRx.push( $.get( "../api/categoryOptionGroupSets/" + id + ".json" ) );
+ } );
+
+ $.when.apply( $, cogsRx ).done( function() {
+ var html = '';
+ var args = dhis2.util.normalizeArguments( arguments );
+
+ $.each( args, function( idx, cogs ) {
+ var groupSet = cogs[0];
+
+ html += '<div class="inputSection">';
+ html += '<div><label>' + groupSet.name + '</label></div>';
+ html += '<select class="dimension" data-uid="' + groupSet.id + '" style="width:330px">';
+ html += '<option value="-1">[ ' + i18n_select_option_view_all + ' ]</option>';
+
+ $.each( groupSet.items, function( idx, option ) {
+ html += '<option value="' + option.id + '">' + option.name + '</option>';
+ } );
+
+ html += '</select>';
+ html += '</div>';
+ } );
+
+ $( "#categoryOptionGroupSetDiv" ).show().html( html );
+ } );
+}
+
/**
* Sets markup for drop down boxes for the given categories in the selection div.