← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 14675: Fixed bug - Don't display the attribute by order in Tracked entity attributes with no program form

 

------------------------------------------------------------
revno: 14675
committer: Tran Chau <tran.hispvietnam@xxxxxxxxx>
branch nick: dhis2
timestamp: Sat 2014-04-05 00:43:59 +0700
message:
  Fixed bug - Don't display the attribute by order in Tracked entity attributes with no program form
modified:
  dhis-2/dhis-services/dhis-service-tracker/src/main/resources/org/hisp/dhis/trackedentity/hibernate/TrackedEntityAttribute.hbm.xml
  dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-program/src/main/java/org/hisp/dhis/trackedentity/action/trackedentityattribute/SaveAttributeInListNoProgramAction.java
  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/resources/struts.xml
  dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-program/src/main/webapp/dhis-web-maintenance-program/attributeInListNoProgram.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-services/dhis-service-tracker/src/main/resources/org/hisp/dhis/trackedentity/hibernate/TrackedEntityAttribute.hbm.xml'
--- dhis-2/dhis-services/dhis-service-tracker/src/main/resources/org/hisp/dhis/trackedentity/hibernate/TrackedEntityAttribute.hbm.xml	2014-03-26 17:39:16 +0000
+++ dhis-2/dhis-services/dhis-service-tracker/src/main/resources/org/hisp/dhis/trackedentity/hibernate/TrackedEntityAttribute.hbm.xml	2014-04-04 17:43:59 +0000
@@ -37,6 +37,8 @@
     <property name="sortOrderInVisitSchedule" />
 
     <property name="displayInListNoProgram" />
+    
+    <property name="sortOrderInListNoProgram" />
 
     <property name="unique" column="uniquefield" />
 

=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-program/src/main/java/org/hisp/dhis/trackedentity/action/trackedentityattribute/SaveAttributeInListNoProgramAction.java'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-program/src/main/java/org/hisp/dhis/trackedentity/action/trackedentityattribute/SaveAttributeInListNoProgramAction.java	2014-03-18 08:10:10 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-program/src/main/java/org/hisp/dhis/trackedentity/action/trackedentityattribute/SaveAttributeInListNoProgramAction.java	2014-04-04 17:43:59 +0000
@@ -41,8 +41,6 @@
 public class SaveAttributeInListNoProgramAction
     implements Action
 {
-    private final String PREFIX_ATTRIBUTE = "attr";
-
     // -------------------------------------------------------------------------
     // Dependencies
     // -------------------------------------------------------------------------
@@ -58,9 +56,9 @@
     // Input/Output
     // -------------------------------------------------------------------------
 
-    private String[] selectedAttributeIds;
+    private Integer[] selectedAttributeIds;
 
-    public void setSelectedAttributeIds( String[] selectedAttributeIds )
+    public void setSelectedAttributeIds( Integer[] selectedAttributeIds )
     {
         this.selectedAttributeIds = selectedAttributeIds;
     }
@@ -74,23 +72,17 @@
     {
         Collection<TrackedEntityAttribute> attributes = attributeService.getAllTrackedEntityAttributes();
 
-        int indexAttr = 1;
+        int index = 1;
         if ( selectedAttributeIds != null )
         {
-            for ( String objectId : selectedAttributeIds )
+            for ( Integer objectId : selectedAttributeIds )
             {
-                // Identifier type
-                String[] id = objectId.split( "_" );
-                if ( id[0].equals( PREFIX_ATTRIBUTE ) )
-                {
-                    TrackedEntityAttribute attribute = attributeService.getTrackedEntityAttribute( Integer
-                        .parseInt( id[1] ) );
-                    attribute.setDisplayInListNoProgram( true );
-                    attribute.setSortOrderInListNoProgram( indexAttr );
-                    attributeService.updateTrackedEntityAttribute( attribute );
-                    indexAttr++;
-                    attributes.remove( attribute );
-                }
+                TrackedEntityAttribute attribute = attributeService.getTrackedEntityAttribute( objectId );
+                attribute.setDisplayInListNoProgram( true );
+                attribute.setSortOrderInListNoProgram( index );
+                attributeService.updateTrackedEntityAttribute( attribute );
+                index++;
+                attributes.remove( attribute );
             }
         }
 

=== 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-03-20 15:05:57 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-program/src/main/java/org/hisp/dhis/trackedentity/action/trackedentityattribute/ShowAttributeInListNoProgramAction.java	2014-04-04 17:43:59 +0000
@@ -35,6 +35,7 @@
 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;
 
 import com.opensymphony.xwork2.Action;
 
@@ -89,7 +90,7 @@
 
         selectedAttributes = new ArrayList<TrackedEntityAttribute>(
             attributeService.getTrackedEntityAttributesDisplayInList( true ) );
-        Collections.sort( availableAttributes, IdentifiableObjectNameComparator.INSTANCE );
+        Collections.sort( selectedAttributes, new TrackedEntityAttributeSortOrderInListNoProgramComparator() );
 
         return SUCCESS;
     }

=== 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-03-18 08:10:10 +0000
+++ 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
@@ -35,6 +35,7 @@
 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;
 
 import com.opensymphony.xwork2.Action;
 
@@ -88,7 +89,7 @@
 
         selectedAttributes = new ArrayList<TrackedEntityAttribute>(
             attributeService.getTrackedEntityAttributesByDisplayOnVisitSchedule( true ) );
-        Collections.sort( availableAttributes, IdentifiableObjectNameComparator.INSTANCE );
+        Collections.sort( selectedAttributes, new TrackedEntityAttributeSortOrderComparator() );
 
         return SUCCESS;
     }

