dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #13057
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 4123: Setting min-max values in data entry form in separate action
Merge authors:
Lars Helge Øverland (larshelge)
------------------------------------------------------------
revno: 4123 [merge]
committer: Lars Helge Overland <larshelge@xxxxxxxxx>
branch nick: dhis2
timestamp: Tue 2011-07-12 19:46:11 +0200
message:
Setting min-max values in data entry form in separate action
modified:
dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/dataentryform/DefaultDataEntryFormService.java
dhis-2/dhis-web/dhis-web-dataentry/src/main/java/org/hisp/dhis/de/action/GetDataValuesForDataSetAction.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/webapp/dhis-web-dataentry/defaultForm.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/responseDataValues.vm
dhis-2/dhis-web/dhis-web-dataentry/src/main/webapp/dhis-web-dataentry/sectionForm.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-services/dhis-service-core/src/main/java/org/hisp/dhis/dataentryform/DefaultDataEntryFormService.java'
--- dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/dataentryform/DefaultDataEntryFormService.java 2011-07-12 15:55:08 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/dataentryform/DefaultDataEntryFormService.java 2011-07-12 17:45:21 +0000
@@ -246,8 +246,8 @@
final String metaDataCode = "<span id=\"$DATAELEMENTID-dataelement\" style=\"display:none\">$DATAELEMENTNAME</span>"
+ "<span id=\"$DATAELEMENTID-type\" style=\"display:none\">$DATAELEMENTTYPE</span>"
- + "<div id=\"$DATAELEMENTID-$OPTIONCOMBOID-min\" style=\"display:none\">$MIN</div>"
- + "<div id=\"$DATAELEMENTID-$OPTIONCOMBOID-max\" style=\"display:none\">$MAX</div>";
+ + "<div id=\"$DATAELEMENTID-$OPTIONCOMBOID-min\" style=\"display:none\"></div>"
+ + "<div id=\"$DATAELEMENTID-$OPTIONCOMBOID-max\" style=\"display:none\"></div>";
StringBuffer sb = new StringBuffer();
@@ -380,17 +380,6 @@
inputHtml = inputHtml.replace( "$DISABLED", disabled );
inputHtml = inputHtml.replace( STYLE_TAG, backgroundColor );
- if ( minMaxDataElement == null )
- {
- inputHtml = inputHtml.replace( "$MIN", minValue );
- inputHtml = inputHtml.replace( "$MAX", maxValue );
- }
- else
- {
- inputHtml = inputHtml.replace( "$MIN", String.valueOf( minMaxDataElement.getMin() ) );
- inputHtml = inputHtml.replace( "$MAX", String.valueOf( minMaxDataElement.getMax() ) );
- }
-
inputMatcher.appendReplacement( sb, inputHtml );
}
}
=== modified file 'dhis-2/dhis-web/dhis-web-dataentry/src/main/java/org/hisp/dhis/de/action/GetDataValuesForDataSetAction.java'
--- dhis-2/dhis-web/dhis-web-dataentry/src/main/java/org/hisp/dhis/de/action/GetDataValuesForDataSetAction.java 2011-07-12 14:44:28 +0000
+++ dhis-2/dhis-web/dhis-web-dataentry/src/main/java/org/hisp/dhis/de/action/GetDataValuesForDataSetAction.java 2011-07-12 17:20:02 +0000
@@ -33,6 +33,8 @@
import org.hisp.dhis.datavalue.DataValue;
import org.hisp.dhis.datavalue.DataValueService;
import org.hisp.dhis.de.state.SelectedStateManager;
+import org.hisp.dhis.minmax.MinMaxDataElement;
+import org.hisp.dhis.minmax.MinMaxDataElementService;
import org.hisp.dhis.organisationunit.OrganisationUnit;
import org.hisp.dhis.period.Period;
@@ -54,6 +56,13 @@
{
this.dataValueService = dataValueService;
}
+
+ private MinMaxDataElementService minMaxDataElementService;
+
+ public void setMinMaxDataElementService( MinMaxDataElementService minMaxDataElementService )
+ {
+ this.minMaxDataElementService = minMaxDataElementService;
+ }
private SelectedStateManager selectedStateManager;
@@ -72,6 +81,13 @@
{
return dataValues;
}
+
+ private Collection<MinMaxDataElement> minMaxDataElements;
+
+ public Collection<MinMaxDataElement> getMinMaxDataElements()
+ {
+ return minMaxDataElements;
+ }
// -------------------------------------------------------------------------
// Action implementation
@@ -85,6 +101,8 @@
dataValues = dataValueService.getDataValues( unit, period, dataSet.getDataElements() );
+ minMaxDataElements = minMaxDataElementService.getMinMaxDataElements( unit, dataSet.getDataElements() );
+
return SUCCESS;
}
}
=== 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-07-12 14:44:28 +0000
+++ dhis-2/dhis-web/dhis-web-dataentry/src/main/resources/META-INF/dhis/beans.xml 2011-07-12 17:20:02 +0000
@@ -25,6 +25,7 @@
scope="prototype">
<property name="selectedStateManager" ref="org.hisp.dhis.de.state.SelectedStateManager" />
<property name="dataValueService" ref="org.hisp.dhis.datavalue.DataValueService" />
+ <property name="minMaxDataElementService" ref="org.hisp.dhis.minmax.MinMaxDataElementService" />
</bean>
<bean id="org.hisp.dhis.de.action.LoadOrganisationUnitAction" class="org.hisp.dhis.de.action.LoadOrganisationUnitAction"
=== modified file 'dhis-2/dhis-web/dhis-web-dataentry/src/main/webapp/dhis-web-dataentry/defaultForm.vm'
--- dhis-2/dhis-web/dhis-web-dataentry/src/main/webapp/dhis-web-dataentry/defaultForm.vm 2011-07-12 15:55:08 +0000
+++ dhis-2/dhis-web/dhis-web-dataentry/src/main/webapp/dhis-web-dataentry/defaultForm.vm 2011-07-12 17:30:07 +0000
@@ -54,10 +54,7 @@
#set( $minMaxError = true )
#end
#end
-
- <span id="${dataElement.id}-${optionCombo.id}-min" class="hidden">$!minMax.min</span>
- <span id="${dataElement.id}-${optionCombo.id}-max" class="hidden">$!minMax.max</span>
-
+ <span id="${dataElement.id}-${optionCombo.id}-min" class="hidden"></span><span id="${dataElement.id}-${optionCombo.id}-max" class="hidden"></span>
<td>
#if( $dataElement.type == "bool" )
<select name="entryselect" id="$dataEntryId" #if( $auth.hasAccess( "dhis-web-dataentry", "saveValue" ) ) onchange="saveBoolean($dataElement.id,$optionCombo.id )" #else disabled="disabled" #end style="width:100%" tabindex="$tabIndex" #if( $locked ) disabled="disabled"#end>
=== 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-12 15:55:08 +0000
+++ dhis-2/dhis-web/dhis-web-dataentry/src/main/webapp/dhis-web-dataentry/javascript/form.js 2011-07-12 17:26:24 +0000
@@ -207,17 +207,41 @@
function insertDataValues()
{
- $.getJSON( 'getDataValues.action', function( json )
+ // Clear existing values
+
+ $( '[name="entryfield"]' ).val( '' );
+
+ $.getJSON( 'getDataValues.action', function( json )
{
+ // Set data values
+
$.each( json.dataValues, function( i, value )
{
- var fieldId = '#' + value.id;
+ var fieldId = '#' + value.id + '-val';
if ( $( fieldId ) )
{
$( fieldId ).val( value.val );
}
} );
+
+ // Set min-max values
+
+ $.each( json.minMaxDataElements, function( i, value )
+ {
+ var minFieldId = '#' + value.id + '-min';
+ var maxFieldId = '#' + value.id + '-max';
+
+ if ( $( minFieldId ) )
+ {
+ $( minFieldId ).html( value.min );
+ }
+
+ if ( $( maxFieldId ) )
+ {
+ $( maxFieldId ).html( value.max );
+ }
+ } );
} );
}
=== modified file 'dhis-2/dhis-web/dhis-web-dataentry/src/main/webapp/dhis-web-dataentry/responseDataValues.vm'
--- dhis-2/dhis-web/dhis-web-dataentry/src/main/webapp/dhis-web-dataentry/responseDataValues.vm 2011-07-12 14:44:28 +0000
+++ dhis-2/dhis-web/dhis-web-dataentry/src/main/webapp/dhis-web-dataentry/responseDataValues.vm 2011-07-12 17:20:02 +0000
@@ -1,8 +1,18 @@
-#set( $size = $dataValues.size() )
+#set( $size1 = $dataValues.size() )
+#set( $size2 = $minMaxDataElements.size() )
{ "dataValues": [
-#foreach( $value in $dataValues )
-{
- "id":"${value.dataElement.id}-${value.optionCombo.id}-val",
- "val":"${value.value}"
-}#if( $velocityCount < $size ),#end
-#end ] }
+ #foreach( $value in $dataValues )
+ {
+ "id":"${value.dataElement.id}-${value.optionCombo.id}",
+ "val":"${value.value}"
+ }#if( $velocityCount < $size1 ),#end
+ #end ],
+ "minMaxDataElements": [
+ #foreach( $element in $minMaxDataElements )
+ {
+ "id":"${element.dataElement.id}-${element.optionCombo.id}",
+ "min":"${element.min}",
+ "max":"${element.max}"
+ }#if( $velocityCount < $size2 ),#end
+ #end ]
+ }
=== modified file 'dhis-2/dhis-web/dhis-web-dataentry/src/main/webapp/dhis-web-dataentry/sectionForm.vm'
--- dhis-2/dhis-web/dhis-web-dataentry/src/main/webapp/dhis-web-dataentry/sectionForm.vm 2011-07-12 15:55:08 +0000
+++ dhis-2/dhis-web/dhis-web-dataentry/src/main/webapp/dhis-web-dataentry/sectionForm.vm 2011-07-12 17:30:07 +0000
@@ -71,7 +71,7 @@
#set( $minMaxError = true )
#end
#end
- <span id="${dataElement.id}-${optionCombo.id}-min" class="hidden">$!minMax.min</span><span id="${dataElement.id}-${optionCombo.id}-max" class="hidden">$!minMax.max</span>
+ <span id="${dataElement.id}-${optionCombo.id}-min" class="hidden"></span><span id="${dataElement.id}-${optionCombo.id}-max" class="hidden"></span>
<td>
#if( $dataElement.type == "bool" )
<select name="entryselect" id="$dataEntryId" #if( $auth.hasAccess( "dhis-web-dataentry", "saveValue" ) ) onchange="saveBoolean($dataElement.id,$optionCombo.id )" #else disabled="disabled" #end style="width:100%" tabindex="$tabIndex" #if( $locked ) disabled="disabled"#end #if( $greyedField ) disabled="disabled"#end>