dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #13602
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 4401: Fixed bug with min-max values
------------------------------------------------------------
revno: 4401
committer: Lars Helge Overland <larshelge@xxxxxxxxx>
branch nick: dhis2
timestamp: Sat 2011-08-20 14:10:52 +0200
message:
Fixed bug with min-max values
modified:
dhis-2/dhis-web/dhis-web-dataentry/src/main/java/org/hisp/dhis/de/action/MarkForFollowupAction.java
dhis-2/dhis-web/dhis-web-dataentry/src/main/java/org/hisp/dhis/de/action/RegisterCompleteDataSetAction.java
dhis-2/dhis-web/dhis-web-dataentry/src/main/java/org/hisp/dhis/de/action/RemoveMinMaxLimitsAction.java
dhis-2/dhis-web/dhis-web-dataentry/src/main/java/org/hisp/dhis/de/action/SaveCommentAction.java
dhis-2/dhis-web/dhis-web-dataentry/src/main/java/org/hisp/dhis/de/action/SaveMinMaxLimitsAction.java
dhis-2/dhis-web/dhis-web-dataentry/src/main/resources/META-INF/dhis/beans.xml
dhis-2/dhis-web/dhis-web-dataentry/src/main/resources/org/hisp/dhis/de/i18n_module.properties
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/history.js
--
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-dataentry/src/main/java/org/hisp/dhis/de/action/MarkForFollowupAction.java'
--- dhis-2/dhis-web/dhis-web-dataentry/src/main/java/org/hisp/dhis/de/action/MarkForFollowupAction.java 2010-04-12 21:23:33 +0000
+++ dhis-2/dhis-web/dhis-web-dataentry/src/main/java/org/hisp/dhis/de/action/MarkForFollowupAction.java 2011-08-20 12:10:52 +0000
@@ -38,7 +38,7 @@
import org.hisp.dhis.organisationunit.OrganisationUnit;
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 com.opensymphony.xwork2.Action;
@@ -68,13 +68,6 @@
this.dataElementService = dataElementService;
}
- private PeriodService periodService;
-
- public void setPeriodService( PeriodService periodService )
- {
- this.periodService = periodService;
- }
-
private OrganisationUnitService organisationUnitService;
public void setOrganisationUnitService( OrganisationUnitService organisationUnitService )
@@ -100,18 +93,18 @@
this.dataElementId = dataElementId;
}
- private Integer periodId;
+ private String periodId;
- public void setPeriodId( Integer periodId )
+ public void setPeriodId( String periodId )
{
this.periodId = periodId;
}
- private Integer sourceId;
+ private int organisationUnitId;
- public void setSourceId( Integer sourceId )
+ public void setOrganisationUnitId( int organisationUnitId )
{
- this.sourceId = sourceId;
+ this.organisationUnitId = organisationUnitId;
}
private Integer categoryOptionComboId;
@@ -138,9 +131,9 @@
public String execute()
{
- DataElement dataElement = dataElementService.getDataElement( dataElementId );
- Period period = periodService.getPeriod( periodId );
- OrganisationUnit source = organisationUnitService.getOrganisationUnit( sourceId );
+ DataElement dataElement = dataElementService.getDataElement( dataElementId );
+ Period period = PeriodType.createPeriodExternalId( periodId );
+ OrganisationUnit source = organisationUnitService.getOrganisationUnit( organisationUnitId );
DataElementCategoryOptionCombo categoryOptionCombo = categoryService.getDataElementCategoryOptionCombo( categoryOptionComboId );
DataValue dataValue = dataValueService.getDataValue( source, dataElement, period, categoryOptionCombo );
=== modified file 'dhis-2/dhis-web/dhis-web-dataentry/src/main/java/org/hisp/dhis/de/action/RegisterCompleteDataSetAction.java'
--- dhis-2/dhis-web/dhis-web-dataentry/src/main/java/org/hisp/dhis/de/action/RegisterCompleteDataSetAction.java 2011-08-17 15:05:47 +0000
+++ dhis-2/dhis-web/dhis-web-dataentry/src/main/java/org/hisp/dhis/de/action/RegisterCompleteDataSetAction.java 2011-08-20 12:10:52 +0000
@@ -44,7 +44,6 @@
/**
* @author Lars Helge Overland
- * @version $Id$
*/
public class RegisterCompleteDataSetAction
implements Action
=== modified file 'dhis-2/dhis-web/dhis-web-dataentry/src/main/java/org/hisp/dhis/de/action/RemoveMinMaxLimitsAction.java'
--- dhis-2/dhis-web/dhis-web-dataentry/src/main/java/org/hisp/dhis/de/action/RemoveMinMaxLimitsAction.java 2011-08-20 11:10:50 +0000
+++ dhis-2/dhis-web/dhis-web-dataentry/src/main/java/org/hisp/dhis/de/action/RemoveMinMaxLimitsAction.java 2011-08-20 12:10:52 +0000
@@ -40,7 +40,6 @@
/**
* @author Torgeir Lorange Ostby
- * @version $Id: RemoveMinMaxLimitsAction.java 2869 2007-02-20 14:26:09Z andegje $
*/
public class RemoveMinMaxLimitsAction
implements Action
=== modified file 'dhis-2/dhis-web/dhis-web-dataentry/src/main/java/org/hisp/dhis/de/action/SaveCommentAction.java'
--- dhis-2/dhis-web/dhis-web-dataentry/src/main/java/org/hisp/dhis/de/action/SaveCommentAction.java 2011-08-20 11:33:08 +0000
+++ dhis-2/dhis-web/dhis-web-dataentry/src/main/java/org/hisp/dhis/de/action/SaveCommentAction.java 2011-08-20 12:10:52 +0000
@@ -29,8 +29,6 @@
import java.util.Date;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
import org.hisp.dhis.dataelement.DataElement;
import org.hisp.dhis.dataelement.DataElementCategoryOptionCombo;
import org.hisp.dhis.dataelement.DataElementCategoryService;
@@ -47,13 +45,10 @@
/**
* @author Torgeir Lorange Ostby
- * @version $Id: SaveCommentAction.java 3113 2007-03-19 20:47:10Z torgeilo $
*/
public class SaveCommentAction
implements Action
{
- private static final Log LOG = LogFactory.getLog( SaveCommentAction.class );
-
// -------------------------------------------------------------------------
// Dependencies
// -------------------------------------------------------------------------
@@ -180,8 +175,6 @@
{
if ( commentValue != null )
{
- LOG.info( "Adding DataValue, comment added " + commentValue );
-
dataValue = new DataValue( dataElement, period, organisationUnit, null,
storedBy, new Date(), commentValue, optionCombo );
@@ -190,8 +183,6 @@
}
else
{
- LOG.info( "Updating DataValue, comment added/changed " + commentValue );
-
dataValue.setComment( commentValue );
dataValue.setTimestamp( new Date() );
dataValue.setStoredBy( storedBy );
=== modified file 'dhis-2/dhis-web/dhis-web-dataentry/src/main/java/org/hisp/dhis/de/action/SaveMinMaxLimitsAction.java'
--- dhis-2/dhis-web/dhis-web-dataentry/src/main/java/org/hisp/dhis/de/action/SaveMinMaxLimitsAction.java 2011-08-20 11:10:50 +0000
+++ dhis-2/dhis-web/dhis-web-dataentry/src/main/java/org/hisp/dhis/de/action/SaveMinMaxLimitsAction.java 2011-08-20 12:10:52 +0000
@@ -40,7 +40,6 @@
/**
* @author Torgeir Lorange Ostby
- * @version $Id: SaveMinMaxLimitsAction.java 2869 2007-02-20 14:26:09Z andegje $
*/
public class SaveMinMaxLimitsAction
implements Action
@@ -117,12 +116,26 @@
}
// -------------------------------------------------------------------------
+ // Output
+ // -------------------------------------------------------------------------
+
+ private int statusCode;
+
+ public int getStatusCode()
+ {
+ return statusCode;
+ }
+
+ // -------------------------------------------------------------------------
// Action implementation
// -------------------------------------------------------------------------
public String execute()
throws Exception
{
+ minLimit = minLimit != null ? minLimit : 0;
+ maxLimit = maxLimit != null ? maxLimit : 0;
+
OrganisationUnit organisationUnit = organisationUnitService.getOrganisationUnit( organisationUnitId );
DataElement dataElement = dataElementService.getDataElement( dataElementId );
=== modified file 'dhis-2/dhis-web/dhis-web-dataentry/src/main/resources/META-INF/dhis/beans.xml'
--- dhis-2/dhis-web/dhis-web-dataentry/src/main/resources/META-INF/dhis/beans.xml 2011-08-17 13:41:04 +0000
+++ dhis-2/dhis-web/dhis-web-dataentry/src/main/resources/META-INF/dhis/beans.xml 2011-08-20 12:10:52 +0000
@@ -111,7 +111,6 @@
scope="prototype">
<property name="dataValueService" ref="org.hisp.dhis.datavalue.DataValueService" />
<property name="dataElementService" ref="org.hisp.dhis.dataelement.DataElementService" />
- <property name="periodService" ref="org.hisp.dhis.period.PeriodService" />
<property name="organisationUnitService" ref="org.hisp.dhis.organisationunit.OrganisationUnitService" />
<property name="categoryService" ref="org.hisp.dhis.dataelement.DataElementCategoryService" />
</bean>
=== modified file 'dhis-2/dhis-web/dhis-web-dataentry/src/main/resources/org/hisp/dhis/de/i18n_module.properties'
--- dhis-2/dhis-web/dhis-web-dataentry/src/main/resources/org/hisp/dhis/de/i18n_module.properties 2011-08-18 17:28:45 +0000
+++ dhis-2/dhis-web/dhis-web-dataentry/src/main/resources/org/hisp/dhis/de/i18n_module.properties 2011-08-20 12:10:52 +0000
@@ -126,6 +126,7 @@
on = On
value = Value
no_response_from_server = No response from server, please check connectivity and try again
+save = Save
save_comment = Save comment
operation_not_available_offline = This operation is not available in off-line mode
online_notification = You are online
=== 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-08-18 10:12:25 +0000
+++ dhis-2/dhis-web/dhis-web-dataentry/src/main/resources/struts.xml 2011-08-20 12:10:52 +0000
@@ -47,9 +47,7 @@
</action>
<action name="saveMinMaxLimits" class="org.hisp.dhis.de.action.SaveMinMaxLimitsAction">
- <result name="success" type="httpheader">
- <param name="status">204</param>
- </result>
+ <result name="success" type="velocity-json">/dhis-web-dataentry/status.vm</result>
<param name="onExceptionReturn">plainTextError</param>
<param name="requiredAuthorities">F_DATAELEMENT_MINMAX_ADD,F_DATAELEMENT_MINMAX_UPDATE</param>
</action>
=== 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-08-13 17:51:36 +0000
+++ dhis-2/dhis-web/dhis-web-dataentry/src/main/webapp/dhis-web-dataentry/history.vm 2011-08-20 12:10:52 +0000
@@ -14,9 +14,9 @@
<h4>$i18n.getString( "dataelement_comment" )
#if ( $dataValue && $dataValue.isFollowup() )
- <img id="followup" src="../images/marked.png" alt="$i18n.getString( 'mark_value_for_followup' )" onclick="markValueForFollowup( '$dataValue.dataElement.id', '$dataValue.period.id', '$dataValue.source.id', '$dataValue.optionCombo.id' )" style="cursor:pointer"/>
+ <img id="followup" src="../images/marked.png" alt="$i18n.getString( 'mark_value_for_followup' )" onclick="markValueForFollowup()" style="cursor:pointer"/>
#elseif ( $dataValue )
- <img id="followup" src="../images/unmarked.png" alt="$i18n.getString( 'unmark_value_for_followup' )" onclick="markValueForFollowup( '$dataValue.dataElement.id', '$dataValue.period.id', '$dataValue.source.id', '$dataValue.optionCombo.id' )" style="cursor:pointer"/>
+ <img id="followup" src="../images/unmarked.png" alt="$i18n.getString( 'unmark_value_for_followup' )" onclick="markValueForFollowup()" style="cursor:pointer"/>
#else
<img id="followup" src="../images/unmarked.png"/>
#end
@@ -30,26 +30,22 @@
<h4>$encoder.htmlEncode( $i18n.getString( "min_max_limits" ) )</h4>
<table>
<tr>
+ <td style="background-color:#d54a4a; height:26px"> </td>
+ <td>$encoder.htmlEncode( $i18n.getString( "min_limit" ) ) </td>
+ <td><input type="text" id="minLimit" style="width:10em" value="$!{dataElementHistory.minLimit}" class="{validate:{digits:true}}"
+ #if( !$auth.hasAccess( "dhis-web-dataentry", "saveMinMaxLimits" ) ) disabled="disabled"#end />
+ <i><span id="minSpan" style="color:red"></span></i>
+ </td>
+ </tr>
+ <tr>
<td style="background-color:#2e4e83; height:26px"> </td>
<td>$encoder.htmlEncode( $i18n.getString( "max_limit" ) ) </td>
- <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 />
+ <td><input type="text" id="maxLimit" style="width:10em" value="$!{dataElementHistory.maxLimit}" class="{validate:{digits:true}}"
+ #if( !$auth.hasAccess( "dhis-web-dataentry", "saveMinMaxLimits" ) ) disabled="disabled"#end />
<i><span id="maxSpan" style="color:red"></span></i>
</td>
</tr>
<tr>
- <td style="background-color:#d54a4a; height:26px"> </td>
- <td>$encoder.htmlEncode( $i18n.getString( "min_limit" ) ) </td>
- <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 />
- <i><span id="minSpan" style="color:red"></span></i>
- </td>
- </tr>
- <tr>
<td style="background-color:#f4f256; height:26px"> </td>
<td>$encoder.htmlEncode( $i18n.getString( "average" ) ) </td>
<td>${average}</td>
@@ -60,7 +56,8 @@
<td></td>
</tr>
<tr>
- <td colspan="3"><input type="button" value="$i18n.getString( 'remove' )" onclick="removeMinMaxLimit()" style="width:100px"></td>
+ <td colspan="3"><input type="button" value="$i18n.getString( 'save' )" onclick="saveMinMaxLimit()" style="width:100px">
+ <input type="button" value="$i18n.getString( 'remove' )" onclick="removeMinMaxLimit()" style="width:100px"></td>
</tr>
</table>
</td>
=== 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-08-20 11:33:08 +0000
+++ dhis-2/dhis-web/dhis-web-dataentry/src/main/webapp/dhis-web-dataentry/javascript/history.js 2011-08-20 12:10:52 +0000
@@ -116,7 +116,7 @@
$( '#maxSpan' ).html( '' );
}
- if ( eval( minValue ) > eval( maxValue ) )
+ if ( new Number( minValue ) > new Number( maxValue ) )
{
$( '#maxSpan' ).html( i18n_max_must_be_greater_than_min );
return;
@@ -132,34 +132,52 @@
currentMinMaxValueMap[minId] = minValue;
currentMinMaxValueMap[maxId] = maxValue;
- $.get( 'saveMinMaxLimits.action',
+ $.ajax( {
+ url: 'saveMinMaxLimits.action',
+ data:
{
organisationUnitId: currentOrganisationUnitId,
dataElementId: currentDataElementId,
categoryOptionComboId: currentOptionComboId,
minLimit: minValue,
- maxValue: maxValue
- },
- refreshChart );
+ maxLimit: maxValue
+ },
+ dataType: 'json',
+ cache: false,
+ success: function() {
+ $( '#minLimit' ).css( 'background-color', COLOR_GREEN );
+ $( '#maxLimit' ).css( 'background-color', COLOR_GREEN );
+ refreshChart();
+ },
+ error: function() {
+
+ $( '#minLimit' ).css( 'background-color', COLOR_RED );
+ $( '#maxLimit' ).css( 'background-color', COLOR_RED );
+ }
+ } );
}
function refreshChart()
-{
+{
+ var periodId = $( '#selectedPeriodId' ).val();
+
var source = 'getHistoryChart.action?dataElementId=' + currentDataElementId + '&categoryOptionComboId='
+ currentOptionComboId + '&periodId=' + periodId + '&organisationUnitId=' + currentOrganisationUnitId + '&r=' + Math.random();
$( '#historyChart' ).attr( 'src', source );
}
-function markValueForFollowup( dataElementId, periodId, sourceId, categoryOptionComboId )
+function markValueForFollowup()
{
+ var periodId = $( '#selectedPeriodId' ).val();
+
$.ajax( { url: 'markValueForFollowup.action',
data:
{
- dataElementId: dataElementId,
+ dataElementId: currentDataElementId,
+ categoryOptionComboId: currentOptionComboId,
periodId: periodId,
- sourceId: sourceId,
- categoryOptionComboId: categoryOptionComboId
+ organisationUnitId: currentOrganisationUnitId
},
cache: false,
dataType: 'json',