dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #12636
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 3936: Added function for viewing message sender information
Merge authors:
Lars Helge Øverland (larshelge)
------------------------------------------------------------
revno: 3936 [merge]
committer: Lars Helge Overland <larshelge@xxxxxxxxx>
branch nick: dhis2
timestamp: Fri 2011-06-17 15:23:38 +0200
message:
Added function for viewing message sender information
added:
dhis-2/dhis-api/src/main/java/org/hisp/dhis/common/IdentifiableObjectUtils.java
dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/ajax/jsonUser.vm
dhis-2/dhis-web/dhis-web-commons/src/main/java/org/hisp/dhis/commons/action/GetUserAction.java
dhis-2/dhis-web/dhis-web-dashboard-integration/src/main/webapp/dhis-web-dashboard-integration/getUserInfo.vm
dhis-2/dhis-web/dhis-web-dashboard-integration/src/main/webapp/dhis-web-dashboard-integration/javascript/readMessage.js
modified:
dhis-2/dhis-api/src/main/java/org/hisp/dhis/user/User.java
dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/css/light_blue/light_blue.css
dhis-2/dhis-web/dhis-web-commons/src/main/java/org/hisp/dhis/commons/action/GetDataElementGroupSetAction.java
dhis-2/dhis-web/dhis-web-commons/src/main/java/org/hisp/dhis/commons/action/GetUsersAction.java
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/dhis-web-commons.xml
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/mainForm.vm
dhis-2/dhis-web/dhis-web-dashboard-integration/src/main/webapp/dhis-web-dashboard-integration/readMessage.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-api/src/main/java/org/hisp/dhis/common/IdentifiableObjectUtils.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/common/IdentifiableObjectUtils.java 1970-01-01 00:00:00 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/common/IdentifiableObjectUtils.java 2011-06-17 13:22:05 +0000
@@ -0,0 +1,66 @@
+package org.hisp.dhis.common;
+
+/*
+ * Copyright (c) 2004-2010, 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 java.util.Collection;
+import java.util.Iterator;
+
+/**
+ * @author Lars Helge Overland
+ */
+public class IdentifiableObjectUtils
+{
+ private static final String SEPARATOR_JOIN = ", ";
+
+ /**
+ * Joins the names of the IdentifiableObjects in the given list and separates
+ * them with a comma and space. Returns null if the given list is null or has
+ * no elements.
+ *
+ * @param objects the list of IdentifiableObjects.
+ * @return the joined string.
+ */
+ public static String join( Collection<? extends IdentifiableObject> objects )
+ {
+ if ( objects != null && objects.size() > 0 )
+ {
+ Iterator<? extends IdentifiableObject> iterator = objects.iterator();
+
+ StringBuilder builder = new StringBuilder( iterator.next().getName() );
+
+ while ( iterator.hasNext() )
+ {
+ builder.append( SEPARATOR_JOIN ).append( iterator.next().getName() );
+ }
+
+ return builder.toString();
+ }
+
+ return null;
+ }
+}
=== 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 2011-06-11 08:15:29 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/user/User.java 2011-06-17 11:38:43 +0000
@@ -33,6 +33,7 @@
import java.util.Set;
import org.apache.commons.collections.CollectionUtils;
+import org.hisp.dhis.common.IdentifiableObjectUtils;
import org.hisp.dhis.organisationunit.OrganisationUnit;
/**
@@ -175,6 +176,11 @@
return !CollectionUtils.isEmpty( organisationUnits );
}
+ public String getOrganisationUnitsName()
+ {
+ return IdentifiableObjectUtils.join( organisationUnits );
+ }
+
// -------------------------------------------------------------------------
// Getters and setters
// -------------------------------------------------------------------------
=== added file 'dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/ajax/jsonUser.vm'
--- dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/ajax/jsonUser.vm 1970-01-01 00:00:00 +0000
+++ dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/ajax/jsonUser.vm 2011-06-17 13:22:05 +0000
@@ -0,0 +1,10 @@
+{ "user":
+ {
+ "id": ${user.id},
+ "surname": "$!encoder.jsonEncode( ${user.surname} )",
+ "firstName": "$!encoder.jsonEncode( ${user.firstName} )",
+ "email": "$!encoder.jsonEncode( ${user.email} )",
+ "phoneNumber": "$!encoder.jsonEncode( ${user.phoneNumber} )",
+ "organisationUnits": "$!encoder.jsonEncode( ${user.organisationUnitsName} )"
+ }
+}
\ No newline at end of file
=== modified file 'dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/css/light_blue/light_blue.css'
--- dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/css/light_blue/light_blue.css 2011-06-16 08:08:02 +0000
+++ dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/css/light_blue/light_blue.css 2011-06-17 10:58:25 +0000
@@ -6,7 +6,7 @@
*
{
font-family: LiberationSansRegular, arial;
- line-height: 135%;
+ line-height: 140%;
}
html,body
=== modified file 'dhis-2/dhis-web/dhis-web-commons/src/main/java/org/hisp/dhis/commons/action/GetDataElementGroupSetAction.java'
--- dhis-2/dhis-web/dhis-web-commons/src/main/java/org/hisp/dhis/commons/action/GetDataElementGroupSetAction.java 2011-05-28 21:04:47 +0000
+++ dhis-2/dhis-web/dhis-web-commons/src/main/java/org/hisp/dhis/commons/action/GetDataElementGroupSetAction.java 2011-06-17 11:38:43 +0000
@@ -67,8 +67,11 @@
return dataElementGroupSet;
}
+ // -------------------------------------------------------------------------
+ // Action implementation
+ // -------------------------------------------------------------------------
+
public String execute()
- throws Exception
{
if ( id != null )
{
=== added 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 1970-01-01 00:00:00 +0000
+++ dhis-2/dhis-web/dhis-web-commons/src/main/java/org/hisp/dhis/commons/action/GetUserAction.java 2011-06-17 13:22:05 +0000
@@ -0,0 +1,84 @@
+package org.hisp.dhis.commons.action;
+
+/*
+ * Copyright (c) 2004-2010, 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 com.opensymphony.xwork2.Action;
+
+/**
+ * @author Lars Helge Overland
+ */
+public class GetUserAction
+ implements Action
+{
+ // -------------------------------------------------------------------------
+ // Dependencies
+ // -------------------------------------------------------------------------
+
+ private UserService userService;
+
+ public void setUserService( UserService userService )
+ {
+ this.userService = userService;
+ }
+
+ // -------------------------------------------------------------------------
+ // Input
+ // -------------------------------------------------------------------------
+
+ private Integer id;
+
+ public void setId( Integer id )
+ {
+ this.id = id;
+ }
+
+ // -------------------------------------------------------------------------
+ // Output
+ // -------------------------------------------------------------------------
+
+ private User user;
+
+ public User getUser()
+ {
+ return user;
+ }
+
+ // -------------------------------------------------------------------------
+ // Action implementation
+ // -------------------------------------------------------------------------
+
+ public String execute()
+ {
+ user = userService.getUser( id );
+
+ return SUCCESS;
+ }
+}
=== modified file 'dhis-2/dhis-web/dhis-web-commons/src/main/java/org/hisp/dhis/commons/action/GetUsersAction.java'
--- dhis-2/dhis-web/dhis-web-commons/src/main/java/org/hisp/dhis/commons/action/GetUsersAction.java 2011-05-28 21:04:47 +0000
+++ dhis-2/dhis-web/dhis-web-commons/src/main/java/org/hisp/dhis/commons/action/GetUsersAction.java 2011-06-17 10:58:25 +0000
@@ -37,7 +37,7 @@
import org.hisp.dhis.user.UserService;
import org.hisp.dhis.user.comparator.UserComparator;
-/*
+/**
* @author mortenoh
*/
public class GetUsersAction
=== 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 2011-06-16 08:08:02 +0000
+++ dhis-2/dhis-web/dhis-web-commons/src/main/resources/META-INF/dhis/beans.xml 2011-06-17 11:38:43 +0000
@@ -258,10 +258,10 @@
</property>
</bean>
- <!-- Security import -->
+ <!-- Security import -->
<import resource="security.xml" />
- <!-- i18n -->
+ <!-- i18n -->
<bean id="org.hisp.dhis.i18n.action.I18nAction" class="org.hisp.dhis.i18n.action.I18nAction" scope="prototype">
<property name="i18nService">
@@ -296,7 +296,7 @@
</property>
</bean>
- <!-- About -->
+ <!-- About -->
<bean id="org.hisp.dhis.about.action.AboutAction" class="org.hisp.dhis.about.action.AboutAction" scope="prototype">
<property name="locationManager" ref="locationManager" />
@@ -320,7 +320,13 @@
<!-- Common actions -->
- <bean id="org.hisp.dhis.commons.action.GetUsersAction" class="org.hisp.dhis.commons.action.GetUsersAction" scope="prototype">
+ <bean id="org.hisp.dhis.commons.action.GetUserAction" class="org.hisp.dhis.commons.action.GetUserAction"
+ scope="prototype">
+ <property name="userService" ref="org.hisp.dhis.user.UserService" />
+ </bean>
+
+ <bean id="org.hisp.dhis.commons.action.GetUsersAction" class="org.hisp.dhis.commons.action.GetUsersAction"
+ scope="prototype">
<property name="userService" ref="org.hisp.dhis.user.UserService" />
</bean>
=== 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 2011-06-16 08:08:02 +0000
+++ dhis-2/dhis-web/dhis-web-commons/src/main/resources/dhis-web-commons.xml 2011-06-17 11:38:43 +0000
@@ -397,24 +397,27 @@
<package name="dhis-web-commons-ajax-json" extends="dhis-web-commons" namespace="/dhis-web-commons-ajax-json">
+ <action name="getUser" class="org.hisp.dhis.commons.action.GetUserAction">
+ <result name="success" type="velocity-json">
+ /dhis-web-commons/ajax/jsonUser.vm</result>
+ <param name="onExceptionReturn">plainTextError</param>
+ </action>
+
<action name="getUsers" class="org.hisp.dhis.commons.action.GetUsersAction">
<result name="success" type="velocity-json">
- /dhis-web-commons/ajax/jsonUsers.vm
- </result>
+ /dhis-web-commons/ajax/jsonUsers.vm</result>
<param name="onExceptionReturn">plainTextError</param>
</action>
<action name="getUserGroups" class="org.hisp.dhis.commons.action.GetUserGroupsAction">
<result name="success" type="velocity-json">
- /dhis-web-commons/ajax/jsonUserGroups.vm
- </result>
+ /dhis-web-commons/ajax/jsonUserGroups.vm</result>
<param name="onExceptionReturn">plainTextError</param>
</action>
<action name="getValidationRules" class="org.hisp.dhis.commons.action.GetValidationRulesAction">
<result name="success" type="velocity-json">
- /dhis-web-commons/ajax/jsonValidationRules.vm
- </result>
+ /dhis-web-commons/ajax/jsonValidationRules.vm</result>
<param name="onExceptionReturn">plainTextError</param>
</action>
=== 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 2011-06-09 14:46:45 +0000
+++ dhis-2/dhis-web/dhis-web-dashboard-integration/src/main/resources/struts.xml 2011-06-17 13:22:05 +0000
@@ -91,7 +91,7 @@
<result name="success" type="velocity">/main.vm</result>
<param name="page">/dhis-web-dashboard-integration/readMessage.vm</param>
<param name="menu">/dhis-web-dashboard-integration/menu.vm</param>
- <param name="javascripts">javascript/message.js</param>
+ <param name="javascripts">javascript/readMessage.js</param>
<param name="stylesheets">style/dashboard.css</param>
</action>
@@ -105,9 +105,14 @@
<param name="onExceptionReturn">plainTextError</param>
</action>
- <action name="removeMessageRedirect" class="org.hisp.dhis.dashboard.message.action.RemoveMessageAction">
+ <action name="removeMessageRedirect" class="org.hisp.dhis.dashboard.message.action.RemoveMessageAction">
<result name="success" type="redirect">message.action</result>
</action>
+ <action name="getUserInfo" class="org.hisp.dhis.commons.action.GetUserAction">
+ <result name="success" type="velocity">/dhis-web-dashboard-integration/getUserInfo.vm</result>
+ <param name="onExceptionReturn">plainTextError</param>
+ </action>
+
</package>
</struts>
=== added file 'dhis-2/dhis-web/dhis-web-dashboard-integration/src/main/webapp/dhis-web-dashboard-integration/getUserInfo.vm'
--- dhis-2/dhis-web/dhis-web-dashboard-integration/src/main/webapp/dhis-web-dashboard-integration/getUserInfo.vm 1970-01-01 00:00:00 +0000
+++ dhis-2/dhis-web/dhis-web-dashboard-integration/src/main/webapp/dhis-web-dashboard-integration/getUserInfo.vm 2011-06-17 13:22:05 +0000
@@ -0,0 +1,15 @@
+<h3>$user.name</h3>
+<table>
+<tr>
+<td><label>$i18n.getString( "email" ):</label></td>
+<td>$!encoder.htmlEncode( ${user.email} )</td>
+</tr>
+<tr>
+<td><label>$i18n.getString( "phone_number" ):</label></td>
+<td>$!encoder.htmlEncode( ${user.phoneNumber} )</td>
+</tr>
+<tr>
+<td><label>$i18n.getString( "organisation_units" ):</label></td>
+<td>$!encoder.htmlEncode( ${user.organisationUnitsName} )</td>
+</tr>
+</table>
\ No newline at end of file
=== 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 2011-04-11 15:07:08 +0000
+++ dhis-2/dhis-web/dhis-web-dashboard-integration/src/main/webapp/dhis-web-dashboard-integration/javascript/message.js 2011-06-17 13:22:05 +0000
@@ -7,4 +7,4 @@
function read( id )
{
window.location.href = "readMessage.action?id=" + id;
-}
\ No newline at end of file
+}
=== added file 'dhis-2/dhis-web/dhis-web-dashboard-integration/src/main/webapp/dhis-web-dashboard-integration/javascript/readMessage.js'
--- dhis-2/dhis-web/dhis-web-dashboard-integration/src/main/webapp/dhis-web-dashboard-integration/javascript/readMessage.js 1970-01-01 00:00:00 +0000
+++ dhis-2/dhis-web/dhis-web-dashboard-integration/src/main/webapp/dhis-web-dashboard-integration/javascript/readMessage.js 2011-06-17 13:22:05 +0000
@@ -0,0 +1,19 @@
+
+var dialog = null;
+
+$( document ).ready( function() {
+
+ dialog = $( "#senderInfo" ).dialog( {
+ modal: true,
+ autoOpen: false,
+ width: 300,
+ height: 250,
+ title: "Sender" } );
+} );
+
+function showSenderInfo( id )
+{
+ $( "#senderInfo" ).load( "getUserInfo.action", { id:id }, function() {
+ dialog.dialog( "open" );
+ } );
+}
=== modified file 'dhis-2/dhis-web/dhis-web-dashboard-integration/src/main/webapp/dhis-web-dashboard-integration/mainForm.vm'
--- dhis-2/dhis-web/dhis-web-dashboard-integration/src/main/webapp/dhis-web-dashboard-integration/mainForm.vm 2011-06-14 19:13:54 +0000
+++ dhis-2/dhis-web/dhis-web-dashboard-integration/src/main/webapp/dhis-web-dashboard-integration/mainForm.vm 2011-06-17 10:58:25 +0000
@@ -43,7 +43,7 @@
<h3>$i18n.getString( "dashboard" )
• <a href="showSendFeedback.action">$i18n.getString( "write_feedback" )</a>
-#if( $messageCount > 0 )• <a href="message.action">$messageCount #if( $messageCount > 1 )$i18n.getString( "unread_messages" )#else$i18n.getString( "unread_message" )#end!</a> #end</h3>
+#if( $messageCount > 0 )• <a href="message.action">$messageCount #if( $messageCount > 1 )$i18n.getString( "unread_messages" )#else$i18n.getString( "unread_message" )#end</a> #end</h3>
<table cellspacing="0" cellpadding="0" style="width:960px">
<tr>
=== modified file 'dhis-2/dhis-web/dhis-web-dashboard-integration/src/main/webapp/dhis-web-dashboard-integration/readMessage.vm'
--- dhis-2/dhis-web/dhis-web-dashboard-integration/src/main/webapp/dhis-web-dashboard-integration/readMessage.vm 2011-06-12 10:33:24 +0000
+++ dhis-2/dhis-web/dhis-web-dashboard-integration/src/main/webapp/dhis-web-dashboard-integration/readMessage.vm 2011-06-17 13:22:05 +0000
@@ -1,7 +1,7 @@
<h3>$encoder.htmlEncode( $message.message.subject )</h3>
-<div class="messageDiv"><span class="bold">$encoder.htmlEncode( $message.message.sender.name )</span>
+<div class="messageDiv"><span class="bold" style="cursor:pointer" onclick="showSenderInfo( ${message.message.sender.id} )">$encoder.htmlEncode( $message.message.sender.name )</span>
<span style="color:#606060">$format.formatDate( $message.messageDate )</span></div>
<div style="margin-bottom:20px; width:50%;">$encoder.htmlEncode( $message.message.text )</div>
@@ -10,4 +10,6 @@
<input type="button" value="$i18n.getString( 'mark_unread' )" onclick="window.location.href='unreadMessage.action?id=${message.id}'" style="width:120px">
<input type="button" value="$i18n.getString( 'remove' )" onclick="window.location.href='removeMessageRedirect.action?id=${message.id}'" style="width:120px">
<input type="button" value="$i18n.getString( 'back' )" onclick="window.location.href='message.action'" style="width:120px">
-</div>
\ No newline at end of file
+</div>
+
+<div id="senderInfo"></div>