← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 15507: Use ajax to load available attributes in Tracked entity attribute visit schedule form and Tracked...

 

------------------------------------------------------------
revno: 15507
committer: Tran Chau <tran.hispvietnam@xxxxxxxxx>
branch nick: dhis2
timestamp: Mon 2014-06-02 09:32:37 +0800
message:
  Use ajax to load available attributes in Tracked entity attribute visit schedule form and Tracked entity attributes displayed in list form.
modified:
  dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-program/src/main/java/org/hisp/dhis/trackedentity/action/trackedentityattribute/ShowAttributeInListNoProgramAction.java
  dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-program/src/main/java/org/hisp/dhis/trackedentity/action/trackedentityattribute/ShowAttributeVisitScheduleFormAction.java
  dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-program/src/main/webapp/dhis-web-maintenance-program/attributeVisitSchedule.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-maintenance/dhis-web-maintenance-program/src/main/java/org/hisp/dhis/trackedentity/action/trackedentityattribute/ShowAttributeInListNoProgramAction.java'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-program/src/main/java/org/hisp/dhis/trackedentity/action/trackedentityattribute/ShowAttributeInListNoProgramAction.java	2014-05-14 13:37:02 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-program/src/main/java/org/hisp/dhis/trackedentity/action/trackedentityattribute/ShowAttributeInListNoProgramAction.java	2014-06-02 01:32:37 +0000
@@ -32,7 +32,6 @@
 import java.util.Collections;
 import java.util.List;
 
-import org.hisp.dhis.common.comparator.IdentifiableObjectNameComparator;
 import org.hisp.dhis.trackedentity.TrackedEntityAttribute;
 import org.hisp.dhis.trackedentity.TrackedEntityAttributeService;
 import org.hisp.dhis.trackedentity.comparator.TrackedEntityAttributeSortOrderInListNoProgramComparator;
@@ -63,13 +62,6 @@
     // Output
     // -------------------------------------------------------------------------
 
-    private List<TrackedEntityAttribute> availableAttributes = new ArrayList<TrackedEntityAttribute>();
-
-    public List<TrackedEntityAttribute> getAvailableAttributes()
-    {
-        return availableAttributes;
-    }
-
     private List<TrackedEntityAttribute> selectedAttributes = new ArrayList<TrackedEntityAttribute>();
 
     public List<TrackedEntityAttribute> getSelectedAttributes()
@@ -86,13 +78,9 @@
     {
         selectedAttributes = new ArrayList<TrackedEntityAttribute>(
             attributeService.getTrackedEntityAttributesDisplayInList() );
+        
         Collections.sort( selectedAttributes, new TrackedEntityAttributeSortOrderInListNoProgramComparator() );
 
-        availableAttributes = new ArrayList<TrackedEntityAttribute>(
-            attributeService.getAllTrackedEntityAttributes() );
-        availableAttributes.removeAll( selectedAttributes );
-        Collections.sort( availableAttributes, IdentifiableObjectNameComparator.INSTANCE );
-
         return SUCCESS;
     }
 }
\ No newline at end of file

=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-program/src/main/java/org/hisp/dhis/trackedentity/action/trackedentityattribute/ShowAttributeVisitScheduleFormAction.java'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-program/src/main/java/org/hisp/dhis/trackedentity/action/trackedentityattribute/ShowAttributeVisitScheduleFormAction.java	2014-04-04 17:43:59 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-program/src/main/java/org/hisp/dhis/trackedentity/action/trackedentityattribute/ShowAttributeVisitScheduleFormAction.java	2014-06-02 01:32:37 +0000
@@ -32,7 +32,6 @@
 import java.util.Collections;
 import java.util.List;
 
-import org.hisp.dhis.common.comparator.IdentifiableObjectNameComparator;
 import org.hisp.dhis.trackedentity.TrackedEntityAttribute;
 import org.hisp.dhis.trackedentity.TrackedEntityAttributeService;
 import org.hisp.dhis.trackedentity.comparator.TrackedEntityAttributeSortOrderComparator;
