=== modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/user/User.java' --- dhis-2/dhis-api/src/main/java/org/hisp/dhis/user/User.java 2012-07-02 12:40:50 +0000 +++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/user/User.java 2012-10-06 08:45:50 +0000 @@ -74,19 +74,34 @@ private String email; private String phoneNumber; - + private String jobTitle; + private String introduction; + + private String gender; + + private Date birthday; + + private String nationality; + + private String employer; + + private String education; + + private String interests; + + private String languages; + private Date lastCheckedInterpretations; - + private UserCredentials userCredentials; private Set groups = new HashSet(); - + /** - * All OrgUnits where the user could belong - *

- * TODO This should have been put in UserCredentials + * All OrgUnits where the user could belong

TODO This should have been + * put in UserCredentials */ @Scanned private Set organisationUnits = new HashSet(); @@ -119,7 +134,8 @@ // Logic // ------------------------------------------------------------------------- - // TODO fix, users might very well have the same name, should use credentials + // TODO fix, users might very well have the same name, should use + // credentials @Override public boolean equals( Object object ) @@ -233,7 +249,7 @@ * Null is returned if the user has no organisation units. Which * organisation unit to return is undefined if the user has multiple * organisation units. - * + * * @return an organisation unit associated with the user. */ public OrganisationUnit getOrganisationUnit() @@ -271,7 +287,7 @@ // ------------------------------------------------------------------------- @JsonProperty - @JsonView( {DetailedView.class, ExportView.class} ) + @JsonView( { DetailedView.class, ExportView.class } ) @JacksonXmlProperty( namespace = Dxf2Namespace.NAMESPACE ) public String getFirstName() { @@ -284,7 +300,7 @@ } @JsonProperty - @JsonView( {DetailedView.class, ExportView.class} ) + @JsonView( { DetailedView.class, ExportView.class } ) @JacksonXmlProperty( namespace = Dxf2Namespace.NAMESPACE ) public String getSurname() { @@ -297,7 +313,7 @@ } @JsonProperty - @JsonView( {DetailedView.class, ExportView.class} ) + @JsonView( { DetailedView.class, ExportView.class } ) @JacksonXmlProperty( namespace = Dxf2Namespace.NAMESPACE ) public String getEmail() { @@ -310,7 +326,7 @@ } @JsonProperty - @JsonView( {DetailedView.class, ExportView.class} ) + @JsonView( { DetailedView.class, ExportView.class } ) @JacksonXmlProperty( namespace = Dxf2Namespace.NAMESPACE ) public String getJobTitle() { @@ -323,7 +339,7 @@ } @JsonProperty - @JsonView( {DetailedView.class, ExportView.class} ) + @JsonView( { DetailedView.class, ExportView.class } ) @JacksonXmlProperty( namespace = Dxf2Namespace.NAMESPACE ) public String getPhoneNumber() { @@ -335,6 +351,110 @@ this.phoneNumber = phoneNumber; } + @JsonProperty + @JsonView( { DetailedView.class, ExportView.class } ) + @JacksonXmlProperty( namespace = Dxf2Namespace.NAMESPACE ) + public String getIntroduction() + { + return introduction; + } + + public void setIntroduction( String introduction ) + { + this.introduction = introduction; + } + + @JsonProperty + @JsonView( { DetailedView.class, ExportView.class } ) + @JacksonXmlProperty( namespace = Dxf2Namespace.NAMESPACE ) + public String getGender() + { + return gender; + } + + public void setGender( String gender ) + { + this.gender = gender; + } + + @JsonProperty + @JsonView( { DetailedView.class, ExportView.class } ) + @JacksonXmlProperty( namespace = Dxf2Namespace.NAMESPACE ) + public Date getBirthday() + { + return birthday; + } + + public void setBirthday( Date birthday ) + { + this.birthday = birthday; + } + + @JsonProperty + @JsonView( { DetailedView.class, ExportView.class } ) + @JacksonXmlProperty( namespace = Dxf2Namespace.NAMESPACE ) + public String getNationality() + { + return nationality; + } + + public void setNationality( String nationality ) + { + this.nationality = nationality; + } + + @JsonProperty + @JsonView( { DetailedView.class, ExportView.class } ) + @JacksonXmlProperty( namespace = Dxf2Namespace.NAMESPACE ) + public String getEmployer() + { + return employer; + } + + public void setEmployer( String employer ) + { + this.employer = employer; + } + + @JsonProperty + @JsonView( { DetailedView.class, ExportView.class } ) + @JacksonXmlProperty( namespace = Dxf2Namespace.NAMESPACE ) + public String getEducation() + { + return education; + } + + public void setEducation( String education ) + { + this.education = education; + } + + @JsonProperty + @JsonView( { DetailedView.class, ExportView.class } ) + @JacksonXmlProperty( namespace = Dxf2Namespace.NAMESPACE ) + public String getInterests() + { + return interests; + } + + public void setInterests( String interests ) + { + this.interests = interests; + } + + @JsonProperty + @JsonView( { DetailedView.class, ExportView.class } ) + @JacksonXmlProperty( namespace = Dxf2Namespace.NAMESPACE ) + public String getLanguages() + { + return languages; + } + + public void setLanguages( String languages ) + { + this.languages = languages; + } + public Date getLastCheckedInterpretations() { return lastCheckedInterpretations; @@ -346,7 +466,7 @@ } @JsonProperty - @JsonView( {DetailedView.class, ExportView.class} ) + @JsonView( { DetailedView.class, ExportView.class } ) @JacksonXmlProperty( namespace = Dxf2Namespace.NAMESPACE ) public UserCredentials getUserCredentials() { @@ -370,7 +490,7 @@ @JsonProperty @JsonSerialize( contentAs = BaseIdentifiableObject.class ) - @JsonView( {DetailedView.class, ExportView.class} ) + @JsonView( { DetailedView.class, ExportView.class } ) @JacksonXmlElementWrapper( localName = "organisationUnits", namespace = Dxf2Namespace.NAMESPACE ) @JacksonXmlProperty( localName = "organisationUnit", namespace = Dxf2Namespace.NAMESPACE ) public Collection getOrganisationUnits() @@ -384,7 +504,7 @@ } @JsonProperty( value = "attributes" ) - @JsonView( {DetailedView.class, ExportView.class} ) + @JsonView( { DetailedView.class, ExportView.class } ) @JacksonXmlElementWrapper( localName = "attributes", namespace = Dxf2Namespace.NAMESPACE ) @JacksonXmlProperty( localName = "attribute", namespace = Dxf2Namespace.NAMESPACE ) public Set getAttributeValues() === modified file 'dhis-2/dhis-services/dhis-service-core/src/main/resources/org/hisp/dhis/user/hibernate/User.hbm.xml' --- dhis-2/dhis-services/dhis-service-core/src/main/resources/org/hisp/dhis/user/hibernate/User.hbm.xml 2012-07-02 12:40:50 +0000 +++ dhis-2/dhis-services/dhis-service-core/src/main/resources/org/hisp/dhis/user/hibernate/User.hbm.xml 2012-10-06 08:45:50 +0000 @@ -28,6 +28,22 @@ + + + + + + + + + + + + + + + + === added file 'dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/javascripts/useraccount/updateUserProfileForm.js' --- dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/javascripts/useraccount/updateUserProfileForm.js 1970-01-01 00:00:00 +0000 +++ dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/javascripts/useraccount/updateUserProfileForm.js 2012-10-06 08:45:50 +0000 @@ -0,0 +1,35 @@ +jQuery( document ).ready( function() +{ + var rules = getValidationRules( "profile" ); + + validation2( 'updateUserProfileForm', updateUserProfile, { + 'rules' : rules + } ); + + datePickerValid( 'birthday', false ); + + jQuery( '#email' ).focus(); +} ); + +function updateUserProfile() +{ + jQuery.postUTF8( 'updateUserProfile.action', + { + id: getFieldValue( 'id' ), + email: getFieldValue( 'email' ), + phoneNumber: getFieldValue( 'phoneNumber' ), + introduction: getFieldValue( 'introduction' ), + jobTitle: getFieldValue( 'jobTitle' ), + gender: getFieldValue( 'gender' ), + birthday: getFieldValue( 'birthday' ), + nationality: getFieldValue( 'nationality' ), + employer: getFieldValue( 'employer' ), + education: getFieldValue( 'education' ), + interests: getFieldValue( 'interests' ), + languages: getFieldValue( 'languages' ) + } + , function( json ) + { + setHeaderDelayMessage( json.message ); + } ); +} === modified file 'dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/javascripts/validationRules.js' --- dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/javascripts/validationRules.js 2012-08-22 07:08:08 +0000 +++ dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/javascripts/validationRules.js 2012-10-06 08:45:50 +0000 @@ -38,6 +38,15 @@ "required" : true } }, + "profile" : { + "email" : { + "email" : true, + "rangelength" : [ 0, 160 ] + }, + "phoneNumber" : { + "rangelength" : [ 0, 80 ] + } + }, "role" : { "name" : { "required" : true, === modified file 'dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/useraccount/updateUserAccountForm.vm' --- dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/useraccount/updateUserAccountForm.vm 2012-10-05 08:36:10 +0000 +++ dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/useraccount/updateUserAccountForm.vm 2012-10-06 08:45:50 +0000 @@ -1,6 +1,8 @@ -

