dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #17914
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 7326: Only save value in option-value list of optionset for data value.
------------------------------------------------------------
revno: 7326
committer: Tran Chau <tran.hispvietnam@xxxxxxxxx>
branch nick: dhis2
timestamp: Mon 2012-06-18 16:40:23 +0700
message:
Only save value in option-value list of optionset for data value.
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/java/org/hisp/dhis/caseentry/action/caseentry/SaveValueAction.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 08:38:51 +0000
+++ dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/program/DefaultProgramDataEntryService.java 2012-06-18 09:40:23 +0000
@@ -555,7 +555,8 @@
// Inline Javascript to add to HTML before outputting
// ---------------------------------------------------------------------
- final String jsCodeForInputs = " $DISABLED onchange=\"saveVal( $DATAELEMENTID )\" data=\"{compulsory:$COMPULSORY, deName:'$DATAELEMENTNAME', deType:'$DATAELEMENTTYPE'}\" onkeypress=\"return keyPress(event, this)\" options='$OPTIONS' style=\" text-align:center;\" ";
+ final String jsCodeForInputs = " $DISABLED data=\"{compulsory:$COMPULSORY, deName:'$DATAELEMENTNAME', deType:'$DATAELEMENTTYPE'}\" options='$OPTIONS' style=\" text-align:center;\" ";
+ final String jsCodeForOnchange = " onchange=\"saveVal( $DATAELEMENTID )\" onkeypress=\"return keyPress(event, this)\" ";
StringBuffer sb = new StringBuffer();
@@ -703,6 +704,10 @@
Boolean hasOptionSet = (dataElement.getOptionSet() != null);
appendCode = appendCode.replace( "$OPTIONS", hasOptionSet.toString() );
+ if( !hasOptionSet)
+ {
+ appendCode += jsCodeForOnchange;
+ }
appendCode += " />";
=== modified file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/caseentry/SaveValueAction.java'
--- dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/caseentry/SaveValueAction.java 2012-06-07 04:23:40 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/caseentry/SaveValueAction.java 2012-06-18 09:40:23 +0000
@@ -162,7 +162,11 @@
patientDataValueService.savePatientDataValue( patientDataValue );
}
- else
+ if( patientDataValue != null && value == null )
+ {
+ patientDataValueService.deletePatientDataValue( patientDataValue );
+ }
+ else if( patientDataValue != null && value != null )
{
LOG.debug( "Updating PatientDataValue, value added/changed" );
=== 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-18 08:38:51 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/dataEntryForm.vm 2012-06-18 09:40:23 +0000
@@ -82,8 +82,10 @@
<script type="text/javascript">
datePicker($programStageDataElement.programStage.id + '-' + $programStageDataElement.dataElement.id + '-val', false);
</script>
+ #elseif($hasOptionSet)
+ <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 )" >
#else
- <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 )" onchange="saveVal( $programStageDataElement.dataElement.id )" onkeypress="return keyPress(event, this)" tabindex="$tabIndex">
+ <input name="entryfield" 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 )" onchange="saveVal( $programStageDataElement.dataElement.id )" onkeypress="return keyPress(event, this)" tabindex="$tabIndex">
#end
</td>
#if( $!programStageInstance.programStage.program.isRegistration() == 'true' )
=== 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-18 08:38:51 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/javascript/entry.js 2012-06-18 09:40:23 +0000
@@ -807,28 +807,41 @@
var input = jQuery( "#" + idField )
var dataElementId = input.attr('id').split('-')[1];
input.autocomplete({
- delay: 0,
- minLength: 0,
- source: function( request, response ){
- $.ajax({
- url: "getOptions.action?id=" + dataElementId + "&key=" + input.val(),
- dataType: "json",
- success: function(data) {
- response($.map(data.options, function(item) {
- return {
- label: item,
- id: item
- };
- }));
- }
- });
- },
- minLength: 2,
- select: function( event, ui ) {
- input.val(ui.item.value);
- saveVal( dataElementId );
- input.autocomplete( "close" );
+ delay: 0,
+ minLength: 0,
+ source: function( request, response ){
+ $.ajax({
+ url: "getOptions.action?id=" + dataElementId + "&key=" + input.val(),
+ dataType: "json",
+ success: function(data) {
+ response($.map(data.options, function(item) {
+ return {
+ label: item,
+ id: item
+ };
+ }));
+ }
+ });
+ },
+ minLength: 2,
+ select: function( event, ui ) {
+ input.val(ui.item.value);
+ saveVal( dataElementId );
+ input.autocomplete( "close" );
+ },
+ change: function( event, ui ) {
+ if ( !ui.item ) {
+ var matcher = new RegExp( "^" + $.ui.autocomplete.escapeRegex( $(this).val() ) + "$", "i" ),
+ valid = false;
+ if ( !valid ) {
+ // remove invalid value, as it didn't match anything
+ $( this ).val( "" );
+ saveVal( dataElementId );
+ input.data( "autocomplete" ).term = "";
+ return false;
+ }
}
- })
- .addClass( "ui-widget" );
+ }
+ })
+ .addClass( "ui-widget" );
}