=== modified file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/trackedentity/GetAttributesByProgramAction.java' --- dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/trackedentity/GetAttributesByProgramAction.java 2014-02-07 20:25:49 +0000 +++ dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/trackedentity/GetAttributesByProgramAction.java 2014-02-12 10:18:42 +0000 @@ -30,13 +30,18 @@ import java.util.ArrayList; import java.util.Collection; import java.util.Collections; +import java.util.HashMap; import java.util.List; +import java.util.Map; import org.hisp.dhis.common.comparator.IdentifiableObjectNameComparator; import org.hisp.dhis.program.Program; import org.hisp.dhis.program.ProgramService; import org.hisp.dhis.trackedentity.TrackedEntityAttribute; import org.hisp.dhis.trackedentity.TrackedEntityAttributeService; +import org.hisp.dhis.trackedentity.TrackedEntityInstance; +import org.hisp.dhis.trackedentity.TrackedEntityInstanceService; +import org.hisp.dhis.trackedentityattributevalue.TrackedEntityAttributeValue; import org.springframework.beans.factory.annotation.Autowired; import com.opensymphony.xwork2.Action; @@ -59,6 +64,9 @@ @Autowired private TrackedEntityAttributeService attributeService; + @Autowired + private TrackedEntityInstanceService entityInstanceService; + // ------------------------------------------------------------------------- // Getter && Setter // ------------------------------------------------------------------------- @@ -70,13 +78,27 @@ this.id = id; } - private List attributes = new ArrayList(); + private Integer entityInstanceId; + + public void setEntityInstanceId( Integer entityInstanceId ) + { + this.entityInstanceId = entityInstanceId; + } + + private List attributes; public List getAttributes() { return attributes; } + private Map attributeValueMaps = new HashMap(); + + public Map getAttributeValueMaps() + { + return attributeValueMaps; + } + // ------------------------------------------------------------------------- // Implementation Action // ------------------------------------------------------------------------- @@ -102,6 +124,16 @@ Collections.sort( attributes, IdentifiableObjectNameComparator.INSTANCE ); + if ( entityInstanceId != null ) + { + TrackedEntityInstance entityInstance = entityInstanceService.getTrackedEntityInstance( entityInstanceId ); + + for ( TrackedEntityAttributeValue attributeValue : entityInstance.getAttributeValues() ) + { + attributeValueMaps.put( attributeValue.getAttribute().getId(), attributeValue.getValue() ); + } + } + return SUCCESS; } } === modified file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/resources/struts.xml' --- dhis-2/dhis-web/dhis-web-caseentry/src/main/resources/struts.xml 2014-02-11 04:11:11 +0000 +++ dhis-2/dhis-web/dhis-web-caseentry/src/main/resources/struts.xml 2014-02-12 10:18:42 +0000 @@ -708,7 +708,7 @@ + class="org.hisp.dhis.caseentry.action.trackedentity.GetAttributesByProgramAction"> /content.vm /dhis-web-caseentry/attributeFormDiv.vm F_TRACKED_ENTITY_INSTANCE_ADD === modified file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/attributeFormDiv.vm' --- dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/attributeFormDiv.vm 2014-02-07 20:25:49 +0000 +++ dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/attributeFormDiv.vm 2014-02-12 10:18:42 +0000 @@ -1,18 +1,18 @@ - -#foreach($programAttribute in $program.attributes ) - #set( $attribute = $programAttribute.attribute ) +#foreach($attribute in $attributes ) #set( $attributeValue = '') + #set( $value='' ) + #set( $value=$!attributeValueMaps.get($attribute.id) ) #if( $attribute.valueType == "bool" ) - - - + + #elseif( $attribute.valueType == "date" ) - + @@ -20,11 +20,11 @@ #else - + #end === modified file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/javascript/commons.js' --- dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/javascript/commons.js 2014-02-12 05:10:39 +0000 +++ dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/javascript/commons.js 2014-02-12 10:18:42 +0000 @@ -385,7 +385,8 @@ } $.postJSON( "getAttributesByProgram.action", { - id:programIdAddEntityInstance + id:programIdAddEntityInstance, + entityInstanceId: getFieldValue('entityInstanceId') }, function( json ) { removeAttributeOption('advSearchBox0'); @@ -1074,7 +1075,8 @@ var program = $('#programEnrollmentSelectDiv [id=programId] option:selected'); $('#identifierAndAttributeDiv').load("getAttribute.action", { - id:program.val() + id:program.val(), + entityInstanceId: getFieldValue('entityInstanceId') }, function(){ $("#dateOfIncidentField").datepicker("destroy"); $("#enrollmentDateField").datepicker("destroy"); @@ -1328,27 +1330,6 @@ // Identifiers && Attributes for selected program // ---------------------------------------------------------------- -function validateIdentifier( entityInstanceId, programId, paramsDiv ) -{ - var params = getParamsForDiv(paramsDiv); - params += "&entityInstanceId=" + entityInstanceId; - params +="&programId=" + programId; - - $.ajax({ - type: "POST", - url: 'validateTrackedEntityAttributeValue.action', - data: params, - success: function(json) { - if( json.response == 'success' ) { - saveIdentifierAndAttribute( entityInstanceId, programId, paramsDiv ); - } - else { - showErrorMessage(json.message); - } - } - }); -} - function saveIdentifierAndAttribute( entityInstanceId, programId, paramsDiv ) { var params = getParamsForDiv(paramsDiv); @@ -1365,7 +1346,15 @@ var id = 'dashboard_' + input.attr('id'); setInnerHTML(id, input.val()); }); - + $('#identifierAndAttributeDiv :input').each(function(){ + var input = $(this); + var id = 'dashboard_' + input.attr('id'); + setInnerHTML(id, input.val()); + + var input = $(this); + var id = input.attr('id'); + jQuery("#tab-2 [id=" + id + "]").val(input.val()); + }); showSuccessMessage( i18n_save_success ); } }); === modified file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/programEnrollmentForm.vm' --- dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/programEnrollmentForm.vm 2014-02-07 20:25:49 +0000 +++ dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/programEnrollmentForm.vm 2014-02-12 10:18:42 +0000 @@ -125,7 +125,7 @@