← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 4225: Made the history popup in data entry a modal jquery ui dialog

 

------------------------------------------------------------
revno: 4225
committer: Lars Helge Overland <larshelge@xxxxxxxxx>
branch nick: dhis2
timestamp: Thu 2011-07-28 09:15:09 +0200
message:
  Made the history popup in data entry a modal jquery ui dialog
modified:
  dhis-2/dhis-web/dhis-web-dashboard-integration/src/main/webapp/dhis-web-dashboard-integration/javascript/readMessage.js
  dhis-2/dhis-web/dhis-web-dataentry/src/main/java/org/hisp/dhis/de/action/GetHistoryChartAction.java
  dhis-2/dhis-web/dhis-web-dataentry/src/main/java/org/hisp/dhis/de/action/HistoryAction.java
  dhis-2/dhis-web/dhis-web-dataentry/src/main/resources/struts.xml
  dhis-2/dhis-web/dhis-web-dataentry/src/main/webapp/dhis-web-dataentry/history.vm
  dhis-2/dhis-web/dhis-web-dataentry/src/main/webapp/dhis-web-dataentry/javascript/form.js
  dhis-2/dhis-web/dhis-web-dataentry/src/main/webapp/dhis-web-dataentry/javascript/history.js
  dhis-2/dhis-web/dhis-web-dataentry/src/main/webapp/dhis-web-dataentry/select.vm
  dhis-2/dhis-web/dhis-web-dataentry/src/main/webapp/dhis-web-dataentry/style/dhis-web-dataentry.css


