← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 9593: Add new value-type Username for data element.

 

------------------------------------------------------------
revno: 9593
committer: Tran Chau <tran.hispvietnam@xxxxxxxxx>
branch nick: dhis2
timestamp: Thu 2013-01-24 11:15:05 +0700
message:
  Add new value-type Username for data element.
added:
  dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/caseentry/GetUsernameListAction.java
  dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/jsonUsernames.vm
modified:
  dhis-2/dhis-api/src/main/java/org/hisp/dhis/dataelement/DataElement.java
  dhis-2/dhis-api/src/main/java/org/hisp/dhis/user/UserCredentialsStore.java
  dhis-2/dhis-api/src/main/java/org/hisp/dhis/user/UserService.java
  dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/user/DefaultUserService.java
  dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/user/hibernate/HibernateUserCredentialsStore.java
  dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/user/hibernate/HibernateUserStore.java
  dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/program/DefaultProgramDataEntryService.java
  dhis-2/dhis-web/dhis-web-caseentry/src/main/resources/META-INF/dhis/beans.xml
  dhis-2/dhis-web/dhis-web-caseentry/src/main/resources/struts.xml
  dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/defaultDataEntryForm.vm
  dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/javascript/entry.js
  dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/sectionDataEntryForm.vm
  dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-datadictionary/src/main/webapp/dhis-web-maintenance-datadictionary/addDataElementForm.vm
  dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-datadictionary/src/main/webapp/dhis-web-maintenance-datadictionary/updateDataElementForm.vm
  dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/javascript/viewDataEntryForm.js


--
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/dataelement/DataElement.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/dataelement/DataElement.java	2012-11-05 19:23:01 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/dataelement/DataElement.java	2013-01-24 04:15:05 +0000
@@ -83,6 +83,8 @@
     public static final String VALUE_TYPE_INT = "int";
 
     public static final String VALUE_TYPE_NUMBER = "number";
+    
+    public static final String VALUE_TYPE_USER_NAME = "username";
 
     public static final String VALUE_TYPE_POSITIVE_INT = "positiveNumber";
 

=== modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/user/UserCredentialsStore.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/user/UserCredentialsStore.java	2012-11-08 09:46:51 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/user/UserCredentialsStore.java	2013-01-24 04:15:05 +0000
@@ -178,4 +178,7 @@
      * @return a Collection of UserSettings.
      */
     Collection<UserSetting> getUserSettings( String name );
+    
+    Collection<String> getUsernames( String key, Integer max );
+
 }

=== modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/user/UserService.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/user/UserService.java	2012-12-04 12:58:11 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/user/UserService.java	2013-01-24 04:15:05 +0000
@@ -374,5 +374,8 @@
      */
     void removeUserSettings( User user );
     
-    Collection<User> getUsersByName( String name );    
+    Collection<User> getUsersByName( String name );  
+    
+    Collection<String> getUsernames( String query, Integer max );
+    
 }

=== modified file 'dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/user/DefaultUserService.java'
--- dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/user/DefaultUserService.java	2013-01-23 11:54:42 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/user/DefaultUserService.java	2013-01-24 04:15:05 +0000
@@ -518,4 +518,10 @@
     {
         userStore.removeUserSettings( user );
     }
+    
+    public Collection<String> getUsernames( String query, Integer max )
+    {
+        return userCredentialsStore.getUsernames( query, max );
+    }
+    
 }

=== modified file 'dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/user/hibernate/HibernateUserCredentialsStore.java'
--- dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/user/hibernate/HibernateUserCredentialsStore.java	2012-11-08 09:46:51 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/user/hibernate/HibernateUserCredentialsStore.java	2013-01-24 04:15:05 +0000
@@ -62,7 +62,7 @@
     {
         this.sessionFactory = sessionFactory;
     }
-    
+
     private UserService userService;
 
     public void setUserService( UserService userService )
@@ -168,8 +168,8 @@
     {
         Session session = sessionFactory.getCurrentSession();
 
-        return session.createQuery( "from UserCredentials order by username" ).setFirstResult( first ).setMaxResults(
-            max ).list();
+        return session.createQuery( "from UserCredentials order by username" ).setFirstResult( first )
+            .setMaxResults( max ).list();
     }
 
     @SuppressWarnings( "unchecked" )
