dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #29493
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 14914: Only display the attribute-value of program selected in TEI Dashboard.
------------------------------------------------------------
revno: 14914
committer: Tran Chau <tran.hispvietnam@xxxxxxxxx>
branch nick: dhis2
timestamp: Sun 2014-04-20 10:45:01 +0800
message:
Only display the attribute-value of program selected in TEI Dashboard.
modified:
dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/trackedentity/TrackedEntityInstanceDashboardAction.java
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/TrackedEntityInstanceDashboardAction.java'
--- dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/trackedentity/TrackedEntityInstanceDashboardAction.java 2014-04-12 12:12:30 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/trackedentity/TrackedEntityInstanceDashboardAction.java 2014-04-20 02:45:01 +0000
@@ -28,13 +28,17 @@
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
+import java.util.ArrayList;
import java.util.Calendar;
import java.util.Collection;
+import java.util.Collections;
import java.util.Date;
import java.util.HashMap;
import java.util.HashSet;
+import java.util.List;
import java.util.Map;
+import org.hisp.dhis.common.comparator.IdentifiableObjectNameComparator;
import org.hisp.dhis.period.PeriodType;
import org.hisp.dhis.program.Program;
import org.hisp.dhis.program.ProgramIndicatorService;
@@ -43,6 +47,7 @@
import org.hisp.dhis.relationship.Relationship;
import org.hisp.dhis.relationship.RelationshipService;
import org.hisp.dhis.trackedentity.TrackedEntityAttribute;
+import org.hisp.dhis.trackedentity.TrackedEntityAttributeService;
import org.hisp.dhis.trackedentity.TrackedEntityAudit;
import org.hisp.dhis.trackedentity.TrackedEntityAuditService;
import org.hisp.dhis.trackedentity.TrackedEntityInstance;
@@ -50,6 +55,7 @@
import org.hisp.dhis.trackedentityattributevalue.TrackedEntityAttributeValue;
import org.hisp.dhis.trackedentityattributevalue.TrackedEntityAttributeValueService;
import org.hisp.dhis.user.CurrentUserService;
+import org.springframework.beans.factory.annotation.Autowired;
import com.opensymphony.xwork2.Action;
@@ -79,6 +85,9 @@
private TrackedEntityAttributeValueService attributeValueService;
+ @Autowired
+ private TrackedEntityAttributeService attributeService;
+
// -------------------------------------------------------------------------
// Input && Output
// -------------------------------------------------------------------------
@@ -87,7 +96,7 @@
private TrackedEntityInstance entityInstance;
- private Collection<TrackedEntityAttributeValue> attributeValues;
+ private List<TrackedEntityAttribute> attributes;
private Collection<ProgramInstance> activeProgramInstances;
@@ -95,7 +104,7 @@
private Collection<TrackedEntityAudit> entityInstanceAudits;
- private Map<TrackedEntityAttribute, String> attributeMap = new HashMap<TrackedEntityAttribute, String>();
+ private Map<Integer, String> attributeValueMap = new HashMap<Integer, String>();
private Collection<Relationship> relationships = new HashSet<Relationship>();
@@ -110,6 +119,11 @@
return programIndicatorsMap;
}
+ public Map<Integer, String> getAttributeValueMap()
+ {
+ return attributeValueMap;
+ }
+
public void setAttributeValueService( TrackedEntityAttributeValueService attributeValueService )
{
this.attributeValueService = attributeValueService;
@@ -130,11 +144,6 @@
this.programService = programService;
}
- public Map<TrackedEntityAttribute, String> getAttributeMap()
- {
- return attributeMap;
- }
-
public void setCurrentUserService( CurrentUserService currentUserService )
{
this.currentUserService = currentUserService;
@@ -170,9 +179,9 @@
return entityInstance;
}
- public Collection<TrackedEntityAttributeValue> getAttributeValues()
+ public List<TrackedEntityAttribute> getAttributes()
{
- return attributeValues;
+ return attributes;
}
public void setEntityInstanceService( TrackedEntityInstanceService entityInstanceService )
@@ -211,13 +220,12 @@
// Get entityInstance-attribute-values
// ---------------------------------------------------------------------
- Collection<TrackedEntityAttributeValue> _attributeValues = attributeValueService
- .getTrackedEntityAttributeValues( entityInstance );
- attributeValues = new HashSet<TrackedEntityAttributeValue>();
+ attributes = new ArrayList<TrackedEntityAttribute>( attributeService.getAllTrackedEntityAttributes() );
+ Collections.sort( attributes, IdentifiableObjectNameComparator.INSTANCE );
- for ( TrackedEntityAttributeValue attributeValue : _attributeValues )
+ for ( TrackedEntityAttributeValue attributeValue : entityInstance.getAttributeValues() )
{
- attributeValues.add( attributeValue );
+ attributeValueMap.put( attributeValue.getAttribute().getId(), attributeValue.getValue() );
}
// ---------------------------------------------------------------------
=== 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-04-18 18:17:51 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/javascript/commons.js 2014-04-20 02:45:01 +0000
@@ -1340,12 +1340,14 @@
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());
+ $('#propertyForm :input').each(function() {
var input = $(this);
var id = input.attr('id');
+ if( input.val() != "" ){
+ setInnerHTML('value_' + id, input.val());
+ showById('row_' + id);
+ }
+ var input = $(this);
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-04-06 15:57:21 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/programEnrollmentForm.vm 2014-04-20 02:45:01 +0000
@@ -180,5 +180,17 @@
if( jQuery('#tabs li').length == 1){
programReports(getFieldValue('programInstanceId'));
}
+
+ // Only display the attribute-value which belong to the program selected
+ $("[id^='row_attr']").hide();
+ #foreach($programAttribute in $attributes )
+ var value = getInnerHTML('value_attr' + '$programAttribute.attribute.id')
+ .replace(/^\s*/, "")
+ .replace(/\s*$/, "");
+ if(value!=''){
+ $('#row_attr' + '$programAttribute.attribute.id').show();
+ }
+ #end
+
resize();
</script>
=== 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-04-11 10:36:47 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/trackedEntityInstanceDashboard.vm 2014-04-20 02:45:01 +0000
@@ -32,21 +32,24 @@
</tr>
#end
- #foreach( $attributeValue in $attributeValues )
- <tr>
- <td>$attributeValue.attribute.displayName</td>
- <td id='dashboard_attr$attributeValue.attribute.id'>
- #if($attributeValue.attribute.valueType=='bool'
- || $attributeValue.attribute.valueType=='trueOnly')
- #if($attributeValue.value=='true')
+ #foreach( $attribute in $attributes )
+ <tr id='row_attr$attribute.id' class='hidden'>
+ <td>$attribute.displayName</td>
+
+ <td id='value_attr$attribute.id' >
+ #set($value = "")
+ #set($value = $attributeValueMap.get($attribute.id) )
+ #if($value != "" && $attribute.valueType=='bool'
+ || $attribute.valueType=='trueOnly')
+ #if($value=='true')
$i18n.getString("yes")
#else
$i18n.getString("no")
#end
#else
- $encoder.htmlEncode($attributeValue.value)
- #end
- </td>
+ $encoder.htmlEncode($value)
+ #end
+ </td>
</tr>
#end
</table>