--
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-dashboard-integration/src/main/webapp/dhis-web-dashboard-integration/javascript/readMessage.js'
--- dhis-2/dhis-web/dhis-web-dashboard-integration/src/main/webapp/dhis-web-dashboard-integration/javascript/readMessage.js	2011-06-22 18:29:52 +0000
+++ dhis-2/dhis-web/dhis-web-dashboard-integration/src/main/webapp/dhis-web-dashboard-integration/javascript/readMessage.js	2011-07-28 07:15:09 +0000
@@ -2,7 +2,6 @@
 
 $( document ).ready( function()
 {
-
     dialog = $( "#senderInfo" ).dialog( {
         modal : true,
         autoOpen : false,

=== modified file 'dhis-2/dhis-web/dhis-web-dataentry/src/main/java/org/hisp/dhis/de/action/GetHistoryChartAction.java'
--- dhis-2/dhis-web/dhis-web-dataentry/src/main/java/org/hisp/dhis/de/action/GetHistoryChartAction.java	2011-07-20 21:38:30 +0000
+++ dhis-2/dhis-web/dhis-web-dataentry/src/main/java/org/hisp/dhis/de/action/GetHistoryChartAction.java	2011-07-28 07:15:09 +0000
@@ -131,7 +131,7 @@
         return width;
     }
 
-    private int height = 330;
+    private int height = 300;
 
     public int getHeight()
     {

=== modified file 'dhis-2/dhis-web/dhis-web-dataentry/src/main/java/org/hisp/dhis/de/action/HistoryAction.java'
--- dhis-2/dhis-web/dhis-web-dataentry/src/main/java/org/hisp/dhis/de/action/HistoryAction.java	2011-07-20 21:38:30 +0000
+++ dhis-2/dhis-web/dhis-web-dataentry/src/main/java/org/hisp/dhis/de/action/HistoryAction.java	2011-07-28 07:15:09 +0000
@@ -120,18 +120,6 @@
     	this.optionComboId = optionComboId;
     }
     
-    private Boolean showComment;
-    
-    public void setShowComment( Boolean showComment)
-    {
-    	this.showComment = showComment;
-    }
-    
-    public Boolean getShowComment()
-    {
-    	return showComment;
-    }
-
     private String periodId;
 
     public String getPeriodId()
@@ -189,7 +177,7 @@
 
     public String execute()
         throws Exception
-    {    	
+    {
     	DataElement dataElement = dataElementService.getDataElement( dataElementId );       
         
         DataElementCategoryOptionCombo optionCombo = categoryService.getDataElementCategoryOptionCombo( optionComboId );

=== modified file 'dhis-2/dhis-web/dhis-web-dataentry/src/main/resources/struts.xml'
--- dhis-2/dhis-web/dhis-web-dataentry/src/main/resources/struts.xml	2011-07-25 20:12:49 +0000
+++ dhis-2/dhis-web/dhis-web-dataentry/src/main/resources/struts.xml	2011-07-28 07:15:09 +0000
@@ -14,7 +14,7 @@
       <param name="page">/dhis-web-dataentry/select.vm</param>
       <param name="menu">/dhis-web-dataentry/menu.vm</param>
       <param name="menuTreeHeight">420</param>
-      <param name="javascripts">../dhis-web-commons/ouwt/ouwt.js,javascript/form.js,javascript/entry.js</param>
+      <param name="javascripts">../dhis-web-commons/ouwt/ouwt.js,javascript/form.js,javascript/entry.js,javascript/history.js</param>
       <param name="stylesheets">style/dhis-web-dataentry.css</param>
     </action>
 
@@ -58,9 +58,7 @@
     </action>
 
     <action name="viewHistory" class="org.hisp.dhis.de.action.HistoryAction">
-      <result name="success" type="velocity">/popup.vm</result>
-      <param name="page">/dhis-web-dataentry/history.vm</param>
-      <param name="javascripts">javascript/history.js</param>
+      <result name="success" type="velocity">/dhis-web-dataentry/history.vm</result>
     </action>
 
     <action name="registerCompleteDataSet" class="org.hisp.dhis.de.action.RegisterCompleteDataSetAction">

=== modified file 'dhis-2/dhis-web/dhis-web-dataentry/src/main/webapp/dhis-web-dataentry/history.vm'
--- dhis-2/dhis-web/dhis-web-dataentry/src/main/webapp/dhis-web-dataentry/history.vm	2011-07-20 21:38:30 +0000
+++ dhis-2/dhis-web/dhis-web-dataentry/src/main/webapp/dhis-web-dataentry/history.vm	2011-07-28 07:15:09 +0000
@@ -1,13 +1,6 @@
 <script type="text/javascript">
-	var currentOrganisationUnitId = $!{dataElementHistory.organisationUnit.id};
-	var currentDataElementId = $!{dataElementHistory.dataElement.id};
-	var currentOptionComboId = $!{dataElementHistory.optionCombo.id};
-	var currentPeriodId = '${periodId}';
-	
-	var i18n_enter_digits = '$encoder.jsEscape( $i18n.getString( "enter_digits" ) , "'")';
-	var i18n_max_must_be_greater_than_min = '$encoder.jsEscape( $i18n.getString( "max_must_be_greater_than_min" ) , "'")';
-	var i18n_mark_value_for_followup = '$encoder.jsEscape( $i18n.getString( "mark_value_for_followup" ) , "'")';
-	var i18n_unmark_value_for_followup = '$encoder.jsEscape( $i18n.getString( "unmark_value_for_followup" ) , "'")';
+var currentDataElementId = $!{dataElementHistory.dataElement.id};
+var currentOptionComboId = $!{dataElementHistory.optionCombo.id};
 </script>
 
 #set( $width = 40 * $dataElementHistory.historyLength )
@@ -28,16 +21,14 @@
 
 <table>
 	<tr>		
-		<!-- Column 1 - Comment -->
+		<!-- Comment -->
 		<td valign="top">			
 			<h4>$i18n.getString( "dataelement_comment" )</h4>
-			#if( $showComment == 'true' )
 			<textarea id="commentTextArea" style="height:130px;width:240px">$!encoder.htmlEncode( $dataValue.comment )</textarea><br>
-			<input type="button" value="$i18n.getString( 'save_comment' )" style="width:130px" onclick="saveComment()">
-			#end
+			<input type="button" value="$i18n.getString( 'save_comment' )" style="width:130px" onclick="saveComment()">
 		</td>
 		
-		<!-- Column 2 - Min-max -->
+		<!-- Min-max -->
         <td valign="top">       
             <h4>$encoder.htmlEncode( $i18n.getString( "min_max_limits" ) )</h4>
             <table>
@@ -47,8 +38,8 @@
                     <td><input type="text" id="maxLimit" style="width:10em" value="$!{dataElementHistory.maxLimit}" class="{validate:{digits:true}}"
                         #if( $auth.hasAccess( "dhis-web-dataentry", "saveMinMaxLimits" ) && $auth.hasAccess( "dhis-web-dataentry", "removeMinMaxLimits" ))
                             onkeyup="saveMinMaxLimit()"
-                        #else disabled="disabled" #end onfocus="this.select()"/>
-						<i><span id='maxSpan' style="color:red;"></span></i>
+                        #else disabled="disabled" #end />
+						<i><span id="maxSpan" style="color:red"></span></i>
 						</td>
                 </tr>
                 <tr>
@@ -57,14 +48,14 @@
                     <td><input type="text" id="minLimit" style="width:10em" value="$!{dataElementHistory.minLimit}"
                         #if( $auth.hasAccess( "dhis-web-dataentry", "saveMinMaxLimits" ) && $auth.hasAccess( "dhis-web-dataentry", "removeMinMaxLimits" ))
                            onkeyup="saveMinMaxLimit()"
-                        #else disabled="disabled" #end onfocus="this.select()"/>
-						<i><span id='minSpan' style="color:red;"></span></i>
+                        #else disabled="disabled" #end />
+						<i><span id="minSpan" style="color:red"></span></i>
 					</td>
                 </tr>
                 <tr>
                     <td style="background-color:#f4f256; height:26px">&nbsp;</td>
                     <td>$encoder.htmlEncode( $i18n.getString( "average" ) ) </td>
-                    <td><script type="text/javascript">document.write( ${average}.toFixed(1) );</script></td>
+                    <td>${average}</td>
                 </tr>
                 <tr>
                     <td style="background-color:#75e077; height:26px">&nbsp;</td>
@@ -101,7 +92,4 @@
 			#end					
         </td>
     </tr>
-
 </table>
-
-<p><input type="button" style="width:130px" value="$encoder.htmlEncode( $i18n.getString( 'close' ) )" onclick="javascript:self.close()"></p>

=== modified file 'dhis-2/dhis-web/dhis-web-dataentry/src/main/webapp/dhis-web-dataentry/javascript/form.js'
--- dhis-2/dhis-web/dhis-web-dataentry/src/main/webapp/dhis-web-dataentry/javascript/form.js	2011-07-25 15:46:47 +0000
+++ dhis-2/dhis-web/dhis-web-dataentry/src/main/webapp/dhis-web-dataentry/javascript/form.js	2011-07-28 07:15:09 +0000
@@ -549,12 +549,26 @@
 // History
 // -----------------------------------------------------------------------------
 
+function displayHistoryDialog()
+{
+	$( '#historyDiv' ).dialog( {
+	    modal: true,
+	   	title: 'History',
+	   	width: 580,
+	   	height: 710
+	} );
+}
+
 function viewHist( dataElementId, optionComboId )
 {
 	var periodId = $( '#selectedPeriodId' ).val();
 	
-    window.open( 'viewHistory.action?dataElementId=' + dataElementId + '&optionComboId=' + optionComboId
-            + '&periodId=' + periodId + '&showComment=true', '_blank', 'width=580,height=710,scrollbars=yes' );
+    $( '#historyDiv' ).load( 'viewHistory.action', {
+    	dataElementId: dataElementId,
+    	optionComboId: optionComboId,
+    	periodId: periodId },
+    	displayHistoryDialog
+    );
 }
 
 function closeCurrentSelection()

=== modified file 'dhis-2/dhis-web/dhis-web-dataentry/src/main/webapp/dhis-web-dataentry/javascript/history.js'
--- dhis-2/dhis-web/dhis-web-dataentry/src/main/webapp/dhis-web-dataentry/javascript/history.js	2011-07-21 17:58:42 +0000
+++ dhis-2/dhis-web/dhis-web-dataentry/src/main/webapp/dhis-web-dataentry/javascript/history.js	2011-07-28 07:15:09 +0000
@@ -1,8 +1,4 @@
 
-var COLOR_GREEN = '#b9ffb9';
-var COLOR_YELLOW = '#fffe8c';
-var COLOR_RED = '#ff8a8a';
-
 // -----------------------------------------------------------------------------
 // Comments
 // -----------------------------------------------------------------------------
@@ -10,8 +6,9 @@
 function saveComment()
 {
 	var commentValue = $( '#commentTextArea' ).val();
+	var periodId = $( '#selectedPeriodId' ).val();
 	
-	var commentSaver = new CommentSaver( currentDataElementId, currentOptionComboId, currentOrganisationUnitId, currentPeriodId, commentValue );
+	var commentSaver = new CommentSaver( currentDataElementId, currentOptionComboId, currentOrganisationUnitId, periodId, commentValue );
 	
 	commentSaver.save();
 }
@@ -68,7 +65,7 @@
 	
 	var url = 'removeMinMaxLimits.action?organisationUnitId=' + currentOrganisationUnitId + '&dataElementId=' + currentDataElementId + '&optionComboId=' + currentOptionComboId;
 	
-	$.get( url, refreshWindow );
+	$.get( url, refreshChart );
 }
 
 function saveMinMaxLimit()
@@ -114,17 +111,19 @@
 		$( '#maxSpan' ).html( '' );
 	}
 	
-	// TODO fix
-	//currentMinMaxValueMap[currentDataElementId + '-' + currentOptionComboId + '-min'] = minValue;
-	//currentMinMaxValueMap[currentDataElementId + '-' + currentOptionComboId + '-max'] = maxValue;
+	var minId = currentDataElementId + '-' + currentOptionComboId + '-min';
+	var maxId = currentDataElementId + '-' + currentOptionComboId + '-max';
+	
+	currentMinMaxValueMap[minId] = minValue;
+	currentMinMaxValueMap[maxId] = maxValue;
 	
     var url = 'saveMinMaxLimits.action?organisationUnitId=' + currentOrganisationUnitId + '&dataElementId=' + currentDataElementId + 
     	'&optionComboId=' + currentOptionComboId + '&minLimit=' + minValue + '&maxLimit=' + maxValue;
     
-    $.get( url, refreshWindow );
+    $.get( url, refreshChart );
 }
 
-function refreshWindow()
+function refreshChart()
 {
 	var source = 'getHistoryChart.action?dataElementId=' + currentDataElementId + '&categoryOptionComboId=' + currentOptionComboId + '&r=' + Math.random();
 	

=== modified file 'dhis-2/dhis-web/dhis-web-dataentry/src/main/webapp/dhis-web-dataentry/select.vm'
--- dhis-2/dhis-web/dhis-web-dataentry/src/main/webapp/dhis-web-dataentry/select.vm	2011-07-25 08:52:10 +0000
+++ dhis-2/dhis-web/dhis-web-dataentry/src/main/webapp/dhis-web-dataentry/select.vm	2011-07-28 07:15:09 +0000
@@ -19,6 +19,11 @@
 var i18n_confirm_undo = '$encoder.jsEscape( $i18n.getString( "confirm_undo" ) , "'")';
 var i18n_no_response_from_server = '$encoder.jsEscape( $i18n.getString( "no_response_from_server" ) , "'")';
 
+var i18n_enter_digits = '$encoder.jsEscape( $i18n.getString( "enter_digits" ) , "'")';
+var i18n_max_must_be_greater_than_min = '$encoder.jsEscape( $i18n.getString( "max_must_be_greater_than_min" ) , "'")';
+var i18n_mark_value_for_followup = '$encoder.jsEscape( $i18n.getString( "mark_value_for_followup" ) , "'")';
+var i18n_unmark_value_for_followup = '$encoder.jsEscape( $i18n.getString( "unmark_value_for_followup" ) , "'")';
+
 significantZeros = [
 #set( $size1 = $significantZeros.size() )
 #foreach( $dataElement in $significantZeros )
@@ -104,3 +109,5 @@
 #parse( "dhis-web-commons/loader/loader.vm" )
 
 <div id="contentDiv"></div>
+
+<div id="historyDiv"></div>

=== modified file 'dhis-2/dhis-web/dhis-web-dataentry/src/main/webapp/dhis-web-dataentry/style/dhis-web-dataentry.css'
--- dhis-2/dhis-web/dhis-web-dataentry/src/main/webapp/dhis-web-dataentry/style/dhis-web-dataentry.css	2011-07-21 20:27:34 +0000
+++ dhis-2/dhis-web/dhis-web-dataentry/src/main/webapp/dhis-web-dataentry/style/dhis-web-dataentry.css	2011-07-28 07:15:09 +0000
@@ -53,28 +53,3 @@
 {
   text-align: center;
 }
-
-@media print 
-{
-  #mainHeader, #topMenu, #leftBar, #currentSelection, #actions, input[type=button] 
-  {
-    display: none;
-  }
-  
-  input, select 
-  {
-    border: 0;
-    background-color: inherit;
-  }
-  
-  a 
-  {
-    text-decoration: none;
-    color: black;
-  }
-  
-  #typeCol, #minCol, #maxCol, #commentCol  
-  {
-    visibility: collapse;
-  } 
-}