@@ -62,13 +61,6 @@
     // Output
     // -------------------------------------------------------------------------
 
-    private List<TrackedEntityAttribute> availableAttributes = new ArrayList<TrackedEntityAttribute>();
-
-    public List<TrackedEntityAttribute> getAvailableAttributes()
-    {
-        return availableAttributes;
-    }
-
     private List<TrackedEntityAttribute> selectedAttributes = new ArrayList<TrackedEntityAttribute>();
 
     public List<TrackedEntityAttribute> getSelectedAttributes()
@@ -83,12 +75,9 @@
     public String execute()
         throws Exception
     {
-        availableAttributes = new ArrayList<TrackedEntityAttribute>(
-            attributeService.getTrackedEntityAttributesByDisplayOnVisitSchedule( false ) );
-        Collections.sort( availableAttributes, IdentifiableObjectNameComparator.INSTANCE );
-
         selectedAttributes = new ArrayList<TrackedEntityAttribute>(
             attributeService.getTrackedEntityAttributesByDisplayOnVisitSchedule( true ) );
+        
         Collections.sort( selectedAttributes, new TrackedEntityAttributeSortOrderComparator() );
 
         return SUCCESS;

=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-program/src/main/webapp/dhis-web-maintenance-program/attributeVisitSchedule.vm'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-program/src/main/webapp/dhis-web-maintenance-program/attributeVisitSchedule.vm	2014-06-02 01:08:01 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-program/src/main/webapp/dhis-web-maintenance-program/attributeVisitSchedule.vm	2014-06-02 01:32:37 +0000
@@ -1,3 +1,20 @@
+<script> 
+	jQuery(document).ready(	function(){
+		jQuery("#availableAttributes").dhisAjaxSelect({
+			source: 'getAttributes.action',
+			iterator: 'attributes',
+			connectedTo: 'selectedAttributeIds',
+			handler: function(item){
+				var option = jQuery( "<option/>" );
+				option.attr( "value", item.id );
+				option.text( item.name );
+				
+				return option;
+			}
+		});
+	});
+</script>
+		
 <h3>$i18n.getString( "tracked_entity_attribute_visit_schedule_form" ) #openHelp('tracked_entity_attribute_configuration')</h3>
 																			
 <form id="attributeVisitScheduleForm" name="attributeVisitScheduleForm" action="saveAttributeVisitSchedule.action" method="post" action='saveAttributeVisitSchedule.action' onsubmit="selectAllById('selectedAttributeIds');">
@@ -17,9 +34,6 @@
 	<tr>
 		<td>
 			<select style="height:200px; width:100%;" multiple="multiple" id="availableAttributes" name="availableAttributes" size="15" ondblclick="moveSelectedById( 'availableAttributes', 'selectedAttributeIds' )" >
-				#foreach($attribute in $availableAttributes)
-					<option value='$attribute.id'>$attribute.name</option>
-				#end
 			</select>
 		</td>
 		<td>
@@ -29,7 +43,7 @@
 			<input type="button" value="&lt;&lt;" onclick="moveAllById( 'selectedAttributeIds', 'availableAttributes' )" class='filterButton' />
 		</td>
 		<td>
-			<select style="height:200px; width:100%;" multiple="multiple" id="selectedAttributeIds" name="selectedAttributeIds" size="15" ondblclick="moveSelectedById( 'selectedAttributeIds', 'availableAttributes' )" >
+			<select style="height:200px; width:100%; margin-top: 22px;" multiple="multiple" id="selectedAttributeIds" name="selectedAttributeIds" size="15" ondblclick="moveSelectedById( 'selectedAttributeIds', 'availableAttributes' )" >
 				#foreach($attribute in $selectedAttributes)
 					<option value='$attribute.id'>$attribute.name</option>
 				#end