← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 14616: Data set report, javascript functions with namespace

 

------------------------------------------------------------
revno: 14616
committer: Lars Helge Øverland <larshelge@xxxxxxxxx>
branch nick: dhis2
timestamp: Wed 2014-04-02 17:07:20 +0200
message:
  Data set report, javascript functions with namespace
modified:
  dhis-2/dhis-web/dhis-web-reporting/src/main/webapp/dhis-web-reporting/dataApprovalForm.vm
  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/renderDataSetReportHeader.vm
  dhis-2/dhis-web/dhis-web-reporting/src/main/webapp/dhis-web-reporting/viewDataCompletenessForm.vm


--
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/webapp/dhis-web-reporting/dataApprovalForm.vm'
--- dhis-2/dhis-web/dhis-web-reporting/src/main/webapp/dhis-web-reporting/dataApprovalForm.vm	2014-04-02 12:33:53 +0000
+++ dhis-2/dhis-web/dhis-web-reporting/src/main/webapp/dhis-web-reporting/dataApprovalForm.vm	2014-04-02 15:07:20 +0000
@@ -0,0 +1,108 @@
+<script type="text/javascript">
+jQuery(document).ready(function() {        
+            
+  #if( $render == true )
+  var dataSetReport = {
+    dataSet: "${ds}",
+    periodType: "${periodType.name}",
+    period: "${pe}",
+    offset: ${offset}
+  };
+  dhis2.dsr.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_select_option_view_all = '$encoder.jsEscape( $i18n.getString( "select_option_view_all" ) , "'")';
+var i18n_waiting_for_lower_level_approval = '$encoder.jsEscape( $i18n.getString( "waiting_for_lower_level_approval" ) , "'")';
+var i18n_ready_for_approval = '$encoder.jsEscape( $i18n.getString( "ready_for_approval" ) , "'")';
+var i18n_approved = '$encoder.jsEscape( $i18n.getString( "approved" ) , "'")';
+var i18n_approved_and_accepted = '$encoder.jsEscape( $i18n.getString( "approved_and_accepted" ) , "'")';
+var i18n_confirm_approval = '$encoder.jsEscape( $i18n.getString( "confirm_approval" ) , "'")';
+var i18n_confirm_unapproval = '$encoder.jsEscape( $i18n.getString( "confirm_unapproval" ) , "'")';
+var i18n_confirm_accept = '$encoder.jsEscape( $i18n.getString( "confirm_accept" ) , "'")';
+var i18n_confirm_unaccept = '$encoder.jsEscape( $i18n.getString( "confirm_unaccept" ) , "'")';
+</script>
+
+<style type="text/css">
+div#control {
+  margin-bottom: 15px;
+}
+
+div.inputSection {
+  padding-top: 7px;
+  padding-bottom: 5px;
+}
+</style>
+
+<h3 id="dataSetReportHeader">$i18n.getString( "dataset_report" ) #openHelp( "dataset_reports" )</h3>
+
+<div id="control">
+<input type="button" value='$i18n.getString( "data" )' style="width:140px" onclick="dhis2.dsr.showCriteria()">
+<input type="button" id="approveButton" value="$i18n.getString( 'approve' )" onclick="dhis2.dsr.approveData()" style="width:120px">
+<input type="button" id="unapproveButton" value="$i18n.getString( 'unapprove' )" onclick="dhis2.dsr.unapproveData()" style="width:120px">
+<input type="button" id="acceptButton" value="$i18n.getString( 'accept' )" onclick="dhis2.dsr.acceptData()" style="width:120px">
+<input type="button" id="unacceptButton" value="$i18n.getString( 'unaccept' )" onclick="dhis2.dsr.unacceptData()" style="width:120px">
+</div>
+
+<div id="criteria" class="inputCriteria" style="width:360px;">
+
+<!-- Data set -->
+
+<div class="inputSection">
+<label>$i18n.getString( "dataset" )</label><br>
+<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-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 -->
+
+<div class="inputSection">
+<label>$i18n.getString( "report_period" )</label><br>
+<select id="periodType" name="periodType" style="width:174px" onchange="dhis2.dsr.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="dhis2.dsr.displayPreviousPeriods()" />
+<input type="button" style="width:75px" value="$i18n.getString( 'next_year' )" onclick="dhis2.dsr.displayNextPeriods()" /><br>
+
+<select id="periodId" name="periodId" style="width:330px" disabled="disabled">
+</select>
+</div>
+
+<!-- Organisation unit -->
+
+<div class="inputSection">
+<label>$i18n.getString( "use_data_for_selected_unit_only" )</label>
+<input type="checkbox" id="selectedUnitOnly" name="selectedUnitOnly" value="true">
+</div>
+
+<div class="inputSection">
+<label>$i18n.getString( "report_organisation_unit" )</label><br>
+<div id="selectionTree" style="width:328px; height:200px; overflow:auto; border:1px solid #ccc; margin-bottom: 8px;"></div>
+</div>
+
+</div>
+
+#parse( "dhis-web-commons/loader/loader.vm" )
+
+<div id="content"></div>
+

=== 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-04-02 14:21:37 +0000
+++ dhis-2/dhis-web/dhis-web-reporting/src/main/webapp/dhis-web-reporting/dataSetReportForm.vm	2014-04-02 15:07:20 +0000
@@ -8,7 +8,7 @@
     period: "${pe}",
     offset: ${offset}
   };
