← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 17863: Edit user group screen, proper sorting

 

------------------------------------------------------------
revno: 17863
committer: Lars Helge Overland <larshelge@xxxxxxxxx>
branch nick: dhis2
timestamp: Fri 2015-01-02 20:56:22 +0100
message:
  Edit user group screen, proper sorting
modified:
  dhis-2/dhis-api/src/main/java/org/hisp/dhis/user/comparator/UserComparator.java
  dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-user/src/main/java/org/hisp/dhis/user/action/usergroup/EditUserGroupFormAction.java
  dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-user/src/main/webapp/dhis-web-maintenance-user/updateUserGroupForm.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-api/src/main/java/org/hisp/dhis/user/comparator/UserComparator.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/user/comparator/UserComparator.java	2014-10-16 06:17:19 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/user/comparator/UserComparator.java	2015-01-02 19:56:22 +0000
@@ -38,6 +38,8 @@
 public class UserComparator
     implements Comparator<User>
 {
+    public static final UserComparator INSTANCE = new UserComparator(); 
+    
     @Override
     public int compare( User u0, User u1 )
     {
@@ -51,6 +53,13 @@
             return -1;
         }
 
-        return u0.getSurname().compareTo( u1.getSurname() );
+        int compare = u0.getSurname().compareTo( u1.getSurname() );
+        
+        if ( compare != 0 )
+        {
+            return compare;
+        }
+        
+        return u0.getFirstName().compareTo( u1.getFirstName() );
     }
 }

=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-user/src/main/java/org/hisp/dhis/user/action/usergroup/EditUserGroupFormAction.java'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-user/src/main/java/org/hisp/dhis/user/action/usergroup/EditUserGroupFormAction.java	2014-12-18 11:41:20 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-user/src/main/java/org/hisp/dhis/user/action/usergroup/EditUserGroupFormAction.java	2015-01-02 19:56:22 +0000
@@ -41,6 +41,7 @@
 import org.hisp.dhis.user.User;
 import org.hisp.dhis.user.UserGroup;
 import org.hisp.dhis.user.UserGroupService;
+import org.hisp.dhis.user.comparator.UserComparator;
 
 import com.opensymphony.xwork2.Action;
 
@@ -90,6 +91,13 @@
     {
         return groupMembers;
     }
+    
+    private List<UserGroup> managedGroups = new ArrayList<>();
+
+    public List<UserGroup> getManagedGroups()
+    {
+        return managedGroups;
+    }
 
     private UserGroup group;
 
@@ -123,11 +131,15 @@
         group = userGroupService.getUserGroup( userGroupId );
 
         groupMembers = new ArrayList<>( group.getMembers() );
+        
+        managedGroups = new ArrayList<>( group.getManagedGroups() );
 
         attributes = new ArrayList<>( attributeService.getUserGroupAttributes() );
 
         attributeValues = AttributeUtils.getAttributeValueMap( group.getAttributeValues() );
 
+        Collections.sort( groupMembers, UserComparator.INSTANCE );
+        Collections.sort( managedGroups );
         Collections.sort( attributes, AttributeSortOrderComparator.INSTANCE );
 
         return SUCCESS;

=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-user/src/main/webapp/dhis-web-maintenance-user/updateUserGroupForm.vm'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-user/src/main/webapp/dhis-web-maintenance-user/updateUserGroupForm.vm	2014-12-28 17:51:04 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-user/src/main/webapp/dhis-web-maintenance-user/updateUserGroupForm.vm	2015-01-02 19:56:22 +0000
@@ -68,7 +68,7 @@
   "prefix": "userGroups",
   "i18n_available": "available_managed_user_groups",
   "i18n_selected": "managed_user_groups",
-  "objects": $group.managedGroups
+  "objects": $managedGroups
 })