@@ -215,7 +215,8 @@
 
     public Collection<UserCredentials> getUsersWithoutOrganisationUnitBetweenByName( String name, int first, int max )
     {
-        return getBlockUser( findByName( toUserCredentials( userService.getUsersWithoutOrganisationUnit() ), name ), first, max );
+        return getBlockUser( findByName( toUserCredentials( userService.getUsersWithoutOrganisationUnit() ), name ),
+            first, max );
     }
 
     public int getUsersWithoutOrganisationUnitCount()
@@ -236,10 +237,10 @@
         criteria.addOrder( Order.desc( "created" ) );
         criteria.setFirstResult( first );
         criteria.setMaxResults( max );
-        
+
         return criteria.list();
     }
-    
+
     public int getSelfRegisteredUserCredentialsCount()
     {
         Criteria criteria = sessionFactory.getCurrentSession().createCriteria( UserCredentials.class );
@@ -250,7 +251,7 @@
 
         return rs != null ? rs.intValue() : 0;
     }
-    
+
     @SuppressWarnings( "unchecked" )
     public Collection<UserCredentials> getInactiveUsers( Date date )
     {
@@ -351,6 +352,28 @@
         session.delete( userSetting );
     }
 
+    @SuppressWarnings( "unchecked" )
+    public Collection<String> getUsernames( String key, Integer max )
+    {
+        Session session = sessionFactory.getCurrentSession();
+
+        String hql = "select username from UserCredentials ";
+
+        if ( key != null )
+        {
+            hql += "where lower(username) like lower('%" + key + "%') ";
+        }
+
+        Query query = session.createQuery( hql );
+        
+        if ( max != null )
+        {
+            query.setMaxResults( max );
+        }
+
+        return query.list();
+    }
+
     // -------------------------------------------------------------------------
     // Supportive methods
     // -------------------------------------------------------------------------

=== modified file 'dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/user/hibernate/HibernateUserStore.java'
--- dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/user/hibernate/HibernateUserStore.java	2013-01-14 21:35:56 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/user/hibernate/HibernateUserStore.java	2013-01-24 04:15:05 +0000
@@ -49,8 +49,6 @@
     extends HibernateIdentifiableObjectStore<User>
     implements UserStore
 {
-  
-    
     // -------------------------------------------------------------------------
     // UserStore implementation
     // -------------------------------------------------------------------------
@@ -133,4 +131,5 @@
         
         return criteria.list();  
     }
+    
 }

=== modified file 'dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/program/DefaultProgramDataEntryService.java'
--- dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/program/DefaultProgramDataEntryService.java	2013-01-23 10:27:28 +0000
+++ dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/program/DefaultProgramDataEntryService.java	2013-01-24 04:15:05 +0000
@@ -242,7 +242,8 @@
                 tabindex++;
 
                 if ( DataElement.VALUE_TYPE_INT.equals( dataElement.getType() )
-                    || DataElement.VALUE_TYPE_STRING.equals( dataElement.getType() ) )
+                    || DataElement.VALUE_TYPE_STRING.equals( dataElement.getType() )
+                    || DataElement.VALUE_TYPE_USER_NAME.equals( dataElement.getType() ) )
                 {
                     inputHTML = populateCustomDataEntryForTextBox( dataElement, inputHTML, dataElementValue );
                 }

=== added file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/caseentry/GetUsernameListAction.java'
--- dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/caseentry/GetUsernameListAction.java	1970-01-01 00:00:00 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/caseentry/GetUsernameListAction.java	2013-01-24 04:15:05 +0000
@@ -0,0 +1,90 @@
+/*
+ * Copyright (c) 2004-2009, University of Oslo
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ * * Redistributions of source code must retain the above copyright notice, this
+ *   list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright notice,
+ *   this list of conditions and the following disclaimer in the documentation
+ *   and/or other materials provided with the distribution.
+ * * Neither the name of the HISP project nor the names of its contributors may
+ *   be used to endorse or promote products derived from this software without
+ *   specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
+ * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
+ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+package org.hisp.dhis.caseentry.action.caseentry;
+
+import java.util.Collection;
+
+import org.hisp.dhis.user.UserService;
+
+import com.opensymphony.xwork2.Action;
+
+/**
+ * @author Chau Thu Tran
+ * 
+ * @version GetUsernameListAction.java 10:24:15 AM Jan 24, 2013 $
+ */
+public class GetUsernameListAction
+    implements Action
+{
+    private static Integer MAX_USER_DISPLAYED = 30;
+
+    // -------------------------------------------------------------------------
+    // Dependencies
+    // -------------------------------------------------------------------------
+
+    private UserService userService;
+
+    public void setUserService( UserService userService )
+    {
+        this.userService = userService;
+    }
+
+    // -------------------------------------------------------------------------
+    // Input
+    // -------------------------------------------------------------------------
+
+    private String query;
+
+    public void setQuery( String query )
+    {
+        this.query = query;
+    }
+
+    // -------------------------------------------------------------------------
+    // Output
+    // -------------------------------------------------------------------------
+
+    private Collection<String> usernames;
+
+    public Collection<String> getUsernames()
+    {
+        return usernames;
+    }
+
+    // -------------------------------------------------------------------------
+    // Action implementation
+    // -------------------------------------------------------------------------
+
+    public String execute()
+    {
+        usernames = userService.getUsernames( query, MAX_USER_DISPLAYED );
+
+        return SUCCESS;
+    }
+
+}