-  setDataSetReport( dataSetReport );	  	
+  dhis2.dsr.setDataSetReport( dataSetReport );	  	
   #else
   selectionTreeSelection.setMultipleSelectionAllowed( false );
   selectionTree.clearSelectedOrganisationUnits();
@@ -86,16 +86,16 @@
 <h3 id="dataSetReportHeader">$i18n.getString( "dataset_report" ) #openHelp( "dataset_reports" )</h3>
 
 <div id="control">
-<input type="button" value='$i18n.getString( "data" )' style="width:140px" onclick="showCriteria()">
-<input type="button" class="downloadButton" value="$i18n.getString( 'get_report_as_xls' )" onclick="exportDataSetReport( 'xls' )" style="width:140px; display:none;">
-<input type="button" class="downloadButton" value="$i18n.getString( 'get_report_as_pdf' )" onclick="exportDataSetReport( 'pdf' )" style="width:140px; display:none;">
+<input type="button" value='$i18n.getString( "data" )' style="width:140px" onclick="dhis2.dsr.showCriteria()">
+<input type="button" class="downloadButton" value="$i18n.getString( 'get_report_as_xls' )" onclick="dhis2.dsr.exportDataSetReport( 'xls' )" style="width:140px; display:none;">
+<input type="button" class="downloadButton" value="$i18n.getString( 'get_report_as_pdf' )" onclick="dhis2.dsr.exportDataSetReport( 'pdf' )" style="width:140px; display:none;">
 <input type="button" class="downloadButton" value="$i18n.getString( 'print' )" onclick="window.print()" style="width:140px; display:none;">
 </div>
 
+<div id="criteria" class="inputCriteria" style="width:360px;">
+
 <!-- 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" onchange="dhis2.dsr.dataSetSelected()">
@@ -115,14 +115,14 @@
 
 <div class="inputSection">
 <label>$i18n.getString( "report_period" )</label><br>
-<select id="periodType" name="periodType" style="width:174px" onchange="displayPeriods()">
+<select id="periodType" name="periodType" style="width:174px" onchange="dhis2.dsr.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="displayPreviousPeriods()" />
-<input type="button" style="width:75px" value="$i18n.getString( 'next_year' )" onclick="displayNextPeriods()" /><br>
+<input type="button" style="width:75px" value="$i18n.getString( 'prev_year' )" onclick="dhis2.dsr.displayPreviousPeriods()" />
+<input type="button" style="width:75px" value="$i18n.getString( 'next_year' )" onclick="dhis2.dsr.displayNextPeriods()" /><br>
 
 <select id="periodId" name="periodId" style="width:330px" disabled="disabled">
 </select>
@@ -154,11 +154,11 @@
 </select></div>
 #end </div>
 
-<div id="moreOptionsLink" style="padding: 8px 0;"><a href="javascript:showMoreOptions()">$i18n.getString( "show_more_options" )</a></div>
-<div id="lessOptionsLink" style="display: none; padding: 8px 0;"><a href="javascript:showLessOptions()">$i18n.getString( "show_less_options" )</a></div>
+<div id="moreOptionsLink" style="padding: 8px 0;"><a href="javascript:dhis2.dsr.showMoreOptions()">$i18n.getString( "show_more_options" )</a></div>
+<div id="lessOptionsLink" style="display: none; padding: 8px 0;"><a href="javascript:dhis2.dsr.showLessOptions()">$i18n.getString( "show_less_options" )</a></div>
 
 <div class="inputSection">
