dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #18825
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 7994: Implemented interpretations for data set report
------------------------------------------------------------
revno: 7994
committer: Lars Helge Øverland <larshelge@xxxxxxxxx>
branch nick: dhis2
timestamp: Mon 2012-09-03 21:48:33 +0200
message:
Implemented interpretations for data set report
added:
dhis-2/dhis-web/dhis-web-reporting/src/main/webapp/dhis-web-reporting/renderDataSetReportHeader.vm
modified:
dhis-2/dhis-api/src/main/java/org/hisp/dhis/interpretation/Interpretation.java
dhis-2/dhis-api/src/main/java/org/hisp/dhis/period/Cal.java
dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/javascripts/periodType.js
dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/oust/oust.js
dhis-2/dhis-web/dhis-web-dashboard-integration/src/main/resources/org/hisp/dhis/dashboard/i18n_module.properties
dhis-2/dhis-web/dhis-web-dashboard-integration/src/main/webapp/dhis-web-dashboard-integration/interpretation.vm
dhis-2/dhis-web/dhis-web-reporting/src/main/java/org/hisp/dhis/reporting/dataset/action/GenerateDataSetReportAction.java
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/resources/org/hisp/dhis/reporting/i18n_module.properties
dhis-2/dhis-web/dhis-web-reporting/src/main/resources/struts.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
dhis-2/dhis-web/dhis-web-reporting/src/main/webapp/dhis-web-reporting/renderCustomDataSetReportForm.vm
dhis-2/dhis-web/dhis-web-reporting/src/main/webapp/dhis-web-reporting/renderDefaultDataSetReportForm.vm
dhis-2/dhis-web/dhis-web-reporting/src/main/webapp/dhis-web-reporting/renderSectionDataSetReportForm.vm
dhis-2/dhis-web/dhis-web-visualizer/src/main/resources/org/hisp/dhis/visualizer/i18n_module.properties
--
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-api/src/main/java/org/hisp/dhis/interpretation/Interpretation.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/interpretation/Interpretation.java 2012-08-31 15:35:59 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/interpretation/Interpretation.java 2012-09-03 19:48:33 +0000
@@ -42,6 +42,7 @@
import org.hisp.dhis.mapping.MapView;
import org.hisp.dhis.organisationunit.OrganisationUnit;
import org.hisp.dhis.period.Period;
+import org.hisp.dhis.period.PeriodType;
import org.hisp.dhis.reporttable.ReportTable;
import org.hisp.dhis.user.User;
@@ -145,7 +146,12 @@
{
return dataSet != null;
}
-
+
+ public PeriodType getPeriodType()
+ {
+ return period != null ? period.getPeriodType() : null;
+ }
+
// -------------------------------------------------------------------------
// Get and set methods
// -------------------------------------------------------------------------
=== modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/period/Cal.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/period/Cal.java 2011-10-29 14:16:54 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/period/Cal.java 2012-09-03 19:48:33 +0000
@@ -1,9 +1,39 @@
package org.hisp.dhis.period;
+/*
+ * Copyright (c) 2004-2012, University of Oslo
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ * * Redistributions of source code must retain the above copyright notice, this
+ * list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following disclaimer in the documentation
+ * and/or other materials provided with the distribution.
+ * * Neither the name of the HISP project nor the names of its contributors may
+ * be used to endorse or promote products derived from this software without
+ * specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
+ * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
+ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
import java.util.Calendar;
import java.util.Date;
import java.util.GregorianCalendar;
+/**
+ * @author Lars Helge Overland
+ */
public class Cal
{
private Calendar calendar;
@@ -25,7 +55,7 @@
calendar.clear();
set( year, month, day );
}
-
+
/**
* Sets the time of the calendar to now.
*/
@@ -70,6 +100,15 @@
}
/**
+ * Returns the current year.
+ * @return
+ */
+ public int getYear()
+ {
+ return calendar.get( Calendar.YEAR );
+ }
+
+ /**
* Sets the current time.
*
* @param year the year starting at AD 1.
@@ -81,6 +120,17 @@
calendar.set( year, month - 1, day );
return this;
}
+
+ /**
+ * Sets the current time.
+ *
+ * @param date the date to base time on.
+ */
+ public Cal set( Date date )
+ {
+ calendar.setTime( date );
+ return this;
+ }
/**
* Returns the current date the cal.
=== modified file 'dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/javascripts/periodType.js'
--- dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/javascripts/periodType.js 2012-07-31 20:02:10 +0000
+++ dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/javascripts/periodType.js 2012-09-03 19:48:33 +0000
@@ -49,6 +49,24 @@
return array;
};
+
+ this.filterFuturePeriodsExceptCurrent = function( periods )
+ {
+ var array = [];
+ var i = 0;
+
+ var now = new Date().getTime();
+
+ for ( var j = 0; j < periods.length; j++ )
+ {
+ if ( $.date( periods[j]['startDate'], dateFormat ).date().getTime() <= now )
+ {
+ array[i++] = periods[j];
+ }
+ }
+
+ return array;
+ };
}
function DailyPeriodType( dateFormat )
=== modified file 'dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/oust/oust.js'
--- dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/oust/oust.js 2012-04-26 15:26:28 +0000
+++ dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/oust/oust.js 2012-09-03 19:48:33 +0000
@@ -114,7 +114,7 @@
selectedOrganisationUnitUid.push( unitUids[i] );
}
- jQuery("body").trigger("oust.selected", selectedOrganisationUnit);
+ jQuery( 'body' ).trigger( 'oust.selected', selectedOrganisationUnit);
if ( listenerFunction )
{
@@ -137,7 +137,7 @@
this.clearSelectedOrganisationUnits = function()
{
$.ajax({
- url: selectionTreePath + "clearSelectedOrganisationUnits.action",
+ url: selectionTreePath + 'clearSelectedOrganisationUnits.action',
async: false
});
};
@@ -232,7 +232,7 @@
clearLoadingMessage( treeTag );
- jQuery("body").trigger( "oust.selected", selectedOrganisationUnit );
+ jQuery( 'body' ).trigger( 'oust.selected', selectedOrganisationUnit );
}
function createChildren( parentTag, parentElement )
=== modified file 'dhis-2/dhis-web/dhis-web-dashboard-integration/src/main/resources/org/hisp/dhis/dashboard/i18n_module.properties'
--- dhis-2/dhis-web/dhis-web-dashboard-integration/src/main/resources/org/hisp/dhis/dashboard/i18n_module.properties 2012-07-27 12:38:08 +0000
+++ dhis-2/dhis-web/dhis-web-dashboard-integration/src/main/resources/org/hisp/dhis/dashboard/i18n_module.properties 2012-09-03 19:48:33 +0000
@@ -46,12 +46,14 @@
click_to_view_report_table=Click to view report table
click_to_view_in_data_visualizer=Click to view in Data Visualizer
click_to_view_in_gis=Click to view in GIS
+click_to_view_data_set_report=Click to view data set report
share=Share
-write_your_interpretation=Write your interpretation
+write_your_interpretation=Write a comment, question or interpretation
share_your_interpretation_of=Share your interpretation of
interpretation_was_shared=Interpretation was shared
viewing=Viewing
from=From
load_favorite_click_share=load a favorite and click 'Share' on the top menu
generate_report_table_click_share=generate a report table and click 'Share' on the top menu
-share_interpretation=Share interpretation
\ No newline at end of file
+share_interpretation=Share interpretation
+view_data_set_report=View data set report
\ No newline at end of file
=== modified file 'dhis-2/dhis-web/dhis-web-dashboard-integration/src/main/webapp/dhis-web-dashboard-integration/interpretation.vm'
--- dhis-2/dhis-web/dhis-web-dashboard-integration/src/main/webapp/dhis-web-dashboard-integration/interpretation.vm 2012-06-02 10:23:57 +0000
+++ dhis-2/dhis-web/dhis-web-dashboard-integration/src/main/webapp/dhis-web-dashboard-integration/interpretation.vm 2012-09-03 19:48:33 +0000
@@ -27,11 +27,17 @@
<a class="bold"
title="$i18n.getString( 'click_to_view_in_gis' )"
href="../dhis-web-mapping/mapping/index.html?id=${ip.mapView.uid}">$encoder.htmlEncode( $ip.mapView.name )</a>
- #else
- #if( $ip.organisationUnit )#set( $ou = "&ou=" + $ip.organisationUnit.uid )#else#set( $ou = "" )#end
+ #elseif( $ip.reportTableInterpretation )
+ #if( $ip.organisationUnit )#set( $ou = "&ou=" + $ip.organisationUnit.uid )#else#set( $ou = "" )#end
<a class="bold"
title="$i18n.getString( 'click_to_view_report_table' )"
- href="../dhis-web-reporting/exportTable.action?uid=${ip.reportTable.uid}&pe=${format.formatDate( $ip.created )}${ou}">$encoder.htmlEncode( $ip.reportTable.name )</a>
+ href="../dhis-web-reporting/exportTable.action?uid=${ip.reportTable.uid}&pe=${format.formatDate( $ip.created )}${ou}">
+ $encoder.htmlEncode( $ip.reportTable.name )</a>
+ #elseif( $ip.dataSetReportInterpretation )
+ <a class="bold"
+ title="$i18n.getString( 'click_to_view_data_set_report' )"
+ href="../dhis-web-reporting/showDataSetReportForm.action?ds=${ip.dataSet.uid}&pe=${ip.period.isoDate}&ou=${ip.organisationUnit.uid}">
+ $i18n.getString( "view_data_set_report" )</a>
#end
</div>
=== modified file 'dhis-2/dhis-web/dhis-web-reporting/src/main/java/org/hisp/dhis/reporting/dataset/action/GenerateDataSetReportAction.java'
--- dhis-2/dhis-web/dhis-web-reporting/src/main/java/org/hisp/dhis/reporting/dataset/action/GenerateDataSetReportAction.java 2012-04-26 15:26:28 +0000
+++ dhis-2/dhis-web/dhis-web-reporting/src/main/java/org/hisp/dhis/reporting/dataset/action/GenerateDataSetReportAction.java 2012-09-03 19:48:33 +0000
@@ -47,6 +47,7 @@
import org.hisp.dhis.organisationunit.OrganisationUnitService;
import org.hisp.dhis.period.Period;
import org.hisp.dhis.period.PeriodService;
+import org.hisp.dhis.period.PeriodType;
import org.hisp.dhis.util.SessionUtils;
import com.opensymphony.xwork2.Action;
@@ -83,20 +84,20 @@
this.registrationService = registrationService;
}
+ private OrganisationUnitService organisationUnitService;
+
+ public void setOrganisationUnitService( OrganisationUnitService organisationUnitService )
+ {
+ this.organisationUnitService = organisationUnitService;
+ }
+
private PeriodService periodService;
-
+
public void setPeriodService( PeriodService periodService )
{
this.periodService = periodService;
}
- private OrganisationUnitService organisationUnitService;
-
- public void setOrganisationUnitService( OrganisationUnitService organisationUnitService )
- {
- this.organisationUnitService = organisationUnitService;
- }
-
private I18nFormat format;
public void setFormat( I18nFormat format )
@@ -115,25 +116,25 @@
// Input
// -------------------------------------------------------------------------
- private Integer dataSetId;
-
- public void setDataSetId( Integer dataSetId )
- {
- this.dataSetId = dataSetId;
- }
-
- private String periodId;
-
- public void setPeriodId( String periodId )
- {
- this.periodId = periodId;
- }
-
- private Integer orgUnitId;
+ private String ds;
+
+ public void setDs( String ds )
+ {
+ this.ds = ds;
+ }
+
+ private String pe;
+
+ public void setPe( String pe )
+ {
+ this.pe = pe;
+ }
+
+ private String ou;
- public void setOrgUnitId( Integer orgUnitId )
+ public void setOu( String ou )
{
- this.orgUnitId = orgUnitId;
+ this.ou = ou;
}
private boolean selectedUnitOnly;
@@ -224,19 +225,20 @@
public String execute()
throws Exception
{
- selectedDataSet = dataSetService.getDataSet( dataSetId );
+ selectedDataSet = dataSetService.getDataSet( ds );
- if ( periodId != null )
+ if ( pe != null )
{
- selectedPeriod = periodService.getPeriodByExternalId( periodId );
+ selectedPeriod = PeriodType.getPeriodFromIsoString( pe );
+ selectedPeriod = periodService.reloadPeriod( selectedPeriod );
}
- selectedOrgunit = organisationUnitService.getOrganisationUnit( orgUnitId );
+ selectedOrgunit = organisationUnitService.getOrganisationUnit( ou );
String dataSetType = selectedDataSet.getDataSetType();
registration = registrationService.getCompleteDataSetRegistration( selectedDataSet, selectedPeriod, selectedOrgunit );
-
+
if ( TYPE_CUSTOM.equals( dataSetType ) )
{
if ( useLast )
=== 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 2012-01-25 17:11:43 +0000
+++ dhis-2/dhis-web/dhis-web-reporting/src/main/java/org/hisp/dhis/reporting/dataset/action/GetDataSetReportOptionsAction.java 2012-09-03 19:48:33 +0000
@@ -27,6 +27,9 @@
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
+import static org.hisp.dhis.period.PeriodType.getAvailablePeriodTypes;
+import static org.hisp.dhis.period.PeriodType.getPeriodFromIsoString;
+
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
@@ -34,6 +37,10 @@
import org.hisp.dhis.common.comparator.IdentifiableObjectNameComparator;
import org.hisp.dhis.dataset.DataSet;
import org.hisp.dhis.dataset.DataSetService;
+import org.hisp.dhis.organisationunit.OrganisationUnitService;
+import org.hisp.dhis.oust.manager.SelectionTreeManager;
+import org.hisp.dhis.period.Cal;
+import org.hisp.dhis.period.Period;
import org.hisp.dhis.period.PeriodType;
import com.opensymphony.xwork2.Action;
@@ -44,6 +51,10 @@
public class GetDataSetReportOptionsAction
implements Action
{
+ // -------------------------------------------------------------------------
+ // Dependencies
+ // -------------------------------------------------------------------------
+
private DataSetService dataSetService;
public void setDataSetService( DataSetService dataSetService )
@@ -51,6 +62,59 @@
this.dataSetService = dataSetService;
}
+ private OrganisationUnitService organisationUnitService;
+
+ public void setOrganisationUnitService( OrganisationUnitService organisationUnitService )
+ {
+ this.organisationUnitService = organisationUnitService;
+ }
+
+ private SelectionTreeManager selectionTreeManager;
+
+ public void setSelectionTreeManager( SelectionTreeManager selectionTreeManager )
+ {
+ this.selectionTreeManager = selectionTreeManager;
+ }
+
+ // -------------------------------------------------------------------------
+ // Input
+ // -------------------------------------------------------------------------
+
+ private String ds;
+
+ public String getDs()
+ {
+ return ds;
+ }
+
+ public void setDs( String ds )
+ {
+ this.ds = ds;
+ }
+
+ private String pe;
+
+ public String getPe()
+ {
+ return pe;
+ }
+
+ public void setPe( String pe )
+ {
+ this.pe = pe;
+ }
+
+ private String ou;
+
+ public void setOu( String ou )
+ {
+ this.ou = ou;
+ }
+
+ // -------------------------------------------------------------------------
+ // Output
+ // -------------------------------------------------------------------------
+
private List<DataSet> dataSets;
public List<DataSet> getDataSets()
@@ -65,13 +129,51 @@
return periodTypes;
}
+ private boolean render;
+
+ public boolean isRender()
+ {
+ return render;
+ }
+
+ private int offset;
+
+ public int getOffset()
+ {
+ return offset;
+ }
+
+ private PeriodType periodType;
+
+ public PeriodType getPeriodType()
+ {
+ return periodType;
+ }
+
+ // -------------------------------------------------------------------------
+ // Action implementation
+ // -------------------------------------------------------------------------
+
public String execute()
{
dataSets = new ArrayList<DataSet>( dataSetService.getAllDataSets() );
Collections.sort( dataSets, IdentifiableObjectNameComparator.INSTANCE );
- periodTypes = PeriodType.getAvailablePeriodTypes();
+ periodTypes = getAvailablePeriodTypes();
+
+ render = ( ds != null && pe != null && ou != null );
+
+ if ( pe != null && getPeriodFromIsoString( pe ) != null )
+ {
+ Period period = getPeriodFromIsoString( pe );
+
+ offset = new Cal().set( period.getStartDate() ).getYear() - new Cal().now().getYear();
+
+ periodType = period.getPeriodType();
+
+ selectionTreeManager.setSelectedOrganisationUnit( organisationUnitService.getOrganisationUnit( ou ) ); //TODO set unit state in client instead
+ }
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 2012-04-26 15:26:28 +0000
+++ dhis-2/dhis-web/dhis-web-reporting/src/main/resources/META-INF/dhis/beans.xml 2012-09-03 19:48:33 +0000
@@ -189,8 +189,11 @@
<!-- DataSet Report -->
- <bean id="org.hisp.dhis.reporting.dataset.action.GetDataSetReportOptionsAction" class="org.hisp.dhis.reporting.dataset.action.GetDataSetReportOptionsAction">
+ <bean id="org.hisp.dhis.reporting.dataset.action.GetDataSetReportOptionsAction" class="org.hisp.dhis.reporting.dataset.action.GetDataSetReportOptionsAction"
+ scope="prototype">
<property name="dataSetService" ref="org.hisp.dhis.dataset.DataSetService" />
+ <property name="organisationUnitService" ref="org.hisp.dhis.organisationunit.OrganisationUnitService" />
+ <property name="selectionTreeManager" ref="org.hisp.dhis.oust.manager.SelectionTreeManager" />
</bean>
<bean id="org.hisp.dhis.reporting.dataset.action.GenerateDataSetReportAction" class="org.hisp.dhis.reporting.dataset.action.GenerateDataSetReportAction"
@@ -198,8 +201,8 @@
<property name="dataSetReportService" ref="org.hisp.dhis.datasetreport.DataSetReportService" />
<property name="dataSetService" ref="org.hisp.dhis.dataset.DataSetService" />
<property name="registrationService" ref="org.hisp.dhis.dataset.CompleteDataSetRegistrationService" />
+ <property name="organisationUnitService" ref="org.hisp.dhis.organisationunit.OrganisationUnitService" />
<property name="periodService" ref="org.hisp.dhis.period.PeriodService" />
- <property name="organisationUnitService" ref="org.hisp.dhis.organisationunit.OrganisationUnitService" />
</bean>
<!-- Data completeness -->
=== modified file 'dhis-2/dhis-web/dhis-web-reporting/src/main/resources/org/hisp/dhis/reporting/i18n_module.properties'
--- dhis-2/dhis-web/dhis-web-reporting/src/main/resources/org/hisp/dhis/reporting/i18n_module.properties 2012-07-24 04:04:14 +0000
+++ dhis-2/dhis-web/dhis-web-reporting/src/main/resources/org/hisp/dhis/reporting/i18n_module.properties 2012-09-03 19:48:33 +0000
@@ -215,7 +215,7 @@
financial_yearly=Financial Yearly
please_specify_file=Please specify a design file
jasper_design=Jasper design
-write_your_interpretation=Write your interpretation
+write_your_interpretation=Write a comment, question or interpretation
share=Share
share_your_interpretation=Share your interpretation
interpretation_was_shared=Interpretation was shared
=== modified file 'dhis-2/dhis-web/dhis-web-reporting/src/main/resources/struts.xml'
--- dhis-2/dhis-web/dhis-web-reporting/src/main/resources/struts.xml 2012-07-19 07:37:36 +0000
+++ dhis-2/dhis-web/dhis-web-reporting/src/main/resources/struts.xml 2012-09-03 19:48:33 +0000
@@ -238,6 +238,7 @@
<param name="page">/dhis-web-reporting/dataSetReportForm.vm</param>
<param name="menu">/dhis-web-reporting/menu.vm</param>
<param name="javascripts">../dhis-web-commons/oust/oust.js,javascript/dataSetReport.js</param>
+ <param name="stylesheets">style/dhis-web-reporting.css</param>
</action>
<action name="generateDataSetReport" class="org.hisp.dhis.reporting.dataset.action.GenerateDataSetReportAction">
=== 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 2012-07-13 09:44:26 +0000
+++ dhis-2/dhis-web/dhis-web-reporting/src/main/webapp/dhis-web-reporting/dataSetReportForm.vm 2012-09-03 19:48:33 +0000
@@ -1,14 +1,28 @@
<script type="text/javascript">
- jQuery(document).ready(function() {
- selectionTreeSelection.setMultipleSelectionAllowed( false );
- selectionTree.clearSelectedOrganisationUnits();
- selectionTree.buildSelectionTree();
+ jQuery(document).ready(function() {
+ jQuery( "#interpretationArea" ).autogrow();
+
+ #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" ), "'")';
</script>
<style type="text/css" media="print">
@@ -38,17 +52,16 @@
</style>
<style type="text/css">
-div#control
-{
+div#control {
margin-bottom: 15px;
}
-div.inputSection
-{
+div.inputSection {
padding-top: 7px;
padding-bottom: 5px;
}
</style>
+
<h3 id="dataset_report_header">$i18n.getString( "dataset_report" ) #openHelp( "dataset_reports" )</h3>
<div id="control">
@@ -61,21 +74,21 @@
<select id="dataSetId" name="dataSetId" style="width:330px">
<option value="">[ $i18n.getString( "select" ) ]</option>
#foreach( $dataSet in $dataSets )
- <option value="$dataSet.id">$encoder.htmlEncode( $dataSet.name )</option>
+ <option value="$dataSet.uid">$encoder.htmlEncode( $dataSet.name )</option>
#end
</select>
</div>
<div class="inputSection">
<label>$i18n.getString( "report_period" )</label><br>
-<select id="periodType" name="periodType" style="min-width:170px" onchange="getPeriods( 'periodType', 'periodId', 'periodId', '0' )">
+<select id="periodType" name="periodType" style="min-width:170px" onchange="displayPeriods()">
<option value="">[ $i18n.getString( "select_period_type" ) ]</option>
#foreach ( $type in $periodTypes )
<option value="$type.name">$i18n.getString( $type.name )</option>
#end
</select>
-<input type="button" style="width:75px" value="$i18n.getString( 'prev_year' )" onclick="getAvailablePeriods( 'periodType', 'periodId', 'periodId', '-1' )" />
-<input type="button" style="width:75px" value="$i18n.getString( 'next_year' )" onclick="getAvailablePeriods( 'periodType', 'periodId', 'periodId', '1' )" /><br>
+<input type="button" style="width:75px" value="$i18n.getString( 'prev_year' )" onclick="displayPreviousPeriods()" />
+<input type="button" style="width:75px" value="$i18n.getString( 'next_year' )" onclick="displayNextPeriods()" /><br>
<select id="periodId" name="periodId" style="width:330px" disabled="disabled">
</select>
@@ -99,4 +112,9 @@
#parse( "dhis-web-commons/loader/loader.vm" )
+<div id="shareForm">
+<textarea id="interpretationArea" class="interpretationArea" placeholder="$i18n.getString( 'write_your_interpretation' )..."></textarea>
+<input type="button" class="interpretationButton" value="$i18n.getString( 'share' )" onclick="shareInterpretation( '${uid}', '$!{ou}' )">
+</div>
+
<div id="content"></div>
=== 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 2012-05-16 17:17:26 +0000
+++ dhis-2/dhis-web/dhis-web-reporting/src/main/webapp/dhis-web-reporting/javascript/dataSetReport.js 2012-09-03 19:48:33 +0000
@@ -1,19 +1,93 @@
-function getPeriods( periodTypeList, availableList, selectedList, timespan )
-{
+var currentPeriodOffset = 0;
+var periodTypeFactory = new PeriodType();
+
+//------------------------------------------------------------------------------
+// Get and set methods
+//------------------------------------------------------------------------------
+
+function getDataSetReport()
+{
+ var dataSetReport = {
+ dataSet: $( "#dataSetId" ).val(),
+ periodType: $( "#periodType" ).val(),
+ period: $( "#periodId" ).val(),
+ orgUnit: selectionTreeSelection.getSelectedUid()[0],
+ selectedUnitOnly: $( "#selectedUnitOnly" ).is( ":checked" ),
+ offset: currentPeriodOffset
+ };
+
+ return dataSetReport;
+}
+
+function setDataSetReport( dataSetReport )
+{
+ $( "#dataSetId" ).val( dataSetReport.dataSet );
+ $( "#periodType" ).val( dataSetReport.periodType );
+
+ currentPeriodOffset = dataSetReport.offset;
+
+ displayPeriods();
+ $( "#periodId" ).val( dataSetReport.period );
+
+ selectionTreeSelection.setMultipleSelectionAllowed( false );
+ selectionTree.buildSelectionTree();
+
+ $( "body" ).on( "oust.selected", function() {
+ $( "body" ).off( "oust.selected" );
+ validateDataSetReport();
+ } );
+}
+
+//------------------------------------------------------------------------------
+// Period
+//------------------------------------------------------------------------------
+
+function displayPeriods()
+{
+ var periodType = $( "#periodType" ).val();
+ var periods = periodTypeFactory.get( periodType ).generatePeriods( currentPeriodOffset );
+ periods = periodTypeFactory.reverse( periods );
+ periods = periodTypeFactory.filterFuturePeriodsExceptCurrent( periods );
+
$( "#periodId" ).removeAttr( "disabled" );
-
- getAvailablePeriods( periodTypeList, availableList, selectedList, timespan );
-}
+ clearListById( "periodId" );
+
+ for ( i in periods )
+ {
+ addOptionById( "periodId", periods[i].iso, periods[i].name );
+ }
+}
+
+function displayNextPeriods()
+{
+ if ( currentPeriodOffset < 0 ) // Cannot display future periods
+ {
+ currentPeriodOffset++;
+ displayPeriods();
+ }
+}
+
+function displayPreviousPeriods()
+{
+ currentPeriodOffset--;
+ displayPeriods();
+}
+
+//------------------------------------------------------------------------------
+// Run report
+//------------------------------------------------------------------------------
function validateDataSetReport()
{
- if ( !$( "#dataSetId" ).val() )
+ var dataSetReport = getDataSetReport();
+
+ if ( !dataSetReport.dataSet )
{
setHeaderMessage( i18n_select_data_set );
return false;
}
- if ( !$( "#periodId" ).val() )
+ if ( !dataSetReport.period )
{
setHeaderMessage( i18n_select_period );
return false;
@@ -26,15 +100,10 @@
hideHeaderMessage();
hideCriteria();
- hideContent();
- showLoader();
+ hideContent();
+ showLoader();
- var dataSetId = $( "#dataSetId" ).val();
- var periodId = $( "#periodId" ).val();
- var selectedUnitOnly = $( "#selectedUnitOnly" ).is( ":checked" );
- var orgUnitId = selectionTreeSelection.getSelected()[0];
-
- var currentParams = { dataSetId: dataSetId, periodId: periodId, selectedUnitOnly: selectedUnitOnly, orgUnitId: orgUnitId };
+ var currentParams = { ds: dataSetReport.dataSet, pe: dataSetReport.period, selectedUnitOnly: dataSetReport.selectedUnitOnly, ou: dataSetReport.orgUnit };
$( '#content' ).load( 'generateDataSetReport.action', currentParams, function() {
hideLoader();
@@ -45,11 +114,13 @@
function exportDataSetReport( type )
{
+ var dataSetReport = getDataSetReport();
+
var url = "generateDataSetReport.action?useLast=true" +
- "&dataSetId=" + $( "#currentDataSetId" ).val() +
- "&periodId=" + $( "#currentPeriodId" ).val() +
- "&selectedUnitOnly=" + $( "#currentSelectedUnitOnly" ).val() +
- "&orgUnitId=" + selectionTreeSelection.getSelected() +
+ "&ds=" + dataSetReport.dataSet +
+ "&pe=" + dataSetReport.period +
+ "&selectedUnitOnly=" + dataSetReport.selectedUnitOnly +
+ "&ou=" + dataSetReport.orgUnit +
"&type=" + type;
window.location.href = url;
@@ -86,3 +157,43 @@
{
$( "#content" ).hide( "fast" );
}
+
+//------------------------------------------------------------------------------
+// Share
+//------------------------------------------------------------------------------
+
+function viewShareForm()
+{
+ $( "#shareForm" ).dialog( {
+ modal : true,
+ width : 550,
+ resizable: false,
+ title : i18n_share_your_interpretation
+ } );
+}
+
+function shareInterpretation()
+{
+ var dataSetReport = getDataSetReport();
+ var text = $( "#interpretationArea" ).val();
+
+ if ( text.length && $.trim( text ).length )
+ {
+ text = $.trim( text );
+
+ var url = "../api/interpretations/dataSetReport/" + $( "#currentDataSetId" ).val() +
+ "?pe=" + dataSetReport.period +
+ "&ou=" + dataSetReport.orgUnit;
+
+ $.ajax( url, {
+ type: "POST",
+ contentType: "text/html",
+ data: text,
+ success: function() {
+ $( "#shareForm" ).dialog( "close" );
+ $( "#interpretationArea" ).val( "" );
+ setHeaderDelayMessage( i18n_interpretation_was_shared );
+ }
+ } );
+ }
+}
=== modified file 'dhis-2/dhis-web/dhis-web-reporting/src/main/webapp/dhis-web-reporting/renderCustomDataSetReportForm.vm'
--- dhis-2/dhis-web/dhis-web-reporting/src/main/webapp/dhis-web-reporting/renderCustomDataSetReportForm.vm 2012-07-13 07:55:41 +0000
+++ dhis-2/dhis-web/dhis-web-reporting/src/main/webapp/dhis-web-reporting/renderCustomDataSetReportForm.vm 2012-09-03 19:48:33 +0000
@@ -1,16 +1,5 @@
-<input type="hidden" id="currentDataSetId" value="${selectedDataSet.id}">
-<input type="hidden" id="currentPeriodId" value="${selectedPeriod.externalId}">
-<input type="hidden" id="currentSelectedUnitOnly" value="${selectedUnitOnly}">
-<div id="userInfo" class="page"></div>
-
-<h3>$i18n.getString('reporting_unit'): $encoder.htmlEncode( $selectedOrgunit.name ) $i18n.getString('reporting_period'): $format.formatPeriod( $selectedPeriod )</h3>
-
-<div id="download_buttons" style="margin-bottom:15px">
-<input type="button" value="$i18n.getString( 'get_report_as_xls' )" onclick="exportDataSetReport( 'xls' )" style="width:140px">
-<input type="button" value="$i18n.getString( 'get_report_as_pdf' )" onclick="exportDataSetReport( 'pdf' )" style="width:140px">
-#if( $registration ) <span>$i18n.getString( "completed_by" ): <a href="javascript:setUserInfo( '${registration.storedBy}' )">${registration.storedBy}</a></span>#end
-</div>
+#parse( "dhis-web-reporting/renderDataSetReportHeader.vm" )
#set( $css = "cde cde-$!{selectedDataSet.dataEntryForm.style}" )
<div class="${css}">
=== added file 'dhis-2/dhis-web/dhis-web-reporting/src/main/webapp/dhis-web-reporting/renderDataSetReportHeader.vm'
--- dhis-2/dhis-web/dhis-web-reporting/src/main/webapp/dhis-web-reporting/renderDataSetReportHeader.vm 1970-01-01 00:00:00 +0000
+++ dhis-2/dhis-web/dhis-web-reporting/src/main/webapp/dhis-web-reporting/renderDataSetReportHeader.vm 2012-09-03 19:48:33 +0000
@@ -0,0 +1,14 @@
+
+<h3>$encoder.htmlEncode( $selectedOrgunit.name ) - $format.formatPeriod( $selectedPeriod )</h3>
+
+<input type="hidden" id="currentDataSetId" value="${selectedDataSet.uid}">
+<input type="hidden" id="currentPeriodId" value="${selectedPeriod.isoDate}">
+<input type="hidden" id="currentSelectedUnitOnly" value="${selectedUnitOnly}">
+<div id="userInfo" class="page"></div>
+
+<div id="download_buttons" style="margin-bottom:15px">
+<input type="button" value="$i18n.getString( 'get_report_as_xls' )" onclick="exportDataSetReport( 'xls' )" style="width:140px">
+<input type="button" value="$i18n.getString( 'get_report_as_pdf' )" onclick="exportDataSetReport( 'pdf' )" style="width:140px">
+<input type="button" value="$i18n.getString( 'share' )" onclick="viewShareForm()" style="width:140px">
+#if( $registration ) <span>$i18n.getString( "completed_by" ): <a href="javascript:setUserInfo( '${registration.storedBy}' )">${registration.storedBy}</a></span>#end
+</div>
=== modified file 'dhis-2/dhis-web/dhis-web-reporting/src/main/webapp/dhis-web-reporting/renderDefaultDataSetReportForm.vm'
--- dhis-2/dhis-web/dhis-web-reporting/src/main/webapp/dhis-web-reporting/renderDefaultDataSetReportForm.vm 2012-07-13 07:55:41 +0000
+++ dhis-2/dhis-web/dhis-web-reporting/src/main/webapp/dhis-web-reporting/renderDefaultDataSetReportForm.vm 2012-09-03 19:48:33 +0000
@@ -1,16 +1,5 @@
-<input type="hidden" id="currentDataSetId" value="${selectedDataSet.id}">
-<input type="hidden" id="currentPeriodId" value="${selectedPeriod.externalId}">
-<input type="hidden" id="currentSelectedUnitOnly" value="${selectedUnitOnly}">
-<div id="userInfo" class="page"></div>
-
-<h3>$encoder.htmlEncode( $selectedOrgunit.name ) - $format.formatPeriod( $selectedPeriod )</h3>
-
-<div id="download_buttons" style="margin-bottom:15px">
-<input type="button" value="$i18n.getString( 'get_report_as_xls' )" onclick="exportDataSetReport( 'xls' )" style="width:140px">
-<input type="button" value="$i18n.getString( 'get_report_as_pdf' )" onclick="exportDataSetReport( 'pdf' )" style="width:140px">
-#if( $registration ) <span>$i18n.getString( "completed_by" ): <a href="javascript:setUserInfo( '${registration.storedBy}' )">${registration.storedBy}</a></span>#end
-</div>
+#parse( "dhis-web-reporting/renderDataSetReportHeader.vm" )
<div>
#parse( "dhis-web-commons/ajax/htmlGrid.vm" )
=== modified file 'dhis-2/dhis-web/dhis-web-reporting/src/main/webapp/dhis-web-reporting/renderSectionDataSetReportForm.vm'
--- dhis-2/dhis-web/dhis-web-reporting/src/main/webapp/dhis-web-reporting/renderSectionDataSetReportForm.vm 2012-07-13 07:55:41 +0000
+++ dhis-2/dhis-web/dhis-web-reporting/src/main/webapp/dhis-web-reporting/renderSectionDataSetReportForm.vm 2012-09-03 19:48:33 +0000
@@ -7,18 +7,7 @@
}
</style>
-<input type="hidden" id="currentDataSetId" value="${selectedDataSet.id}">
-<input type="hidden" id="currentPeriodId" value="${selectedPeriod.externalId}">
-<input type="hidden" id="currentSelectedUnitOnly" value="${selectedUnitOnly}">
-<div id="userInfo" class="page"></div>
-
-<h3>$encoder.htmlEncode( $selectedOrgunit.name ) - $format.formatPeriod( $selectedPeriod )</h3>
-
-<div id="download_buttons" style="margin-bottom:15px">
-<input type="button" value="$i18n.getString( 'get_report_as_xls' )" onclick="exportDataSetReport( 'xls' )" style="width:140px">
-<input type="button" value="$i18n.getString( 'get_report_as_pdf' )" onclick="exportDataSetReport( 'pdf' )" style="width:140px">
-#if( $registration ) <span>$i18n.getString( "completed_by" ): <a href="javascript:setUserInfo( '${registration.storedBy}' )">${registration.storedBy}</a></span>#end
-</div>
+#parse( "dhis-web-reporting/renderDataSetReportHeader.vm" )
#foreach( $grid in $grids )
<div class="formSection" style="margin-bottom:30px">
=== modified file 'dhis-2/dhis-web/dhis-web-visualizer/src/main/resources/org/hisp/dhis/visualizer/i18n_module.properties'
--- dhis-2/dhis-web/dhis-web-visualizer/src/main/resources/org/hisp/dhis/visualizer/i18n_module.properties 2012-07-24 04:04:14 +0000
+++ dhis-2/dhis-web/dhis-web-visualizer/src/main/resources/org/hisp/dhis/visualizer/i18n_module.properties 2012-09-03 19:48:33 +0000
@@ -127,7 +127,7 @@
show_data = Show series data
share = Share
interpretation = interpretation
-write_your_interpretation = Write your interpretation
+write_your_interpretation = Write a comment, question or interpretation
interpretation_was_shared = Interpretation was shared
save_load_favorite_before_sharing = Please save or load a favorite before sharing
create_chart_before_datatable = Please create a chart before showing the datatable