=== modified file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/resources/META-INF/dhis/beans.xml'
--- dhis-2/dhis-web/dhis-web-caseentry/src/main/resources/META-INF/dhis/beans.xml	2013-01-21 06:18:31 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/resources/META-INF/dhis/beans.xml	2013-01-24 04:15:05 +0000
@@ -142,6 +142,13 @@
 		<property name="dataElementService" ref="org.hisp.dhis.dataelement.DataElementService" />
 		<property name="optionService" ref="org.hisp.dhis.option.OptionService" />
 	</bean>
+	
+	<bean
+		id="org.hisp.dhis.caseentry.action.caseentry.GetUsernameListAction"
+		class="org.hisp.dhis.caseentry.action.caseentry.GetUsernameListAction"
+		scope="prototype">
+		<property name="userService" ref="org.hisp.dhis.user.UserService" />
+	</bean>
 
 	<!-- Multi DataEntry -->
 

=== modified file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/resources/struts.xml'
--- dhis-2/dhis-web/dhis-web-caseentry/src/main/resources/struts.xml	2013-01-21 06:18:31 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/resources/struts.xml	2013-01-24 04:15:05 +0000
@@ -194,6 +194,12 @@
 			</result>
 		</action>
 
+		<action name="getUsernameList"
+			class="org.hisp.dhis.caseentry.action.caseentry.GetUsernameListAction">
+			<result name="success" type="velocity-json">/dhis-web-caseentry/jsonUsernames.vm
+			</result>
+		</action>
+		
 		<!-- save value -->
 
 		<action name="saveValue"

=== modified file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/defaultDataEntryForm.vm'
--- dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/defaultDataEntryForm.vm	2013-01-23 04:48:39 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/defaultDataEntryForm.vm	2013-01-24 04:15:05 +0000
@@ -59,7 +59,9 @@
 					datePicker($programStageDataElement.programStage.id + '-' + $programStageDataElement.dataElement.id + '-val', false);
 				</script> 
 			#elseif($hasOptionSet=='true')
-				<input name="entryfield" options='$hasOptionSet' #if($hasOptionSet == 'true') #end dataElementId='$programStageDataElement.dataElement.id' data="{compulsory: $programStageDataElement.compulsory, deName:'$programStageDataElement.dataElement.name', deType:'$programStageDataElement.dataElement.getDetailedNumberType()' }" id="$id" type="text" value="$!encoder.htmlEncode( $patientDataValue.value )" onkeypress="return keyPress(event, this)" tabindex="$tabIndex" class="optionset" />
+				<input name="entryfield" options='$hasOptionSet' dataElementId='$programStageDataElement.dataElement.id' data="{compulsory: $programStageDataElement.compulsory, deName:'$programStageDataElement.dataElement.name', deType:'$programStageDataElement.dataElement.getDetailedNumberType()' }" id="$id" type="text" value="$!encoder.htmlEncode( $patientDataValue.value )" onkeypress="return keyPress(event, this)" tabindex="$tabIndex" class="optionset" />
+			#elseif($programStageDataElement.dataElement.type=='username')
+				<input name="entryfield" username='true' dataElementId='$programStageDataElement.dataElement.id' data="{compulsory: $programStageDataElement.compulsory, deName:'$programStageDataElement.dataElement.name', deType:'$programStageDataElement.dataElement.getDetailedNumberType()' }" id="$id" type="text" value="$!encoder.htmlEncode( $patientDataValue.value )" onkeypress="return keyPress(event, this)" tabindex="$tabIndex" />
 			#else
 				<input name="entryfield" dataElementId='$programStageDataElement.dataElement.id' 
 					data="{compulsory: $programStageDataElement.compulsory, deName:'$programStageDataElement.dataElement.name', deType:'$programStageDataElement.dataElement.getDetailedNumberType()' }" onkeypress="return keyPress(event, this)" tabindex="$tabIndex"

