← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 5903: Data entry, implemented function for displaying a dialog with info about the user who marked the ...

 

------------------------------------------------------------
revno: 5903
committer: Lars Helge Overland <larshelge@xxxxxxxxx>
branch nick: dhis2
timestamp: Thu 2012-02-09 19:17:37 +0100
message:
  Data entry, implemented function for displaying a dialog with info about the user who marked the form as complete
modified:
  dhis-2/dhis-web/dhis-web-commons/src/main/java/org/hisp/dhis/commons/action/GetUserAction.java
  dhis-2/dhis-web/dhis-web-dataentry/src/main/resources/org/hisp/dhis/de/i18n_module.properties
  dhis-2/dhis-web/dhis-web-dataentry/src/main/webapp/dhis-web-dataentry/javascript/form.js
  dhis-2/dhis-web/dhis-web-dataentry/src/main/webapp/dhis-web-dataentry/select.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-commons/src/main/java/org/hisp/dhis/commons/action/GetUserAction.java'
--- dhis-2/dhis-web/dhis-web-commons/src/main/java/org/hisp/dhis/commons/action/GetUserAction.java	2011-12-26 10:07:59 +0000
+++ dhis-2/dhis-web/dhis-web-commons/src/main/java/org/hisp/dhis/commons/action/GetUserAction.java	2012-02-09 18:17:37 +0000
@@ -28,6 +28,7 @@
  */
 
 import org.hisp.dhis.user.User;
+import org.hisp.dhis.user.UserCredentials;
 import org.hisp.dhis.user.UserService;
 
 import com.opensymphony.xwork2.Action;
@@ -59,6 +60,13 @@
     {
         this.id = id;
     }
+    
+    private String username;
+
+    public void setUsername( String username )
+    {
+        this.username = username;
+    }
 
     private User user;
 
@@ -73,8 +81,16 @@
 
     public String execute()
     {
-        user = userService.getUser( id );
-
+        if ( id != null )
+        {
+            user = userService.getUser( id );
+        }
+        else if ( username != null )
+        {
+            UserCredentials credentials = userService.getUserCredentialsByUsername( username );
+            
+            user = credentials != null ? credentials.getUser() : null;
+        }
         return SUCCESS;
     }
 }

=== modified file 'dhis-2/dhis-web/dhis-web-dataentry/src/main/resources/org/hisp/dhis/de/i18n_module.properties'
--- dhis-2/dhis-web/dhis-web-dataentry/src/main/resources/org/hisp/dhis/de/i18n_module.properties	2012-01-05 20:36:00 +0000
+++ dhis-2/dhis-web/dhis-web-dataentry/src/main/resources/org/hisp/dhis/de/i18n_module.properties	2012-02-09 18:17:37 +0000
@@ -149,4 +149,7 @@
 indicator_not_exist=Indicator does not exist
 does_not_exist=does not exist
 prev_year=Prev year
-next_year=Next year
\ No newline at end of file
+next_year=Next year
+see_details = See details
+username = Username
+user_roles = User roles
\ No newline at end of file

=== modified file 'dhis-2/dhis-web/dhis-web-dataentry/src/main/webapp/dhis-web-dataentry/javascript/form.js'
--- dhis-2/dhis-web/dhis-web-dataentry/src/main/webapp/dhis-web-dataentry/javascript/form.js	2012-01-18 06:11:17 +0000
+++ dhis-2/dhis-web/dhis-web-dataentry/src/main/webapp/dhis-web-dataentry/javascript/form.js	2012-02-09 18:17:37 +0000
@@ -38,6 +38,9 @@
 // value with one
 var currentPeriodOffset = 0;
 
+// Username of user who marked the current data set as complete if any
+var currentCompletedByUser = null;
+
 // Period type object
 var periodTypeFactory = new PeriodType();
 
@@ -713,6 +716,8 @@
 	                $( '#infoDiv' ).css( 'display', 'block' );
 	                $( '#completedBy' ).html( json.storedBy );
 	                $( '#completedDate' ).html( json.date );
+	                
+	                currentCompletedByUser = json.storedBy;
 	            }
 	        }
 	        else
@@ -904,6 +909,30 @@
     $( '#undoButton' ).removeAttr( 'disabled' );
 }
 
+function displayUserDetails()
+{
+	if ( currentCompletedByUser )
+	{
+		var url = '../dhis-web-commons-ajax-json/getUser.action';
+		
+		$.getJSON( url, { username:currentCompletedByUser }, function( json ) {
+			$( '#userFullName' ).html( json.user.firstName + " " + json.user.surname );
+			$( '#userUsername' ).html( json.user.username );
+			$( '#userEmail' ).html( json.user.email );
+			$( '#userPhoneNumber' ).html( json.user.phoneNumber );
+			$( '#userOrganisationUnits' ).html( joinNameableObjects( json.user.organisationUnits ) );
+			$( '#userUserRoles' ).html( joinNameableObjects( json.user.roles ) );
+				
+			$( '#completedByDiv' ).dialog( {
+	        	modal : true,
+	        	width : 350,
+	        	height : 350,
+	        	title : 'User'
+	    	} );
+		} );
+	}
+}
+
 // -----------------------------------------------------------------------------
 // Validation
 // -----------------------------------------------------------------------------

=== modified file 'dhis-2/dhis-web/dhis-web-dataentry/src/main/webapp/dhis-web-dataentry/select.vm'
--- dhis-2/dhis-web/dhis-web-dataentry/src/main/webapp/dhis-web-dataentry/select.vm	2012-01-05 20:36:00 +0000
+++ dhis-2/dhis-web/dhis-web-dataentry/src/main/webapp/dhis-web-dataentry/select.vm	2012-02-09 18:17:37 +0000
@@ -83,4 +83,32 @@
 <div id="infoDiv" class="page inputCriteria" style="display:none;width:386px;height:20px;">
 <span style="color:#505050">$i18n.getString( "completed_by" ): </span><span id="completedBy"></span>
 <span style="color:#505050"> $i18n.getString( "at" ): </span><span id="completedDate"></span>
+<a href="javascript:displayUserDetails()">$i18n.getString( "see_details" )</a>
+</div>
+
+
+<div id="completedByDiv" style="display:none" class="page">
+<h3><span id="userFullName"></span></h3>
+<table>
+	<tr>
+		<td><label>$i18n.getString( "username" ):</label></td>
+		<td><span id="userUsername"></span></td>
+	</tr>
+	<tr>
+		<td><label>$i18n.getString( "email" ):</label></td>
+		<td><span id="userEmail"></span></td>
+	</tr>
+	<tr>
+		<td><label>$i18n.getString( "phone_number" ):</label></td>
+		<td><span id="userPhoneNumber"></span></td>
+	</tr>
+	<tr>
+		<td><label>$i18n.getString( "organisation_units" ):</label></td>
+		<td><span id="userOrganisationUnits"></span></td>
+	</tr>
+	<tr>
+		<td><label>$i18n.getString( "user_roles" ):</label></td>
+		<td><span id="userUserRoles"></span></td>
+	</tr>
+</table>
 </div>