=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-program/src/main/resources/struts.xml'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-program/src/main/resources/struts.xml	2014-03-24 19:24:58 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-program/src/main/resources/struts.xml	2014-04-04 17:43:59 +0000
@@ -172,7 +172,7 @@
 
     <action name="saveAttributeInListNoProgram"
       class="org.hisp.dhis.trackedentity.action.trackedentityattribute.SaveAttributeInListNoProgramAction">
-      <result name="success" type="redirect">index.action</result>
+      <result name="success" type="redirect">attribute.action</result>
       <param name="anyAuthorities">F_TRACKED_ENTITY_ATTRIBUTE_PUBLIC_ADD, F_TRACKED_ENTITY_ATTRIBUTE_PRIVATE_ADD</param>
     </action>
 

=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-program/src/main/webapp/dhis-web-maintenance-program/attributeInListNoProgram.vm'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-program/src/main/webapp/dhis-web-maintenance-program/attributeInListNoProgram.vm	2014-02-07 20:25:49 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-program/src/main/webapp/dhis-web-maintenance-program/attributeInListNoProgram.vm	2014-04-04 17:43:59 +0000
@@ -34,7 +34,7 @@
 		<td>
 			<select style='width:322px' multiple="multiple" id="availableAttributes" name="availableAttributes" size="15" ondblclick="moveSelectedById( 'availableAttributes', 'selectedAttributeIds' )" >
 				#foreach($attribute in $availableAttributes)
-					<option value='attr_$attribute.id'>$attribute.displayName</option>
+					<option value='$attribute.id'>$attribute.displayName</option>
 				#end
 			</select>
 		</td>
@@ -47,7 +47,7 @@
 		<td>
 			<select style='width:322px' multiple="multiple" id="selectedAttributeIds" name="selectedAttributeIds" size="15" ondblclick="moveSelectedById( 'selectedAttributeIds', 'availableAttributes' )" >
 				#foreach($attribute in $selectedAttributes)
-					<option value='attr_$attribute.id'>$attribute.displayName</option>
+					<option value='$attribute.id'>$attribute.displayName</option>
 				#end
 			</select>
 		</td>