← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 10119: Add Aggregate and Save button into Manual person aggregation

 

------------------------------------------------------------
revno: 10119
committer: Tran Chau <tran.hispvietnam@xxxxxxxxx>
branch nick: dhis2
timestamp: Sun 2013-03-10 22:03:37 +0700
message:
  Add Aggregate and Save button into Manual person aggregation
modified:
  dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/caseaggregation/CaseAggregationResultAction.java
  dhis-2/dhis-web/dhis-web-caseentry/src/main/resources/org/hisp/dhis/caseentry/i18n_module.properties
  dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/caseAggregationForm.vm
  dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/caseAggregationResult.vm
  dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/javascript/caseagg.js
  dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/addCaseAggregation.vm
  dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/updateCaseAggregation.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-caseentry/src/main/java/org/hisp/dhis/caseentry/action/caseaggregation/CaseAggregationResultAction.java'
--- dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/caseaggregation/CaseAggregationResultAction.java	2012-12-13 12:34:42 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/caseaggregation/CaseAggregationResultAction.java	2013-03-10 15:03:37 +0000
@@ -148,6 +148,18 @@
         this.endDate = endDate;
     }
 
+    private boolean autoSave;
+
+    public void setAutoSave( boolean autoSave )
+    {
+        this.autoSave = autoSave;
+    }
+
+    public boolean isAutoSave()
+    {
+        return autoSave;
+    }
+
     private Map<String, String> mapStatusValues = new HashMap<String, String>();
 
     public Map<String, String> getMapStatusValues()
@@ -232,7 +244,8 @@
         // Get selected periods list
         // ---------------------------------------------------------------------
 
-        CalendarPeriodType periodType = (CalendarPeriodType) CalendarPeriodType.getPeriodTypeByName( selectedDataSet.getPeriodType().getName() );
+        CalendarPeriodType periodType = (CalendarPeriodType) CalendarPeriodType.getPeriodTypeByName( selectedDataSet
+            .getPeriodType().getName() );
 
         periods.addAll( periodType.generatePeriods( format.parseDate( startDate ), format.parseDate( endDate ) ) );
 
@@ -263,18 +276,30 @@
                             dataValue = new DataValue( dElement, period, orgUnit, "" + resultValue, "", new Date(),
                                 null, optionCombo );
                             mapStatusValues.put( keyStatus, i18n.getString( ADD_STATUS ) );
+                            if ( autoSave )
+                            {
+                                dataValueService.addDataValue( dataValue );
+                            }
                         }
                         else
                         {
                             dataValue.setValue( "" + resultValue );
                             dataValue.setTimestamp( new Date() );
                             mapStatusValues.put( keyStatus, i18n.getString( UPDATE_STATUS ) );
+                            if ( autoSave )
+                            {
+                                dataValueService.updateDataValue( dataValue );
+                            }
                         }
                         mapCaseAggCondition.put( dataValue, condition );
                     }
                     else if ( dataValue != null )
                     {
                         mapStatusValues.put( keyStatus, i18n.getString( DELETE_STATUS ) );
+                        if ( autoSave )
+                        {
+                            dataValueService.deleteDataValue( dataValue );
+                        }
                     }
 
                     if ( dataValue != null )

