dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #08686
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 2142: Improved min max popup in dataentry
------------------------------------------------------------
revno: 2142
committer: Lars Helge Overland <larshelge@xxxxxxxxx>
branch nick: dhis2
timestamp: Mon 2010-11-22 22:48:22 +0100
message:
Improved min max popup in dataentry
modified:
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/org/hisp/dhis/de/i18n_module.properties
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/SaveMinMaxLimitsAction.java'
--- dhis-2/dhis-web/dhis-web-dataentry/src/main/java/org/hisp/dhis/de/action/SaveMinMaxLimitsAction.java 2010-04-12 21:23:33 +0000
+++ dhis-2/dhis-web/dhis-web-dataentry/src/main/java/org/hisp/dhis/de/action/SaveMinMaxLimitsAction.java 2010-11-22 21:48:22 +0000
@@ -27,8 +27,6 @@
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-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;
@@ -46,9 +44,7 @@
*/
public class SaveMinMaxLimitsAction
implements Action
-{
- private static final Log log = LogFactory.getLog( SaveMinMaxLimitsAction.class );
-
+{
// -------------------------------------------------------------------------
// Dependencies
// -------------------------------------------------------------------------
@@ -139,7 +135,7 @@
if ( minMaxDataElement == null )
{
minMaxDataElement = new MinMaxDataElement( organisationUnit, dataElement, optionCombo, minLimit, maxLimit, false );
-
+
minMaxDataElementService.addMinMaxDataElement( minMaxDataElement );
}
else
@@ -150,8 +146,6 @@
minMaxDataElementService.updateMinMaxDataElement( minMaxDataElement );
}
-
- log.info( "Generated min-max data elements" );
return SUCCESS;
}
=== 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 2010-11-17 18:26:47 +0000
+++ dhis-2/dhis-web/dhis-web-dataentry/src/main/resources/org/hisp/dhis/de/i18n_module.properties 2010-11-22 21:48:22 +0000
@@ -124,3 +124,5 @@
value_must_positive_number = Value must be an positive number
value_must_negative_number = Value must be an nagative number
datavalue_history = Data value history
+max_must_be_greater_than_min = Max must be greater than min
+remove = Remove
\ No newline at end of file
=== 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 2010-11-17 18:26:47 +0000
+++ dhis-2/dhis-web/dhis-web-dataentry/src/main/webapp/dhis-web-dataentry/history.vm 2010-11-22 21:48:22 +0000
@@ -2,18 +2,6 @@
#set( $lastIndex = $dataElementHistory.historyLength - 1 )
#set( $average = $dataElementHistory.historyPoints.get( $lastIndex ).average )
-#if( $dataElementHistory.minLimit )
- #set( $minLimit = $dataElementHistory.minLimit )
-#else
- #set( $minLimit = $encoder.htmlEncode( $i18n.getString( "not_set" ) ) )
-#end
-
-#if( $dataElementHistory.maxLimit )
- #set( $maxLimit = $dataElementHistory.maxLimit )
-#else
- #set( $maxLimit = $encoder.htmlEncode( $i18n.getString( "not_set" ) ) )
-#end
-
<h3>
$encoder.htmlEncode( $dataElementHistory.dataElement.name )
$encoder.htmlEncode( $dataElementHistory.optionCombo.name )
@@ -57,9 +45,9 @@
<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="$maxLimit" class="{validate:{digits:true}}"
+ <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" ))
- onchange="saveMaxLimit( $dataElementHistory.organisationUnit.id, $dataElementHistory.dataElement.id, $dataElementHistory.optionCombo.id )"
+ onchange="saveMinMaxLimit( $dataElementHistory.organisationUnit.id, $dataElementHistory.dataElement.id, $dataElementHistory.optionCombo.id )"
#else disabled="disabled" #end onfocus="this.select()"/>
<span id='maxSpan' style="color:red;"></span>
</td>
@@ -67,9 +55,9 @@
<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="$minLimit"
+ <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" ))
- onchange="saveMinLimit( $dataElementHistory.organisationUnit.id, $dataElementHistory.dataElement.id, $dataElementHistory.optionCombo.id )"
+ onchange="saveMinMaxLimit( $dataElementHistory.organisationUnit.id, $dataElementHistory.dataElement.id, $dataElementHistory.optionCombo.id )"
#else disabled="disabled" #end onfocus="this.select()"/>
<span id='minSpan' style="color:red;"></span>
</td>
@@ -84,6 +72,9 @@
<td>$encoder.htmlEncode( $i18n.getString( "interpolation" ) ) </td>
<td></td>
</tr>
+ <tr>
+ <td colspan="3"><input type="button" value="$i18n.getString( 'remove' )" onclick="removeMinMaxLimit( $dataElementHistory.organisationUnit.id, $dataElementHistory.dataElement.id, $dataElementHistory.optionCombo.id )" style="width:100px"></td>
+ </tr>
</table>
</td>
</tr>
@@ -120,6 +111,7 @@
<script type="text/javascript">
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" ) , "'")';
=== 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 2010-10-12 10:00:17 +0000
+++ dhis-2/dhis-web/dhis-web-dataentry/src/main/webapp/dhis-web-dataentry/javascript/history.js 2010-11-22 21:48:22 +0000
@@ -118,118 +118,52 @@
}
}
-function saveMinLimit( organisationUnitId, dataElementId, optionComboId )
+function removeMinMaxLimit( organisationUnitId, dataElementId, optionComboId )
{
- var minLimitField = document.getElementById( "minLimit" );
-
- if( !isInt(minLimitField.value) ) {
- setInnerHTML('minSpan', i18n_enter_digits);
- return;
- }else {
- setInnerHTML('minSpan', "");
- }
-
- var maxLimitField = document.getElementById( "maxLimit" );
-
- if( !isInt(maxLimitField.value) ) {
- setInnerHTML('maxSpan', i18n_enter_digits);
- return;
- }else {
- setInnerHTML('maxSpan', "");
- }
-
- var request = new Request();
- request.setCallbackSuccess( refreshWindow );
- request.setCallbackError( refreshWindow );
-
- if ( minLimitField.value == '' )
- {
- request.send( 'removeMinMaxLimits.action?organisationUnitId=' + organisationUnitId + '&dataElementId=' + dataElementId + '&optionComboId=' + optionComboId );
- }
- else
- {
- var minLimit = Number( minLimitField.value );
- var maxLimit = Number( maxLimitField.value );
-
- if ( minLimit )
- {
- if ( minLimit < 0 )
- {
- minLimit = 0;
- }
-
- if ( !maxLimit || maxLimit <= minLimit )
- {
- maxLimit = minLimit + 1;
- }
-
- request.send( 'saveMinMaxLimits.action?organisationUnitId=' + organisationUnitId + '&dataElementId=' + dataElementId + '&optionComboId=' + optionComboId + '&minLimit=' + minLimit + '&maxLimit=' + maxLimit );
- }
- else
- {
- refreshWindow();
- }
- }
+ var url = 'removeMinMaxLimits.action?organisationUnitId=' + organisationUnitId + '&dataElementId=' + dataElementId + '&optionComboId=' + optionComboId;
+
+ $.get( url, refreshWindow );
}
-function saveMaxLimit( organisationUnitId, dataElementId, optionComboId )
-{
- var maxLimitField = document.getElementById( "maxLimit" );
-
- if( !isInt(maxLimitField.value) ) {
- setInnerHTML('maxSpan', i18n_enter_digits);
- return;
- }else {
- setInnerHTML('maxSpan', "");
- }
-
- var minLimitField = document.getElementById( "minLimit" );
-
- if( !isInt(minLimitField.value) ) {
- setInnerHTML('minSpan', i18n_enter_digits);
- return;
- }else {
- setInnerHTML('minSpan', "");
- }
-
- var request = new Request();
-
- request.setCallbackSuccess( refreshWindow );
- request.setCallbackError( refreshWindow );
-
- if ( maxLimitField.value == '' )
- {
- request.send( 'removeMinMaxLimits.action?organisationUnitId=' + organisationUnitId + '&dataElementId=' + dataElementId + '&optionComboId=' + optionComboId );
- }
- else
- {
- var minLimit = Number( minLimitField.value );
- var maxLimit = Number( maxLimitField.value );
-
- if ( maxLimit )
- {
- if ( maxLimit < 1 )
- {
- maxLimit = 1;
- }
-
- if ( !minLimit )
- {
- minLimit = 0;
- }
- else if ( minLimit >= maxLimit )
- {
- minLimit = maxLimit - 1;
- }
-
- request.send( 'saveMinMaxLimits.action?organisationUnitId=' + organisationUnitId + '&dataElementId=' + dataElementId + '&optionComboId=' + optionComboId + '&minLimit=' + minLimit + '&maxLimit=' + maxLimit );
-
- }
- else
- {
- refreshWindow();
- }
- }
+function saveMinMaxLimit( organisationUnitId, dataElementId, optionComboId )
+{
+ var minValue = $( '#minLimit' ).val();
+ var maxValue = $( '#maxLimit' ).val();
+
+ if ( !minValue || minValue == '' ) {
+ return;
+ }
+ else if ( !isInt( minValue ) ) {
+ $( '#minSpan' ).html( i18n_enter_digits );
+ return;
+ }
+ else {
+ $( '#minSpan' ).html( '' );
+ }
+
+ if ( !maxValue || maxValue == '' ) {
+ return;
+ }
+ else if ( !isInt( maxValue ) ) {
+ $( '#maxSpan' ).html( i18n_enter_digits );
+ return;
+ }
+ else {
+ $( '#maxSpan' ).html( '' );
+ }
+
+ if ( minValue >= maxValue ) {
+ $( '#maxSpan' ).html( i18n_max_must_be_greater_than_min );
+ return;
+ }
+ else {
+ $( '#maxSpan' ).html( '' );
+ }
+
+ var url = 'saveMinMaxLimits.action?organisationUnitId=' + organisationUnitId + '&dataElementId=' + dataElementId +
+ '&optionComboId=' + optionComboId + '&minLimit=' + minValue + '&maxLimit=' + maxValue;
+
+ $.get( url, refreshWindow );
}
function refreshWindow()