-<input type="button" value='$i18n.getString( "get_report" )' style="width:120px" onclick="generateDataSetReport()">
+<input type="button" value='$i18n.getString( "get_report" )' style="width:120px" onclick="dhis2.dsr.generateDataSetReport()">
 <input type="button" value='$i18n.getString( "cancel" )' style="width:120px" onclick="hideCriteria()">
 </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	2014-03-31 18:12:00 +0000
+++ dhis-2/dhis-web/dhis-web-reporting/src/main/webapp/dhis-web-reporting/javascript/dataSetReport.js	2014-04-02 15:07:20 +0000
@@ -1,4 +1,7 @@
 
+/**
+ * This file is used by dataSetReportForm.vm and dataApprovalForm.vm.
+ */
 dhis2.util.namespace( 'dhis2.dsr' );
 
 dhis2.dsr.currentPeriodOffset = 0;
@@ -10,7 +13,7 @@
 // Get and set methods
 //------------------------------------------------------------------------------
 
-function getDataSetReport()
+dhis2.dsr.getDataSetReport = function()
 {
 	var ds = $( "#dataSetId" ).val();
 	
@@ -45,14 +48,14 @@
     return dataSetReport;
 }
 
-function setDataSetReport( dataSetReport )
+dhis2.dsr.setDataSetReport = function( dataSetReport )
 {
 	$( "#dataSetId" ).val( dataSetReport.dataSet );
 	$( "#periodType" ).val( dataSetReport.periodType );
 	
 	dhis2.dsr.currentPeriodOffset = dataSetReport.offset;
 	
-	displayPeriods();
+	dhis2.dsr.displayPeriods();
 	$( "#periodId" ).val( dataSetReport.period );
 	
 	selectionTreeSelection.setMultipleSelectionAllowed( false );
@@ -61,7 +64,7 @@
 	$( "body" ).on( "oust.selected", function() 
 	{
 		$( "body" ).off( "oust.selected" );
-		generateDataSetReport();
+		dhis2.dsr.generateDataSetReport();
 	} );
 }
 
@@ -177,7 +180,7 @@
 // Period
 //------------------------------------------------------------------------------
 
-function displayPeriods()
+dhis2.dsr.displayPeriods = function()
 {
     var periodType = $( "#periodType" ).val();
     var periods = dhis2.dsr.periodTypeFactory.get( periodType ).generatePeriods( dhis2.dsr.currentPeriodOffset );
@@ -193,42 +196,42 @@
     }
 }
 
-function displayNextPeriods()
+dhis2.dsr.displayNextPeriods = function()
 {
     if ( dhis2.dsr.currentPeriodOffset < 0 ) // Cannot display future periods
     {
         dhis2.dsr.currentPeriodOffset++;
-        displayPeriods();
+        dhis2.dsr.displayPeriods();
     }
 }
 
-function displayPreviousPeriods()
+dhis2.dsr.displayPreviousPeriods = function()
 {
     dhis2.dsr.currentPeriodOffset--;
-    displayPeriods();
+    dhis2.dsr.displayPeriods();
 }
 
 //------------------------------------------------------------------------------
 // Run report
 //------------------------------------------------------------------------------
 
-function drillDownDataSetReport( orgUnitId, orgUnitUid )
+dhis2.dsr.drillDownDataSetReport = function( orgUnitId, orgUnitUid )
 {
 	selectionTree.clearSelectedOrganisationUnits();
 	selectionTreeSelection.select( orgUnitId );
 	
-	var dataSetReport = getDataSetReport();
+	var dataSetReport = dhis2.dsr.getDataSetReport();
 	dataSetReport["ou"] = orgUnitUid;
-	displayDataSetReport( dataSetReport );
+	dhis2.dsr.displayDataSetReport( dataSetReport );
 }
 
-function generateDataSetReport()
+dhis2.dsr.generateDataSetReport = function()
 {
-	var dataSetReport = getDataSetReport();
-	displayDataSetReport( dataSetReport );
+	var dataSetReport = dhis2.dsr.getDataSetReport();
+	dhis2.dsr.displayDataSetReport( dataSetReport );
 }
 