=== modified file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/javascript/entry.js'
--- dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/javascript/entry.js	2013-01-23 06:04:08 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/javascript/entry.js	2013-01-24 04:15:05 +0000
@@ -623,6 +623,10 @@
 			{
 				autocompletedField(jQuery(this).attr('id'));
 			}
+			else if( jQuery(this).attr( 'username' )!= null && jQuery(this).attr( 'username' )== 'true' )
+			{
+				autocompletedUsernameField(jQuery(this).attr('id'));
+			}
 		});
     }
 }
@@ -731,3 +735,92 @@
 			input.focus();
 		});
 }
+
+function autocompletedUsernameField( idField )
+{
+	var input = jQuery( "#" +  idField );
+	input.parent().width( input.width() + 200 );
+	var dataElementId = input.attr('id').split('-')[1];
+	
+	input.autocomplete({
+		delay: 0,
+		minLength: 0,
+		source: function( request, response ){
+			$.ajax({
+				url: "getUsernameList.action?query=" + input.val(),
+				dataType: "json",
+				cache: true,
+				success: function(data) {
+					response($.map(data.usernames, function(item) {
+						return {
+							label: item.u,
+							id: item.u
+						};
+					}));
+				}
+			});
+		},
+		minLength: 0,
+		select: function( event, ui ) {
+			var fieldValue = ui.item.value;
+			
+			if ( !dhis2.trigger.invoke( "caseentry-value-selected", [dataElementId, fieldValue] ) ) {
+				input.val( "" );
+				return false;
+			}
+			
+			input.val( fieldValue );			
+			if ( !unSave ) {
+				saveVal( dataElementId );
+			}
+			input.autocomplete( "close" );
+		},
+		change: function( event, ui ) {
+			if ( !ui.item ) {
+				var matcher = new RegExp( "^" + $.ui.autocomplete.escapeRegex( $(this).val() ) + "$", "i" ),
+					valid = false;
+				if ( !valid ) {
+					$( this ).val( "" );
+					if(!unSave)
+						saveVal( dataElementId );
+					input.data( "autocomplete" ).term = "";
+					return false;
+				}
+			}
+		}
+	})
+	.addClass( "ui-widget" );
+	
+	input.data( "autocomplete" )._renderItem = function( ul, item ) {
+		return $( "<li></li>" )
+			.data( "item.autocomplete", item )
+			.append( "<a>" + item.label + "</a>" )
+			.appendTo( ul );
+	};
+		
+	var wrapper = this.wrapper = $( "<span style='width:200px'>" )
+			.addClass( "ui-combobox" )
+			.insertAfter( input );
+						
+	var button = $( "<a style='width:20px; margin-bottom:-5px;height:20px;'>" )
+		.attr( "tabIndex", -1 )
+		.attr( "title", i18n_show_all_items )
+		.appendTo( wrapper )
+		.button({
+			icons: {
+				primary: "ui-icon-triangle-1-s"
+			},
+			text: false
+		})
+		.addClass('small-button')
+		.click(function() {
+			if ( input.autocomplete( "widget" ).is( ":visible" ) ) {
+				input.autocomplete( "close" );
+				return;
+			}
+			$( this ).blur();
+			input.autocomplete( "search", "" );
+			input.focus();
+		});
+}
+

