dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #19462
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 8494: Impl function for sending message to user from the profile page of the user. Fixed bug with write...
------------------------------------------------------------
revno: 8494
committer: Lars Helge Øverland <larshelge@xxxxxxxxx>
branch nick: dhis2
timestamp: Thu 2012-10-11 21:54:10 +0200
message:
Impl function for sending message to user from the profile page of the user. Fixed bug with write message form.
added:
dhis-2/dhis-web/dhis-web-dashboard-integration/src/main/java/org/hisp/dhis/dashboard/message/action/GetMessageOptionsAction.java
modified:
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/resources/META-INF/dhis/beans.xml
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/struts.xml
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/jsonMessageRecipients.vm
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/sendMessage.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
=== 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 @@
</bean>
<bean id="org.hisp.dhis.dashboard.action.SearchAction" class="org.hisp.dhis.dashboard.action.SearchAction"
- scope="prototype">
- </bean>
+ scope="prototype"/>
<!-- Message -->
@@ -66,10 +65,11 @@
<property name="messageService" ref="org.hisp.dhis.message.MessageService" />
</bean>
+ <bean id="org.hisp.dhis.dashboard.message.action.GetMessageOptionsAction" class="org.hisp.dhis.dashboard.message.action.GetMessageOptionsAction"
+ scope="prototype"/>
+
<bean id="org.hisp.dhis.dashboard.message.action.SendMessageAction" class="org.hisp.dhis.dashboard.message.action.SendMessageAction"
scope="prototype">
- <property name="messageService" ref="org.hisp.dhis.message.MessageService" />
- <property name="selectionTreeManager" ref="org.hisp.dhis.oust.manager.SelectionTreeManager" />
</bean>
<bean id="org.hisp.dhis.dashboard.message.action.SendFeedbackAction" class="org.hisp.dhis.dashboard.message.action.SendFeedbackAction"
@@ -116,7 +116,6 @@
<!-- Profile -->
<bean id="org.hisp.dhis.dashboard.profile.action.GetUserAction" class="org.hisp.dhis.dashboard.profile.action.GetUserAction"
- scope="prototype">
- </bean>
+ scope="prototype"/>
</beans>
=== 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 @@
<param name="onExceptionReturn">plainTextError</param>
</action>
- <action name="showSendMessage" class="org.hisp.dhis.dashboard.action.NoAction">
+ <action name="showSendMessage" class="org.hisp.dhis.dashboard.message.action.GetMessageOptionsAction">
<result name="success" type="velocity">/main.vm</result>
<param name="page">/dhis-web-dashboard-integration/sendMessage.vm</param>
<param name="menu">/dhis-web-commons/about/menuDashboard.vm</param>
=== 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 @@
</style>
<div id="userHeader">$!encoder.htmlEncode( $user.firstName ) $!encoder.htmlEncode( $user.surname )</div>
+#if( $user.id == $currentUser.id )
<div id="userProfileLink"><a class="blueButtonLink" href="../dhis-web-commons-about/showUpdateUserProfileForm.action">$i18n.getString( "edit_profile" )</a></div>
+#else
+<div id="userProfileLink"><a class="blueButtonLink" href="showSendMessage.action?id=${user.uid}">$i18n.getString( "send_message" )</a></div>
+#end
<div id="userCover"><img src="images/profile_cover.jpg" style="border: none; border-bottom-right-radius: 5px;"></div>
=== 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
});
</script>
-<h3>$i18n.getString( "write_new_message" )</h3>
+<h3>$i18n.getString( "write_new_message" )#if( ${recipient} ) $i18n.getString( "to" ) $encoder.htmlEncode( ${recipient.name} )#end </h3>
<form action="sendMessage.action" method="post" onsubmit="return validateMessage()">
<table>
+#if( !${recipient} )
<tr>
<td style="width:80px" rowspan="2">$i18n.getString( "recipients" )</td>
<td>
#organisationUnitSelectionTree( true true false )
</td>
</tr>
+#end
+
+<tr>
<td>
-<input type="hidden" name="additionalUsers" id="additionalUsers" style="width:545px; padding:4px; border:1px solid grey;"/>
+<input type="hidden" name="recipients" id="recipients" style="width:545px; padding:4px; border:1px solid grey;"/>
</td>
</tr>