=== 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-05-31 18:16:45 +0000 +++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/interpretation/Interpretation.java 2012-05-31 21:51:26 +0000 @@ -38,6 +38,7 @@ import org.hisp.dhis.common.annotation.Scanned; import org.hisp.dhis.common.view.DetailedView; import org.hisp.dhis.common.view.ExportView; +import org.hisp.dhis.organisationunit.OrganisationUnit; import org.hisp.dhis.reporttable.ReportTable; import org.hisp.dhis.user.User; @@ -56,6 +57,8 @@ private ReportTable reportTable; + private OrganisationUnit organisationUnit; // Applicable to report table only + private String text; private User user; @@ -81,9 +84,10 @@ this.created = new Date(); } - public Interpretation( ReportTable reportTable, String text ) + public Interpretation( ReportTable reportTable, OrganisationUnit organisationUnit, String text ) { this.reportTable = reportTable; + this.organisationUnit = organisationUnit; this.text = text; this.created = new Date(); } @@ -97,6 +101,16 @@ this.comments.add( comment ); } + public boolean isChartInterpretation() + { + return chart != null; + } + + public boolean isReportTableInterpretation() + { + return reportTable != null; + } + // ------------------------------------------------------------------------- // Get and set methods // ------------------------------------------------------------------------- @@ -130,6 +144,20 @@ } @JsonProperty + @JsonDeserialize( as = BaseIdentifiableObject.class ) + @JsonView( { DetailedView.class, ExportView.class } ) + @JacksonXmlProperty( namespace = Dxf2Namespace.NAMESPACE ) + public OrganisationUnit getOrganisationUnit() + { + return organisationUnit; + } + + public void setOrganisationUnit( OrganisationUnit organisationUnit ) + { + this.organisationUnit = organisationUnit; + } + + @JsonProperty @JsonView( { DetailedView.class, ExportView.class } ) @JacksonXmlProperty( namespace = Dxf2Namespace.NAMESPACE ) public String getText() === modified file 'dhis-2/dhis-services/dhis-service-reporting/src/main/resources/org/hisp/dhis/interpretation/hibernate/Interpretation.hbm.xml' --- dhis-2/dhis-services/dhis-service-reporting/src/main/resources/org/hisp/dhis/interpretation/hibernate/Interpretation.hbm.xml 2012-05-31 18:16:45 +0000 +++ dhis-2/dhis-services/dhis-service-reporting/src/main/resources/org/hisp/dhis/interpretation/hibernate/Interpretation.hbm.xml 2012-05-31 21:51:26 +0000 @@ -20,7 +20,10 @@ - + + + getEntityList( WebMetaData metaData, WebOptions options ) { @@ -97,13 +103,15 @@ } @RequestMapping( value = "/chart/{uid}", method = RequestMethod.POST, consumes = { "text/html", "text/plain" } ) - public void shareChartInterpretation( @PathVariable( "uid" ) String chartUid, @RequestBody String text, HttpServletResponse response ) throws IOException + public void shareChartInterpretation( + @PathVariable( "uid" ) String chartUid, + @RequestBody String text, HttpServletResponse response ) throws IOException { Chart chart = chartService.getChart( chartUid ); if ( chart == null ) { - ContextUtils.conflictResponse( response, "Chart identifier not valid" ); + ContextUtils.conflictResponse( response, "Chart identifier not valid: " + chartUid); return; } @@ -115,17 +123,33 @@ } @RequestMapping( value = "/reportTable/{uid}", method = RequestMethod.POST, consumes = { "text/html", "text/plain" } ) - public void shareReportTableInterpretation( @PathVariable( "uid" ) String reportTableUid, @RequestBody String text, HttpServletResponse response ) throws IOException + public void shareReportTableInterpretation( + @PathVariable( "uid" ) String reportTableUid, + @RequestParam( value = "ou", required = false ) String orgUnitUid, + @RequestBody String text, HttpServletResponse response ) throws IOException { ReportTable reportTable = reportTableService.getReportTable( reportTableUid ); if ( reportTable == null ) { - ContextUtils.conflictResponse( response, "Report table identifier not valid" ); + ContextUtils.conflictResponse( response, "Report table identifier not valid: " + reportTableUid ); return; } - Interpretation interpretation = new Interpretation( reportTable, text ); + OrganisationUnit orgUnit = null; + + if ( orgUnitUid != null ) + { + orgUnit = organisationUnitService.getOrganisationUnit( orgUnitUid ); + + if ( orgUnit == null ) + { + ContextUtils.conflictResponse( response, "Organisation unit identifier not valid: " + orgUnitUid ); + return; + } + } + + Interpretation interpretation = new Interpretation( reportTable, orgUnit, text ); interpretationService.saveInterpretation( interpretation ); @@ -133,7 +157,9 @@ } @RequestMapping( value = "/{uid}/comment", method = RequestMethod.POST, consumes = { "text/html", "text/plain" } ) - public void postComment( @PathVariable( "uid" ) String uid, @RequestBody String text, HttpServletResponse response ) throws IOException + public void postComment( + @PathVariable( "uid" ) String uid, + @RequestBody String text, HttpServletResponse response ) throws IOException { interpretationService.addInterpretationComment( uid, text ); === 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-05-29 21:23:47 +0000 +++ dhis-2/dhis-web/dhis-web-dashboard-integration/src/main/resources/org/hisp/dhis/dashboard/i18n_module.properties 2012-05-31 21:51:26 +0000 @@ -40,4 +40,5 @@ data_visualizer=Data Visualizer add_a_comment=Add a comment new_interpretations=new interpretations -new_interpretation=new interpretation \ No newline at end of file +new_interpretation=new interpretation +click_to_view_report_table=Click to view report table \ 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-05-31 20:29:41 +0000 +++ dhis-2/dhis-web/dhis-web-dashboard-integration/src/main/webapp/dhis-web-dashboard-integration/interpretation.vm 2012-05-31 21:51:26 +0000 @@ -14,12 +14,19 @@
${ip.text}
+ #if( $ip.chartInterpretation )
+ #else +
+ #if( $ip.organisationUnit )#set( $ou = "&ou=" + $ip.organisationUnit.uid )#else#set( $ou = "" )#end + $encoder.htmlEncode( $ip.reportTable.name ) +
+ #end #set( $comments = $ip.comments )
@@ -36,7 +43,7 @@
#end -
+ === modified file 'dhis-2/dhis-web/dhis-web-dashboard-integration/src/main/webapp/dhis-web-dashboard-integration/javascript/interpretation.js' --- dhis-2/dhis-web/dhis-web-dashboard-integration/src/main/webapp/dhis-web-dashboard-integration/javascript/interpretation.js 2012-05-29 21:23:47 +0000 +++ dhis-2/dhis-web/dhis-web-dashboard-integration/src/main/webapp/dhis-web-dashboard-integration/javascript/interpretation.js 2012-05-31 21:51:26 +0000 @@ -23,20 +23,23 @@ var created = getCurrentDate(); - $.ajax( url, { - type: "POST", - contentType: "text/html", - data: text, - success: function() { - var template = - "
${userName}<\/span>  " + - "${created}<\/span><\/div><\/div>" + - "
${text}<\/div>"; - - $.tmpl( template, { "userId": currentUser.id, "userName": currentUser.name, created: created, text: text } ).appendTo( "#comments" + uid ); - - $( "#commentArea" + uid ).val( "" ); - } - } ); + if ( text.length && $.trim( text ).length ) + { + $.ajax( url, { + type: "POST", + contentType: "text/html", + data: $.trim( text ), + success: function() { + var template = + "
${userName}<\/span>  " + + "${created}<\/span><\/div><\/div>" + + "
${text}<\/div>"; + + $.tmpl( template, { "userId": currentUser.id, "userName": currentUser.name, created: created, text: text } ).appendTo( "#comments" + uid ); + + $( "#commentArea" + uid ).val( "" ); + } + } ); + } } \ No newline at end of file === modified file 'dhis-2/dhis-web/dhis-web-dashboard-integration/src/main/webapp/dhis-web-dashboard-integration/style/dashboard.css' --- dhis-2/dhis-web/dhis-web-dashboard-integration/src/main/webapp/dhis-web-dashboard-integration/style/dashboard.css 2012-05-29 19:30:37 +0000 +++ dhis-2/dhis-web/dhis-web-dashboard-integration/src/main/webapp/dhis-web-dashboard-integration/style/dashboard.css 2012-05-31 21:51:26 +0000 @@ -166,20 +166,19 @@ .interpretationText { - margin-bottom: 18px; + margin-bottom: 16px; } .interpretationChart { - margin-bottom: 12px; + margin-bottom: 16px; } .interpretationCommentArea { margin-top: 10px; padding: 18px 20px 14px 20px; - background-color: #f2f3f4; - border: 1px solid #d5d5d5; + background-color: #eef1f3; border-radius: 3px; } === modified file 'dhis-2/dhis-web/dhis-web-reporting/src/main/java/org/hisp/dhis/reporting/tablecreator/action/ExportTableAction.java' --- dhis-2/dhis-web/dhis-web-reporting/src/main/java/org/hisp/dhis/reporting/tablecreator/action/ExportTableAction.java 2012-05-31 20:29:41 +0000 +++ dhis-2/dhis-web/dhis-web-reporting/src/main/java/org/hisp/dhis/reporting/tablecreator/action/ExportTableAction.java 2012-05-31 21:51:26 +0000 @@ -81,7 +81,23 @@ { this.format = format; } - + + // ------------------------------------------------------------------------- + // Input + // ------------------------------------------------------------------------- + + private String uid; + + public String getUid() + { + return uid; + } + + public void setUid( String uid ) + { + this.uid = uid; + } + private String pe; public void setPe( String pe ) @@ -91,27 +107,16 @@ private String ou; + public String getOu() + { + return ou; + } + public void setOu( String ou ) { this.ou = ou; } - - // ------------------------------------------------------------------------- - // Input - // ------------------------------------------------------------------------- - - private String uid; - - public String getUid() - { - return uid; - } - - public void setUid( String uid ) - { - this.uid = uid; - } - + private String type; public void setType( String type ) === modified file 'dhis-2/dhis-web/dhis-web-reporting/src/main/webapp/dhis-web-reporting/javascript/generateReport.js' --- dhis-2/dhis-web/dhis-web-reporting/src/main/webapp/dhis-web-reporting/javascript/generateReport.js 2012-05-31 20:29:41 +0000 +++ dhis-2/dhis-web/dhis-web-reporting/src/main/webapp/dhis-web-reporting/javascript/generateReport.js 2012-05-31 21:51:26 +0000 @@ -84,14 +84,18 @@ } ); } -function shareInterpretation( uid ) +function shareInterpretation( uid, ou ) { var text = $( "#interpretationArea" ).val(); - if ( text.length ) + if ( text.length && $.trim( text ).length ) { + text = $.trim( text ); + var url = "../api/interpretations/reportTable/" + uid; + url += ( ou && ou.length ) ? "?ou=" + ou : ""; + $.ajax( url, { type: "POST", contentType: "text/html", === modified file 'dhis-2/dhis-web/dhis-web-reporting/src/main/webapp/dhis-web-reporting/reportTableGrid.vm' --- dhis-2/dhis-web/dhis-web-reporting/src/main/webapp/dhis-web-reporting/reportTableGrid.vm 2012-05-31 20:29:41 +0000 +++ dhis-2/dhis-web/dhis-web-reporting/src/main/webapp/dhis-web-reporting/reportTableGrid.vm 2012-05-31 21:51:26 +0000 @@ -22,5 +22,5 @@
- +
\ No newline at end of file