=== added file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/jsonUsernames.vm'
--- dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/jsonUsernames.vm	1970-01-01 00:00:00 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/jsonUsernames.vm	2013-01-24 04:15:05 +0000
@@ -0,0 +1,2 @@
+{ "usernames": [#foreach( $username in $usernames ){"u":"$username"}#if( $velocityCount < $usernames.size() ),#end #end]
+}
\ No newline at end of file

=== modified file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/sectionDataEntryForm.vm'
--- dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/sectionDataEntryForm.vm	2013-01-03 09:04:36 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/sectionDataEntryForm.vm	2013-01-24 04:15:05 +0000
@@ -73,6 +73,8 @@
 									</script> 
 								#elseif($hasOptionSet=='true')
 									<input name="entryfield" options='$hasOptionSet' #if($hasOptionSet == 'true') #end dataElementId='$programStageDataElement.dataElement.id' data="{compulsory: $programStageDataElement.compulsory, deName:'$programStageDataElement.dataElement.name', deType:'$programStageDataElement.dataElement.getDetailedNumberType()' }" id="$id" type="text" value="$!encoder.htmlEncode( $patientDataValue.value )" onkeypress="return keyPress(event, this)" tabindex="$tabIndex" class="optionset" />
+								#elseif($programStageDataElement.dataElement.type=='username')
+									<input name="entryfield" username='true' dataElementId='$programStageDataElement.dataElement.id' data="{compulsory: $programStageDataElement.compulsory, deName:'$programStageDataElement.dataElement.name', deType:'$programStageDataElement.dataElement.getDetailedNumberType()' }" id="$id" type="text" value="$!encoder.htmlEncode( $patientDataValue.value )" onkeypress="return keyPress(event, this)" tabindex="$tabIndex" />
 								#else
 									<input name="entryfield" dataElementId='$programStageDataElement.dataElement.id' 
 										data="{compulsory: $programStageDataElement.compulsory, deName:'$programStageDataElement.dataElement.name', deType:'$programStageDataElement.dataElement.getDetailedNumberType()' }" onkeypress="return keyPress(event, this)" tabindex="$tabIndex"

=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-datadictionary/src/main/webapp/dhis-web-maintenance-datadictionary/addDataElementForm.vm'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-datadictionary/src/main/webapp/dhis-web-maintenance-datadictionary/addDataElementForm.vm	2013-01-23 08:42:50 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-datadictionary/src/main/webapp/dhis-web-maintenance-datadictionary/addDataElementForm.vm	2013-01-24 04:15:05 +0000
@@ -67,11 +67,12 @@
 		<td><label for="valueType">$i18n.getString( "value_type" ) <em title="$i18n.getString( 'required' )" class="required">*</em></label></td>
 		<td>
 			<select id="valueType" onchange="changeValueType( this.value )">
-				<option value="int" selected="selected" onclick="enable('numberType');">$i18n.getString( "number" )</option>
-				<option value="string" onclick="disable('numberType');enable('textType')">$i18n.getString( "text" )</option>
-				<option value="bool" onclick="disable('numberType');">$i18n.getString( "yes_no" )</option>
-				<option value="trueOnly" onclick="disable('numberType');">$i18n.getString( "yes_only" )</option>
-				<option value="date" onclick="disable('numberType');">$i18n.getString( "date" )</option>
+				<option value="int" selected="selected">$i18n.getString( "number" )</option>
+				<option value="string">$i18n.getString( "text" )</option>
+				<option value="bool">$i18n.getString( "yes_no" )</option>
+				<option value="trueOnly">$i18n.getString( "yes_only" )</option>
+				<option value="date">$i18n.getString( "date" )</option>
+				<option value="username">$i18n.getString( "user_name" )</option>
 			</select>
 			<input type="hidden" id="submitValueType" name="valueType"/>
 		</td>

=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-datadictionary/src/main/webapp/dhis-web-maintenance-datadictionary/updateDataElementForm.vm'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-datadictionary/src/main/webapp/dhis-web-maintenance-datadictionary/updateDataElementForm.vm	2013-01-23 08:42:50 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-datadictionary/src/main/webapp/dhis-web-maintenance-datadictionary/updateDataElementForm.vm	2013-01-24 04:15:05 +0000
@@ -83,6 +83,7 @@
 				<option value="trueOnly" #if( $dataElement.type == 'trueOnly' ) selected="selected" #end >$i18n.getString( "yes_only" )</option>
 				<option value="bool" #if( $dataElement.type == 'bool' ) selected="selected" #end >$i18n.getString( "yes_no" )</option>
 				<option value="date" #if( $dataElement.type == 'date' ) selected="selected" #end >$i18n.getString( "date" )</option>
+				<option value="username" #if( $dataElement.type == 'username' ) selected="selected" #end >$i18n.getString( "user_name" )</option>
 			</select>
 		</td>
 	</tr>

=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/javascript/viewDataEntryForm.js'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/javascript/viewDataEntryForm.js	2013-01-18 01:23:52 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/javascript/viewDataEntryForm.js	2013-01-24 04:15:05 +0000
@@ -161,6 +161,11 @@
 		var displayName = dataElementName;
 		htmlCode = "<input type=\"checkbox\" title=\"" + titleValue + "\" name=\"entryselect\" id=\"" + id + "\" title=\"" + displayName + "\">";
 	} 
+	else if ( dataElementType == "username" )
+	{
+		var displayName = dataElementName;
+		htmlCode = "<input type=\"checkbox\" title=\"" + titleValue + "\" name=\"entryselect\" id=\"" + id + "\" title=\"" + displayName + "\ username=\"true\" ">";
+	} 
 	else
 	{
 		var displayName = dataElementName;