=== added file 'dhis-2/dhis-web/dhis-web-dashboard-integration/src/main/java/org/hisp/dhis/dashboard/message/action/GetMessageOptionsAction.java' --- dhis-2/dhis-web/dhis-web-dashboard-integration/src/main/java/org/hisp/dhis/dashboard/message/action/GetMessageOptionsAction.java 1970-01-01 00:00:00 +0000 +++ dhis-2/dhis-web/dhis-web-dashboard-integration/src/main/java/org/hisp/dhis/dashboard/message/action/GetMessageOptionsAction.java 2012-10-11 19:54:10 +0000 @@ -0,0 +1,80 @@ +package org.hisp.dhis.dashboard.message.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 org.hisp.dhis.user.User; +import org.hisp.dhis.user.UserService; +import org.springframework.beans.factory.annotation.Autowired; + +import com.opensymphony.xwork2.Action; + +/** + * @author Lars Helge Overland + */ +public class GetMessageOptionsAction + implements Action +{ + @Autowired + private UserService userService; + + // ------------------------------------------------------------------------- + // Input + // ------------------------------------------------------------------------- + + private String id; + + public void setId( String id ) + { + this.id = id; + } + + // ------------------------------------------------------------------------- + // Output + // ------------------------------------------------------------------------- + + private User recipient; + + public User getRecipient() + { + return recipient; + } + + // ------------------------------------------------------------------------- + // Action implementation + // ------------------------------------------------------------------------- + + public String execute() + { + if ( id != null ) + { + recipient = userService.getUser( id ); + } + + return SUCCESS; + } +} === modified file 'dhis-2/dhis-web/dhis-web-dashboard-integration/src/main/java/org/hisp/dhis/dashboard/message/action/SendMessageAction.java' --- dhis-2/dhis-web/dhis-web-dashboard-integration/src/main/java/org/hisp/dhis/dashboard/message/action/SendMessageAction.java 2012-10-03 14:29:10 +0000 +++ dhis-2/dhis-web/dhis-web-dashboard-integration/src/main/java/org/hisp/dhis/dashboard/message/action/SendMessageAction.java 2012-10-11 19:54:10 +0000 @@ -27,7 +27,9 @@ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -import com.opensymphony.xwork2.Action; +import java.util.HashSet; +import java.util.Set; + import org.apache.struts2.ServletActionContext; import org.hisp.dhis.message.MessageService; import org.hisp.dhis.organisationunit.OrganisationUnit; @@ -39,8 +41,7 @@ import org.hisp.dhis.util.ContextUtils; import org.springframework.beans.factory.annotation.Autowired; -import java.util.HashSet; -import java.util.Set; +import com.opensymphony.xwork2.Action; /** * @author Lars Helge Overland @@ -55,20 +56,12 @@ // Dependencies // ------------------------------------------------------------------------- + @Autowired private MessageService messageService; - public void setMessageService( MessageService messageService ) - { - this.messageService = messageService; - } - + @Autowired private SelectionTreeManager selectionTreeManager; - public void setSelectionTreeManager( SelectionTreeManager selectionTreeManager ) - { - this.selectionTreeManager = selectionTreeManager; - } - @Autowired private UserService userService; @@ -79,11 +72,11 @@ // Input // ------------------------------------------------------------------------- - private String additionalUsers; + private String recipients; - public void setAdditionalUsers( String additionalUsers ) + public void setRecipients( String recipients ) { - this.additionalUsers = additionalUsers; + this.recipients = recipients; } private String subject; @@ -116,9 +109,9 @@ users.addAll( unit.getUsers() ); } - String[] recipients = additionalUsers.split( "," ); + String[] recipientsArray = recipients.split( "," ); - for ( String recipient : recipients ) + for ( String recipient : recipientsArray ) { if ( recipient.startsWith( PREFIX_USER ) ) { @@ -139,7 +132,7 @@ } } } - + messageService.sendMessage( subject, text, metaData, users ); return SUCCESS; === modified file 'dhis-2/dhis-web/dhis-web-dashboard-integration/src/main/resources/META-INF/dhis/beans.xml' --- dhis-2/dhis-web/dhis-web-dashboard-integration/src/main/resources/META-INF/dhis/beans.xml 2012-10-06 12:30:22 +0000 +++ dhis-2/dhis-web/dhis-web-dashboard-integration/src/main/resources/META-INF/dhis/beans.xml 2012-10-11 19:54:10 +0000 @@ -56,8 +56,7 @@ - + scope="prototype"/> @@ -66,10 +65,11 @@ + + - - - + scope="prototype"/> === modified file 'dhis-2/dhis-web/dhis-web-dashboard-integration/src/main/resources/org/hisp/dhis/dashboard/i18n_module.properties' --- dhis-2/dhis-web/dhis-web-dashboard-integration/src/main/resources/org/hisp/dhis/dashboard/i18n_module.properties 2012-10-10 13:23:23 +0000 +++ dhis-2/dhis-web/dhis-web-dashboard-integration/src/main/resources/org/hisp/dhis/dashboard/i18n_module.properties 2012-10-11 19:54:10 +0000 @@ -81,4 +81,6 @@ edit_profile=Edit profile inbox=Inbox follow_up=Follow up -unread=Unread \ No newline at end of file +unread=Unread +send_message=Send message +to=to \ No newline at end of file === modified file 'dhis-2/dhis-web/dhis-web-dashboard-integration/src/main/resources/struts.xml' --- dhis-2/dhis-web/dhis-web-dashboard-integration/src/main/resources/struts.xml 2012-10-11 16:02:00 +0000 +++ dhis-2/dhis-web/dhis-web-dashboard-integration/src/main/resources/struts.xml 2012-10-11 19:54:10 +0000 @@ -77,7 +77,7 @@ plainTextError - + /main.vm /dhis-web-dashboard-integration/sendMessage.vm /dhis-web-commons/about/menuDashboard.vm === modified file 'dhis-2/dhis-web/dhis-web-dashboard-integration/src/main/webapp/dhis-web-dashboard-integration/javascript/message.js' --- dhis-2/dhis-web/dhis-web-dashboard-integration/src/main/webapp/dhis-web-dashboard-integration/javascript/message.js 2012-10-03 15:43:35 +0000 +++ dhis-2/dhis-web/dhis-web-dashboard-integration/src/main/webapp/dhis-web-dashboard-integration/javascript/message.js 2012-10-11 19:54:10 +0000 @@ -21,7 +21,7 @@ var subject = $( "#subject" ).val(); var text = $( "#text" ).val(); - if( $('#selectionTree').find('.selected').length == 0 && $('#additionalUsers').val().length == 0 ) + if( $( "#selectionTree" ).find( ".selected" ).length == 0 && $( "#recipients" ).val().length == 0 ) { setHeaderMessage( i18n_select_one_or_more_recipients ); return false; === modified file 'dhis-2/dhis-web/dhis-web-dashboard-integration/src/main/webapp/dhis-web-dashboard-integration/jsonMessageRecipients.vm' --- dhis-2/dhis-web/dhis-web-dashboard-integration/src/main/webapp/dhis-web-dashboard-integration/jsonMessageRecipients.vm 2012-09-24 06:28:31 +0000 +++ dhis-2/dhis-web/dhis-web-dashboard-integration/src/main/webapp/dhis-web-dashboard-integration/jsonMessageRecipients.vm 2012-10-11 19:54:10 +0000 @@ -3,14 +3,14 @@ { "matches": [ #foreach( $user in $users ) { - "id": "u:${user.id}", + "id": "u:${user.uid}", "text": "$!encoder.jsonEncode( ${user.firstName} ) $!encoder.jsonEncode( ${user.surname} )" }#if( $velocityCount < ( $userSize )),#end #end #if($userSize > 0 && $userGroupSize > 0 ),#end #foreach( $userGroup in $userGroups ) { - "id": "ug:${userGroup.id}", + "id": "ug:${userGroup.uid}", "text": "$!encoder.jsonEncode( ${userGroup.name} )" }#if( $velocityCount < ( $userGroupSize ) ),#end #end === modified file 'dhis-2/dhis-web/dhis-web-dashboard-integration/src/main/webapp/dhis-web-dashboard-integration/profile.vm' --- dhis-2/dhis-web/dhis-web-dashboard-integration/src/main/webapp/dhis-web-dashboard-integration/profile.vm 2012-10-11 17:21:32 +0000 +++ dhis-2/dhis-web/dhis-web-dashboard-integration/src/main/webapp/dhis-web-dashboard-integration/profile.vm 2012-10-11 19:54:10 +0000 @@ -6,7 +6,11 @@
$!encoder.htmlEncode( $user.firstName ) $!encoder.htmlEncode( $user.surname )
+#if( $user.id == $currentUser.id ) +#else + +#end
=== modified file 'dhis-2/dhis-web/dhis-web-dashboard-integration/src/main/webapp/dhis-web-dashboard-integration/sendMessage.vm' --- dhis-2/dhis-web/dhis-web-dashboard-integration/src/main/webapp/dhis-web-dashboard-integration/sendMessage.vm 2012-10-08 12:47:00 +0000 +++ dhis-2/dhis-web/dhis-web-dashboard-integration/src/main/webapp/dhis-web-dashboard-integration/sendMessage.vm 2012-10-11 19:54:10 +0000 @@ -5,7 +5,8 @@ var i18n_select_users_and_user_groups = '$encoder.jsEscape( $i18n.getString( "select_users_and_user_groups" ), "'")'; jQuery(function() { - $('#additionalUsers').select2({ +#if( !${recipient} ) + $('#recipients').select2({ placeholder: i18n_select_users_and_user_groups, minimumInputLength: 2, multiple: true, @@ -25,23 +26,30 @@ formatResult: formatItem, formatSelection: formatItem }); +#else + $('#recipients').val('u:${recipient.uid}'); +#end }); -

$i18n.getString( "write_new_message" )

+

$i18n.getString( "write_new_message" )#if( ${recipient} ) $i18n.getString( "to" ) $encoder.htmlEncode( ${recipient.name} )#end

+#if( !${recipient} ) +#end + +
$i18n.getString( "recipients" ) #organisationUnitSelectionTree( true true false )
- +