------------------------------------------------------------ revno: 2342 committer: Tran Chau <tran.hispviet...@gmail.com> branch nick: trunk timestamp: Fri 2010-10-08 18:12:29 +0700 message: Fix bug: There is no validation for Min/Max text field into Data entry form. modified: dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/i18n/i18n.vm dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/popup.vm 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-commons-resources/src/main/webapp/dhis-web-commons/i18n/i18n.vm' --- dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/i18n/i18n.vm 2010-10-07 12:19:06 +0000 +++ dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/i18n/i18n.vm 2010-10-08 11:12:29 +0000 @@ -91,7 +91,7 @@ var i18n_success = '$encoder.jsEscape( $i18n.getString( "success" ) , "'")'; var i18n_hide_menu = '$encoder.jsEscape( $i18n.getString( "hide_menu" ) , "'")'; var i18n_waiting = '$encoder.jsEscape( $i18n.getString( "waiting" ) , "'")'; - +var i18n_enter_digits = '$encoder.jsEscape($i18n.getString( 'please_enter_a_valid_digits' ) , "'")' // =========================================================================== === modified file 'dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/popup.vm' --- dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/popup.vm 2010-09-25 08:21:19 +0000 +++ dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/popup.vm 2010-10-08 11:12:29 +0000 @@ -21,6 +21,8 @@ <script type="text/javascript" src="../dhis-web-commons/javascripts/commons.ajax.js"></script> <script type="text/javascript" src="../dhis-web-commons/javascripts/lists.js"></script> + <script type="text/javascript" src="../request.js"></script> + #foreach( $javascript in $javascripts ) <script type="text/javascript" src="$javascript"></script> #end === 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 2010-10-08 09:56:09 +0000 +++ dhis-2/dhis-web/dhis-web-dataentry/src/main/resources/struts.xml 2010-10-08 11:12:29 +0000 @@ -188,7 +188,7 @@ <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,../request.js</param> + <param name="javascripts">javascript/history.js</param> </action> <action name="minMaxGeneration" class="org.hisp.dhis.de.action.MinMaxGeneratingAction"> === 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-10-08 09:56:09 +0000 +++ dhis-2/dhis-web/dhis-web-dataentry/src/main/webapp/dhis-web-dataentry/history.vm 2010-10-08 11:12:29 +0000 @@ -58,7 +58,9 @@ <td><input type="text" id="maxLimit" style="width:10em" value="$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 )" - #else disabled="disabled" #end onfocus="this.select()"></td> + #else disabled="disabled" #end onfocus="this.select()"> + <span id='maxSpan' style="color:red;"></span> + </td> </tr> <tr> <td style="background-color:#d54a4a; height:26px"> </td> @@ -66,7 +68,9 @@ <td><input type="text" id="minLimit" style="width:10em" value="$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 )" - #else disabled="disabled" #end onfocus="this.select()"></td> + #else disabled="disabled" #end onfocus="this.select()"> + <span id='minSpan' style="color:red;"></span> + </td> </tr> <tr> <td style="background-color:#f4f256; height:26px"> </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 2010-10-08 09:56:09 +0000 +++ dhis-2/dhis-web/dhis-web-dataentry/src/main/webapp/dhis-web-dataentry/javascript/history.js 2010-10-08 11:12:29 +0000 @@ -107,11 +107,32 @@ } } +function isInt(value){ + if(((value) == parseInt(value)) && !isNaN(parseInt(value))){ + return true; + } else { + return false; + } +} + function saveMinLimit( organisationUnitId, dataElementId, optionComboId ) { var minLimitField = document.getElementById( "minLimit" ); - var maxLimitField = document.getElementById( "maxLimit" ); - + 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 ); @@ -147,11 +168,23 @@ } 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" ); - var maxLimitField = document.getElementById( "maxLimit" ); - + if(!isInt(minLimitField.value)){ + setInnerHTML('minSpan', i18n_enter_digits); + return; + }else{ + setInnerHTML('minSpan', ""); + } + var request = new Request(); request.setCallbackSuccess( refreshWindow );
_______________________________________________ Mailing list: https://launchpad.net/~dhis2-devs Post to : dhis2-devs@lists.launchpad.net Unsubscribe : https://launchpad.net/~dhis2-devs More help : https://help.launchpad.net/ListHelp