$i18n.getString( "update_user" )

+

$i18n.getString( "update_user" ) +$i18n.getString( 'edit_profile' ) +

@@ -13,18 +15,18 @@ - - - - - - - - - + + + + + + + + + - + @@ -37,15 +39,15 @@ - + - + - + === added file 'dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/useraccount/updateUserProfileForm.vm' --- dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/useraccount/updateUserProfileForm.vm 1970-01-01 00:00:00 +0000 +++ dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/useraccount/updateUserProfileForm.vm 2012-10-06 08:45:50 +0000 @@ -0,0 +1,69 @@ + + +

$encoder.htmlEncode( $userCredentials.user.getName() )

+ + +
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
$i18n.getString( "profile_details" )
+
+ \ No newline at end of file === added file 'dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/icons/profile_edit.png' Binary files dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/icons/profile_edit.png 1970-01-01 00:00:00 +0000 and dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/icons/profile_edit.png 2012-10-06 08:45:50 +0000 differ === added file 'dhis-2/dhis-web/dhis-web-commons/src/main/java/org/hisp/dhis/useraccount/action/UpdateUserProfileAction.java' --- dhis-2/dhis-web/dhis-web-commons/src/main/java/org/hisp/dhis/useraccount/action/UpdateUserProfileAction.java 1970-01-01 00:00:00 +0000 +++ dhis-2/dhis-web/dhis-web-commons/src/main/java/org/hisp/dhis/useraccount/action/UpdateUserProfileAction.java 2012-10-06 08:45:50 +0000 @@ -0,0 +1,223 @@ +package org.hisp.dhis.useraccount.action; + +/* + * Copyright (c) 2004-2012, 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. + */ + +import static org.hisp.dhis.system.util.TextUtils.nullIfEmpty; + +import org.hisp.dhis.i18n.I18n; +import org.hisp.dhis.i18n.I18nFormat; +import org.hisp.dhis.user.User; +import org.hisp.dhis.user.UserService; +import org.springframework.beans.factory.annotation.Autowired; + +import com.opensymphony.xwork2.Action; + +/** + * @author Dang Duy Hieu + * @version $Id$ + */ +public class UpdateUserProfileAction + implements Action +{ + // ------------------------------------------------------------------------- + // Dependencies + // ------------------------------------------------------------------------- + + @Autowired + private UserService userService; + + // ------------------------------------------------------------------------- + // I18n + // ------------------------------------------------------------------------- + + private I18n i18n; + + private I18nFormat format; + + // ------------------------------------------------------------------------- + // Input + // ------------------------------------------------------------------------- + + private Integer id; + + private String email; + + private String phoneNumber; + + private String introduction; + + private String gender; + + private String birthday; + + private String nationality; + + private String employer; + + private String education; + + private String interests; + + private String languages; + + private String message; + + private String jobTitle; + + // ------------------------------------------------------------------------- + // Getters && Setters + // ------------------------------------------------------------------------- + + public void setI18n( I18n i18n ) + { + this.i18n = i18n; + } + + public void setFormat( I18nFormat format ) + { + this.format = format; + } + + public void setId( Integer id ) + { + this.id = id; + } + + public void setPhoneNumber( String phoneNumber ) + { + this.phoneNumber = phoneNumber; + } + + public void setEmail( String email ) + { + this.email = email; + } + + public void setIntroduction( String introduction ) + { + this.introduction = introduction; + } + + public void setJobTitle( String jobTitle ) + { + this.jobTitle = jobTitle; + } + + public void setGender( String gender ) + { + this.gender = gender; + } + + public void setBirthday( String birthday ) + { + this.birthday = birthday; + } + + public void setNationality( String nationality ) + { + this.nationality = nationality; + } + + public void setEmployer( String employer ) + { + this.employer = employer; + } + + public void setEducation( String education ) + { + this.education = education; + } + + public void setInterests( String interests ) + { + this.interests = interests; + } + + public void setLanguages( String languages ) + { + this.languages = languages; + } + + public String getMessage() + { + return message; + } + + // ------------------------------------------------------------------------- + // Action implementation + // ------------------------------------------------------------------------- + + public String execute() + throws Exception + { + // --------------------------------------------------------------------- + // Prepare values + // --------------------------------------------------------------------- + + email = nullIfEmpty( email ); + phoneNumber = nullIfEmpty( phoneNumber ); + introduction = nullIfEmpty( introduction ); + jobTitle = nullIfEmpty( jobTitle ); + nationality = nullIfEmpty( nationality ); + employer = nullIfEmpty( employer ); + education = nullIfEmpty( education ); + interests = nullIfEmpty( interests ); + languages = nullIfEmpty( languages ); + + User user = userService.getUser( id ); + + if ( user == null ) + { + message = i18n.getString( "user_is_not_available" ); + + return ERROR; + } + + // --------------------------------------------------------------------- + // Update User + // --------------------------------------------------------------------- + + user.setEmail( email ); + user.setPhoneNumber( phoneNumber ); + user.setIntroduction( introduction ); + user.setJobTitle( jobTitle ); + user.setGender( gender ); + user.setBirthday( format.parseDate( birthday ) ); + user.setNationality( nationality ); + user.setEmployer( employer ); + user.setEducation( education ); + user.setInterests( interests ); + user.setLanguages( languages ); + + userService.updateUser( user ); + + message = i18n.getString( "update_user_profile_success" ); + + return SUCCESS; + } +} === modified file 'dhis-2/dhis-web/dhis-web-commons/src/main/resources/META-INF/dhis/beans.xml' --- dhis-2/dhis-web/dhis-web-commons/src/main/resources/META-INF/dhis/beans.xml 2012-10-05 11:57:54 +0000 +++ dhis-2/dhis-web/dhis-web-commons/src/main/resources/META-INF/dhis/beans.xml 2012-10-06 08:45:50 +0000 @@ -584,6 +584,9 @@ + + === modified file 'dhis-2/dhis-web/dhis-web-commons/src/main/resources/dhis-web-commons.xml' --- dhis-2/dhis-web/dhis-web-commons/src/main/resources/dhis-web-commons.xml 2012-09-19 11:41:19 +0000 +++ dhis-2/dhis-web/dhis-web-commons/src/main/resources/dhis-web-commons.xml 2012-10-06 08:45:50 +0000 @@ -858,6 +858,11 @@ /dhis-web-commons/useraccount/updateUserAccountForm.vm + + /main.vm + /dhis-web-commons/useraccount/updateUserProfileForm.vm + + /dhis-web-commons/useraccount/updateUserSuccess.vm @@ -867,6 +872,15 @@ + + + /dhis-web-commons/ajax/jsonResponseSuccess.vm + + + /dhis-web-commons/ajax/jsonResponseError.vm + + + /main.vm /dhis-web-commons/about/modules.vm === modified file 'dhis-2/dhis-web/dhis-web-commons/src/main/resources/i18n_global.properties' --- dhis-2/dhis-web/dhis-web-commons/src/main/resources/i18n_global.properties 2012-10-05 08:36:10 +0000 +++ dhis-2/dhis-web/dhis-web-commons/src/main/resources/i18n_global.properties 2012-10-06 08:45:50 +0000 @@ -296,6 +296,21 @@ system_overview=System Overview server_date=Server date online_release_page=online release page +edit_profile=Edit profile +profile_details=Profile details +job_title=Job title +introduction=Introduction +gender=Gender +male=Male +female=Female +other=Other +birthday=Birthday +nationality=Nationality +employer=Employer +education=Education +interests=Interests +languages=Languages +update_user_profile_success=Update user profile successfully #-- Change Log------------------------------------------------------------------# === modified file 'dhis-2/dhis-web/dhis-web-commons/src/main/resources/i18n_global_vi_VN.properties' --- dhis-2/dhis-web/dhis-web-commons/src/main/resources/i18n_global_vi_VN.properties 2012-09-19 15:26:57 +0000 +++ dhis-2/dhis-web/dhis-web-commons/src/main/resources/i18n_global_vi_VN.properties 2012-10-06 08:45:50 +0000 @@ -410,3 +410,18 @@ help_center=Trung t\u00e2m h\u1ed7 tr\u1ee3 clear=X\u00f3a Monthly=H\u00e0ng th\u00e1ng +edit_profile=Ch\u1ec9nh s\u1eeda Profile +profile_details=Chi ti\u1ebft Profile +job_title=Ngh\u1ec1 nghi\u1ec7p +introduction=Gi\u1edbi thi\u1ec7u b\u1ea3n th\u00e2n +gender=Gi\u1edbi t\u00ednh +male=Nam +female=N\u1eef +other=Kh\u00e1c +birthday=Ng\u00e0y sinh +nationality=Qu\u1ed1c t\u1ecbch +employer=C\u00f4ng ty +education=Tr\u00ecnh \u0111\u1ed9 +interests=S\u1edf th\u00edch +languages=Ng\u00f4n ng\u1eef +update_user_profile_success=C\u1eadp nh\u1eadt profile cho ng\u01b0\u1eddi d\u00f9ng th\u00e0nh c\u00f4ng \ No newline at end of file === modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-user/src/main/resources/org/hisp/dhis/user/i18n_module.properties' --- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-user/src/main/resources/org/hisp/dhis/user/i18n_module.properties 2012-09-26 08:42:25 +0000 +++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-user/src/main/resources/org/hisp/dhis/user/i18n_module.properties 2012-10-06 08:45:50 +0000 @@ -263,5 +263,4 @@ month=month months=months select=Select -object_not_deleted_associated_by_objects=Object not deleted because it is associated by objects of type -job_title=Job title \ No newline at end of file +object_not_deleted_associated_by_objects=Object not deleted because it is associated by objects of type \ No newline at end of file