-function displayDataSetReport( dataSetReport )
+dhis2.dsr.displayDataSetReport = function( dataSetReport )
 {	
     if ( !dataSetReport.ds )
     {
@@ -249,8 +252,8 @@
     dhis2.dsr.currentDataSetReport = dataSetReport;
     
     hideHeaderMessage();
-    hideCriteria();
-    hideContent();
+    dhis2.dsr.hideCriteria();
+    dhis2.dsr.hideContent();
     showLoader();
 	    
     var url = dhis2.dsr.getDataSetReportUrl( dataSetReport );
@@ -258,7 +261,7 @@
     $.get( url, function( data ) {
     	$( '#content' ).html( data );
     	hideLoader();
-    	showContent();
+    	dhis2.dsr.showContent();
     	dhis2.dsr.showApproval();
     	setTableStyles();
     } );
@@ -330,7 +333,7 @@
     return url;
 }
 
-function exportDataSetReport( type )
+dhis2.dsr.exportDataSetReport = function( type )
 {
 	var dataSetReport = dhis2.dsr.currentDataSetReport;
 	
@@ -339,7 +342,7 @@
 	window.location.href = url;
 }
 
-function setUserInfo( username )
+dhis2.dsr.setUserInfo = function( username )
 {
 	$( "#userInfo" ).load( "../dhis-web-commons-ajax-html/getUser.action?username=" + username, function() {
 		$( "#userInfo" ).dialog( {
@@ -351,37 +354,37 @@
 	} );	
 }
 
-function showCriteria()
+dhis2.dsr.showCriteria = function()
 {
 	$( "#criteria" ).show( "fast" );
 }
 
-function hideCriteria()
+dhis2.dsr.hideCriteria = function()
 {
 	$( "#criteria" ).hide( "fast" );
 }
 
-function showContent()
+dhis2.dsr.showContent = function()
 {
 	$( "#content" ).show( "fast" );
 	$( ".downloadButton" ).show();
 	$( "#interpretationArea" ).autogrow();
 }
 
-function hideContent()
+dhis2.dsr.hideContent = function()
 {
 	$( "#content" ).hide( "fast" );
 	$( ".downloadButton" ).hide();
 }
 
-function showMoreOptions()
+dhis2.dsr.showMoreOptions = function()
 {
 	$( "#moreOptionsLink" ).hide();
 	$( "#lessOptionsLink" ).show();
 	$( "#advancedOptions" ).show();
 }
 
-function showLessOptions()
+dhis2.dsr.showLessOptions = function()
 {
 	$( "#moreOptionsLink" ).show();
 	$( "#lessOptionsLink" ).hide();
@@ -588,9 +591,9 @@
 // Share
 //------------------------------------------------------------------------------
 
-function shareInterpretation()
+dhis2.dsr.shareInterpretation = function()
 {
-	var dataSetReport = getDataSetReport();
+	var dataSetReport = dhis2.dsr.getDataSetReport();
     var text = $( "#interpretationArea" ).val();
     
     if ( text.length && $.trim( text ).length )

=== modified 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	2013-12-28 15:41:14 +0000
+++ dhis-2/dhis-web/dhis-web-reporting/src/main/webapp/dhis-web-reporting/renderDataSetReportHeader.vm	2014-04-02 15:07:20 +0000
@@ -11,5 +11,5 @@
 <div id="shareForm">
 <textarea id="interpretationArea" class="interpretationArea" placeholder="$i18n.getString( 'write_your_interpretation_of_report' )"></textarea>
 <span id="approvalNotification" class="message message-info" style="display:none"></span><br>
-<input type="button" value="$i18n.getString( 'share' )" onclick="shareInterpretation( '${uid}', '$!{ou}' )" style="width:120px">
+<input type="button" value="$i18n.getString( 'share' )" onclick="dhis2.dsr.shareInterpretation( '${uid}', '$!{ou}' )" style="width:120px">
 </div>

=== modified file 'dhis-2/dhis-web/dhis-web-reporting/src/main/webapp/dhis-web-reporting/viewDataCompletenessForm.vm'
--- dhis-2/dhis-web/dhis-web-reporting/src/main/webapp/dhis-web-reporting/viewDataCompletenessForm.vm	2013-10-22 10:29:16 +0000
+++ dhis-2/dhis-web/dhis-web-reporting/src/main/webapp/dhis-web-reporting/viewDataCompletenessForm.vm	2014-04-02 15:07:20 +0000
@@ -63,7 +63,7 @@
     <!-- Get report -->
     
     <input id="reportButton" type="button" value="$i18n.getString( 'get_report' )" style="width:135px" onclick="displayCompleteness()"/> &nbsp;
-    <a id="advancedOptionsLink" href="javascript:showAdvancedOptions()">$i18n.getString( "more_options" )</a><br><br>
+    <a id="advancedOptionsLink" href="javascript:showAdvancedOptions()">$i18n.getString( "show_more_options" )</a><br><br>
     
     <!-- Export -->