dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #18101
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 7492: Press Entrer or Tab to focus next field in data entry form ( patient).
------------------------------------------------------------
revno: 7492
committer: Tran Chau <tran.hispvietnam@xxxxxxxxx>
branch nick: dhis2
timestamp: Tue 2012-07-03 04:30:21 +0100
message:
Press Entrer or Tab to focus next field in data entry form ( patient).
modified:
dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/program/DefaultProgramDataEntryService.java
dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/dataEntryForm.vm
dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/javascript/entry.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-services/dhis-service-patient/src/main/java/org/hisp/dhis/program/DefaultProgramDataEntryService.java'
--- dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/program/DefaultProgramDataEntryService.java 2012-06-18 09:40:23 +0000
+++ dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/program/DefaultProgramDataEntryService.java 2012-07-03 03:30:21 +0000
@@ -343,7 +343,7 @@
// Inline Javascript to add to HTML before outputting
// ---------------------------------------------------------------------
- final String jsCodeForBoolean = " name=\"entryselect\" $DISABLED data=\"{compulsory:$COMPULSORY, deName:'$DATAELEMENTNAME' }\" onchange=\"saveOpt( $DATAELEMENTID )\" style=\" text-align:center;\" ";
+ final String jsCodeForBoolean = " name=\"entryfield\" $DISABLED data=\"{compulsory:$COMPULSORY, deName:'$DATAELEMENTNAME' }\" onchange=\"saveOpt( $DATAELEMENTID )\" style=\" text-align:center;\" ";
StringBuffer sb = new StringBuffer();
@@ -457,7 +457,7 @@
}
String appendCode = dataElementCode.replaceFirst( "input", "select" );
- appendCode = appendCode.replace( "name=\"entryselect\"", jsCodeForBoolean );
+ appendCode = appendCode.replace( "name=\"entryfield\"", jsCodeForBoolean );
// -------------------------------------------------------------
// Add title
=== modified file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/dataEntryForm.vm'
--- dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/dataEntryForm.vm 2012-06-27 08:21:26 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/dataEntryForm.vm 2012-07-03 03:30:21 +0000
@@ -69,18 +69,18 @@
#end
#if( $programStageDataElement.dataElement.type == "bool" )
- <select style='width: 256px;' name="entryselect" data="{compulsory: $programStageDataElement.compulsory }" id="$id" onchange="saveOpt( $programStageDataElement.dataElement.id )" tabindex="$tabIndex">
+ <select style='width: 256px;' name="entryfield" data="{compulsory: $programStageDataElement.compulsory }" id="$id" onchange="saveOpt( $programStageDataElement.dataElement.id )" tabindex="$tabIndex">
<option value="">[$i18n.getString( "select_value" )]</option>
<option value="true" #if( $patientDataValue.value == "true" ) selected="selected" #end>$i18n.getString( "yes" )</option>
<option value="false" #if( $patientDataValue.value == "false" ) selected="selected" #end>$i18n.getString( "no" )</option>
</select>
#elseif( $programStageDataElement.dataElement.type == "date" )
- <input style='width: 250px;' type="text" data="{compulsory: $programStageDataElement.compulsory }" id="$id" name="entryfield" value="$!encoder.htmlEncode( $patientDataValue.value )" onchange="saveVal( $programStageDataElement.dataElement.id )" onkeypress="return keyPress(event, this)" tabindex="$tabIndex" >
+ <input name="entryfield" style='width: 250px;' type="text" data="{compulsory: $programStageDataElement.compulsory }" id="$id" name="entryfield" value="$!encoder.htmlEncode( $patientDataValue.value )" onchange="saveVal( $programStageDataElement.dataElement.id )" onkeypress="return keyPress(event, this)" tabindex="$tabIndex" >
<script type="text/javascript">
datePicker($programStageDataElement.programStage.id + '-' + $programStageDataElement.dataElement.id + '-val', false);
</script>
#elseif($hasOptionSet=='true')
- <input name="entryfield" options='$hasOptionSet' #if($hasOptionSet == 'true') #end dataElementId='$programStageDataElement.dataElement.id' data="{compulsory: $programStageDataElement.compulsory, deName:'$programStageDataElement.dataElement.name', deType:'$programStageDataElement.dataElement.getDetailedNumberType()' }" id="$id" type="text" value="$!encoder.htmlEncode( $patientDataValue.value )"
+ <input name="entryfield" options='$hasOptionSet' #if($hasOptionSet == 'true') #end dataElementId='$programStageDataElement.dataElement.id' data="{compulsory: $programStageDataElement.compulsory, deName:'$programStageDataElement.dataElement.name', deType:'$programStageDataElement.dataElement.getDetailedNumberType()' }" id="$id" type="text" value="$!encoder.htmlEncode( $patientDataValue.value )" onkeypress="return keyPress(event, this)" tabindex="$tabIndex"
#set( $type=$programStageDataElement.dataElement.getDetailedNumberType())
#if( $type=='number' )
class="{validate:{number:true}}"
@@ -93,7 +93,7 @@
#end />
#else
<input name="entryfield" dataElementId='$programStageDataElement.dataElement.id'
- data="{compulsory: $programStageDataElement.compulsory, deName:'$programStageDataElement.dataElement.name', deType:'$programStageDataElement.dataElement.getDetailedNumberType()' }"
+ data="{compulsory: $programStageDataElement.compulsory, deName:'$programStageDataElement.dataElement.name', deType:'$programStageDataElement.dataElement.getDetailedNumberType()' }" onkeypress="return keyPress(event, this)" tabindex="$tabIndex"
id="$id" type="text" value="$!encoder.htmlEncode( $patientDataValue.value )"
onchange="saveVal( $programStageDataElement.dataElement.id )"
onkeypress="return keyPress(event, this)" tabindex="$tabIndex"
@@ -122,8 +122,8 @@
</td>
#end
</tr>
- #end
- #set( $tabIndex = $tabIndex + 1 )
+ #set( $tabIndex = $tabIndex + 1 )
+ #end
</table>
#end
</div>
=== modified file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/javascript/entry.js'
--- dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/javascript/entry.js 2012-06-28 07:56:22 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/javascript/entry.js 2012-07-03 03:30:21 +0000
@@ -331,56 +331,23 @@
}
}
- if ( key == 13 ) /* CR */
+ if ( key == 13 )
{
nextField = getNextEntryField( field );
if ( nextField )
{
- nextField.focus(); /* Does not seem to actually work in Safari, unless you also have an Alert in between */
+ nextField.focus();
}
return true;
}
- /* Illegal characters can be removed with a new if-block and return false */
return true;
}
function getNextEntryField( field )
{
- var inputs = document.getElementsByName( "entryfield" );
-
- // Simple bubble sort
- for ( var i = 0; i < inputs.length - 1; ++i )
- {
- for ( var j = i + 1; j < inputs.length; ++j )
- {
- if ( inputs[i].tabIndex > inputs[j].tabIndex )
- {
- tmp = inputs[i];
- inputs[i] = inputs[j];
- inputs[j] = tmp;
- }
- }
- }
-
- i = 0;
- for ( ; i < inputs.length; ++i )
- {
- if ( inputs[i] == field )
- {
- break;
- }
- }
-
- if ( i == inputs.length - 1 )
- {
- // No more fields after this:
- return false;
- }
- else
- {
- return inputs[i + 1];
- }
+ var index = field.getAttribute( 'tabindex' );
+ return $( '[name="entryfield"][tabindex="' + (++index) + '"]' );
}
//-----------------------------------------------------------------