dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #28080
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 13993: Fixed bug - No existing values for attributes are displayed in the input fields in the enroll fo...
------------------------------------------------------------
revno: 13993
committer: Tran Chau <tran.hispvietnam@xxxxxxxxx>
branch nick: dhis2
timestamp: Wed 2014-02-12 17:18:42 +0700
message:
Fixed bug - No existing values for attributes are displayed in the input fields in the enroll forms.
modified:
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/resources/struts.xml
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/javascript/commons.js
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/trackedEntityInstanceDashboard.vm
--
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-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<TrackedEntityAttribute> attributes = new ArrayList<TrackedEntityAttribute>();
+ private Integer entityInstanceId;
+
+ public void setEntityInstanceId( Integer entityInstanceId )
+ {
+ this.entityInstanceId = entityInstanceId;
+ }
+
+ private List<TrackedEntityAttribute> attributes;
public List<TrackedEntityAttribute> getAttributes()
{
return attributes;
}
+ private Map<Integer, String> attributeValueMaps = new HashMap<Integer, String>();
+
+ public Map<Integer, String> 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 @@
</action>
<action name="getAttribute"
- class="org.hisp.dhis.caseentry.action.trackedentity.GetProgramAction">
+ class="org.hisp.dhis.caseentry.action.trackedentity.GetAttributesByProgramAction">
<result name="success" type="velocity">/content.vm</result>
<param name="page">/dhis-web-caseentry/attributeFormDiv.vm</param>
<param name="requiredAuthorities">F_TRACKED_ENTITY_INSTANCE_ADD</param>
=== 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 = '')
<tr>
<td class='text-column'><label>$attribute.displayName #if($attribute.mandatory)<em title="$i18n.getString( "required" )" class="required">*</em> #end</label></td>
<td class="input-column" >
+ #set( $value='' )
+ #set( $value=$!attributeValueMaps.get($attribute.id) )
#if( $attribute.valueType == "bool" )
- <select id="attr$attribute.id" name="attr$attribute.id" >
+ <select id="attr$attribute.id" name="attr$attribute.id">
<option value="">[$i18n.getString( "please_select" )]</option>
- <option value="true">$i18n.getString( "yes" )</option>
- <option value="false">$i18n.getString( "no" )</option>
+ <option value="true" #if($value=='true') selected #end >$i18n.getString( "yes" )</option>
+ <option value="false" #if($value=='false') selected #end >$i18n.getString( "no" )</option>
</select>
#elseif( $attribute.valueType == "date" )
- <input type="text" id="attr$attribute.id" name="attr$attribute.id" objectId='$attribute.id' objectType='attr' class=' #validate( "default" $attribute.mandatory )' >
+ <input type="text" id="attr$attribute.id" name="attr$attribute.id" value='$!format.formatDate($value)' objectId='$attribute.id' objectType='attr' class=' #validate( "default" $attribute.mandatory )' >
<script type="text/javascript">
datePickerValid( 'attr$attribute.id', false );
</script>
@@ -20,11 +20,11 @@
<select id="attr$attribute.id" name="attr$attribute.id" class=' #validate( "default" $attribute.mandatory )' >
<option value="">[$i18n.getString( "please_select" )]</option>
#foreach ($option in $attribute.attributeOptions )
- <option value="$option.id">$option.name</option>
+ <option value="$option.id" #if($value==$option.name) selected #end >$option.name</option>
#end
</select>
#else
- <input type="text" id="attr$attribute.id" name="attr$attribute.id" class="{validate:{required:$attribute.mandatory #if($!attribute.noChars),maxlength:$attribute.noChars #end #if($attribute.valueType=='NUMBER'),number:true #end }}" >
+ <input type="text" id="attr$attribute.id" name="attr$attribute.id" value='$value' class="{validate:{required:$attribute.mandatory #if($!attribute.noChars),maxlength:$attribute.noChars #end #if($attribute.valueType=='NUMBER'),number:true #end }}" >
#end
</td>
</tr>
=== 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 @@
<script type="text/javascript">
jQuery("#propertyForm").ready( function(){
validation( 'propertyForm', function(form){
- validateIdentifier( $programInstance.entityInstance.id, $programInstance.program.id, 'propertyForm' );
+ saveIdentifierAndAttribute( $programInstance.entityInstance.id, $programInstance.program.id, 'propertyForm' );
});
validation( 'coordinatesForm', function(form){
=== modified file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/trackedEntityInstanceDashboard.vm'
--- dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/trackedEntityInstanceDashboard.vm 2014-02-07 20:25:49 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/trackedEntityInstanceDashboard.vm 2014-02-12 10:18:42 +0000
@@ -1,3 +1,4 @@
+<input type='hidden' id='entityInstanceId' name='entityInstanceId' value='$entityInstance.id'>
<table style='margin-top:-25px;'>
<tr>
<td colspan='3'>