=== modified file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/resources/org/hisp/dhis/caseentry/i18n_module.properties'
--- dhis-2/dhis-web/dhis-web-caseentry/src/main/resources/org/hisp/dhis/caseentry/i18n_module.properties	2013-03-08 08:47:35 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/resources/org/hisp/dhis/caseentry/i18n_module.properties	2013-03-10 15:03:37 +0000
@@ -593,4 +593,6 @@
 forms_completed_percent = Forms completed (%)
 visits_overdue = Visits overdue (#)
 visits_overdue_percent = Visits overdue (%)
-program_stages = Program stages
\ No newline at end of file
+program_stages = Program stages
+aggregate_and_save = Aggregate and Save
+preview = Preview
\ No newline at end of file

=== modified file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/caseAggregationForm.vm'
--- dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/caseAggregationForm.vm	2013-03-05 14:47:06 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/caseAggregationForm.vm	2013-03-10 15:03:37 +0000
@@ -9,6 +9,7 @@
 	<h1> $i18n.getString( "manual_person_aggregation_form" ) #openHelp('run_case_aggregation')</h1>
 	
 	<form id="caseAggregationForm" name="caseAggregationForm" action="caseAggregationResult.action" method="post">
+		<input type='hidden' id='autoSave' name='autoSave' value='false' />
 		<table>
 			<tr>
 				<td>
@@ -63,10 +64,10 @@
 			</tr>
 
 			<tr>
-				<td>
-					<input type="submit" name="Aggregate" value="$i18n.getString( 'aggregate' )"/></td>
+				<td colspan='2'>
+					<input type="submit" name="aggregateAndSaveBtn" value="$i18n.getString( 'aggregate_and_save' )" onclick="setFieldValue('autoSave', true)" >
+					<input type="submit" name="aggregateBtn" value="$i18n.getString( 'preview' )" onclick="setFieldValue('autoSave', false)" >
 				</td>
-				<td></td>
 			</tr>
 		</table>
 	</form>

=== modified file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/caseAggregationResult.vm'
--- dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/caseAggregationResult.vm	2012-12-14 17:07:44 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/caseAggregationResult.vm	2013-03-10 15:03:37 +0000
@@ -2,8 +2,10 @@
 #if($orgunits.size()>0)
 	<div>
 		<input type="button" value="$i18n.getString( 'back' )" onclick="backBtnOnClick();" style="width:10em">
+		#if($autoSave=='false')
 		<input type='button' value="$i18n.getString( 'save_selected_values' )" onclick='saveAggregateDataValues( false )' >
 		<input type='button' value="$i18n.getString( 'save_all_values' )" onclick='saveAggregateDataValues( true )' >
+		#end
 	</div>
 	<p></p>
 
@@ -23,8 +25,12 @@
 			
 				#set( $dataValues = $mapDataValues.get( $key ) ) 
 				<table class="formSection mainPageTable hidden" id='$periodDiv'>
-					<col width="40">          
+					<col width="40"> 
+					
+					#if($autoSave=='false')
 					<col>
+					#end
+					
 					<col>
 					<col>
 					<tbody>
@@ -32,7 +38,11 @@
 					#set($no = 1)
 						<tr>
 							<th>#</th>
+							
+							#if($autoSave=='false')
 							<th><input type='checkbox' onchange="toogleAllCheckBoxes( '$periodDiv', this.checked );"></th>
+							#end
+							
 							<th>$i18n.getString('name')</th>
 							<th>$i18n.getString('value')</th>
 							<th>$i18n.getString('status')</th>
@@ -42,10 +52,14 @@
 							#set( $statusKey = $key + '-' + $dataValue.dataElement.id )
 							<tr #alternate( $mark )>
 								<td>$no</td>
+								
+								#if($autoSave=='false')
 								<td>
 									#set( $item=$dataValue.dataElement.id + '_' + $dataValue.optionCombo.id + '_' + $period.periodType.name + '_' + $format.formatDate($period.startDate) + '_' + $orgunit.id + '_' + $dataValue.value )
 									<input type='checkbox' name='aggregateValues' value='$item'>
 								</td>
+								#end
+								
 								<td>$dataValue.dataElement.name</td>
 								<td>$dataValue.value</td>
 								<td>$!mapStatusValues.get( $statusKey )</td>

=== modified file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/javascript/caseagg.js'
--- dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/javascript/caseagg.js	2012-12-10 12:54:54 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/javascript/caseagg.js	2013-03-10 15:03:37 +0000
@@ -46,7 +46,8 @@
 			facilityLB: getFieldValue('facilityLB'),
 			dataSetId: getFieldValue('dataSetId'),
 			startDate: getFieldValue('startDate'),
-			endDate: getFieldValue('endDate')
+			endDate: getFieldValue('endDate'),
+			autoSave: getFieldValue('autoSave')
 		}
 		, function(){
 			$( "#loaderDiv" ).hide();

=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/addCaseAggregation.vm'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/addCaseAggregation.vm	2013-02-21 03:26:10 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/addCaseAggregation.vm	2013-03-10 15:03:37 +0000
@@ -51,7 +51,7 @@
 	<tr>
 		<td><label for="operator">$i18n.getString( "operator" )</label></td>
 		<td>
-			<input type="radio" id="operator" name="operator" value="COUNT" checked onchange='operatorOnchange(this.value)'>$i18n.getString('number_of_patients')<br>
+			<input type="radio" id="operator" name="operator" value="COUNT" checked onchange='operatorOnchange(this.value)'> $i18n.getString('number_of_patients')<br>
 			<input type="radio" id="operator" name="operator" value="times" onchange='operatorOnchange(this.value)'> $i18n.getString('number_of_visits')<br>
 			<input type="radio" id="operator" name="operator" value="sum" onchange='operatorOnchange(this.value)'> $i18n.getString('sum_dataelement_value')<br>
 			<input type="radio" id="operator" name="operator" value="avg" onchange='operatorOnchange(this.value)'> $i18n.getString('avg_dataelement_value')<br>

=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/updateCaseAggregation.vm'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/updateCaseAggregation.vm	2013-02-21 03:26:10 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/updateCaseAggregation.vm	2013-03-10 15:03:37 +0000
@@ -49,7 +49,7 @@
 	<tr>
 		<td><label for="operator">$i18n.getString( "operator" )</label></td>
 		<td>
-			<input type="radio" id="operator" name="operator" value="COUNT" onchange='operatorOnchange(this.value)' #if($caseAggregation.operator=="COUNT") checked #end >  $i18n.getString('number_of_patients')<br>
+			<input type="radio" id="operator" name="operator" value="COUNT" onchange='operatorOnchange(this.value)' #if($caseAggregation.operator=="COUNT") checked #end > $i18n.getString('number_of_patients')<br>
 			<input type="radio" id="operator" name="operator" value="times" onchange='operatorOnchange(this.value)' #if($caseAggregation.operator=="times") checked #end > $i18n.getString('number_of_visits')<br>
 			<input type="radio" id="operator" name="operator" value="sum" onchange='operatorOnchange(this.value)' #if($caseAggregation.operator=="sum") checked #end > $i18n.getString('sum_dataelement_value')<br>
 			<input type="radio" id="operator" name="operator" value="avg" onchange='operatorOnchange(this.value)' #if($caseAggregation.operator=="avg") checked #end > $i18n.getString('avg_dataelement_value')<br>