=== 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 @@ + #elseif($hasOptionSet) + #else - + #end #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" ); }