dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #16024
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 5961: Implemented followup (star) for messages
------------------------------------------------------------
revno: 5961
committer: Lars Helge Overland <larshelge@xxxxxxxxx>
branch nick: dhis2
timestamp: Tue 2012-02-14 21:27:19 +0100
message:
Implemented followup (star) for messages
added:
dhis-2/dhis-web/dhis-web-dashboard-integration/src/main/java/org/hisp/dhis/dashboard/message/action/ToggleFollowUpAction.java
modified:
dhis-2/dhis-api/src/main/java/org/hisp/dhis/message/MessageConversation.java
dhis-2/dhis-api/src/main/java/org/hisp/dhis/message/UserMessage.java
dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/message/hibernate/HibernateMessageConversationStore.java
dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/startup/TableAlteror.java
dhis-2/dhis-services/dhis-service-core/src/main/resources/org/hisp/dhis/message/hibernate/UserMessage.hbm.xml
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/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/message.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
=== modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/message/MessageConversation.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/message/MessageConversation.java 2012-01-13 18:59:01 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/message/MessageConversation.java 2012-02-14 20:27:19 +0000
@@ -55,6 +55,8 @@
private User lastSender;
private transient boolean read;
+
+ private transient boolean followUp;
private transient String lastSenderSurname;
@@ -91,6 +93,21 @@
this.messages.add( message );
}
+ public boolean toggleFollowUp( User user )
+ {
+ for ( UserMessage userMessage : userMessages )
+ {
+ if ( userMessage.getUser() != null && userMessage.getUser().equals( user ) )
+ {
+ userMessage.setFollowUp( !userMessage.isFollowUp() );
+
+ return userMessage.isFollowUp();
+ }
+ }
+
+ return false;
+ }
+
public boolean markRead( User user )
{
for ( UserMessage userMessage : userMessages )
@@ -182,10 +199,6 @@
this.subject = subject;
}
- /* @XmlElementWrapper( name = "userMessages" )
- @XmlElement( name = "userMessage" )
- @JsonProperty
- TODO waiting for idObject version of userMessage */
public Set<UserMessage> getUserMessages()
{
return userMessages;
@@ -223,8 +236,6 @@
this.lastSender = lastSender;
}
- @XmlElement
- @JsonProperty
public boolean isRead()
{
return read;
@@ -235,6 +246,16 @@
this.read = read;
}
+ public boolean isFollowUp()
+ {
+ return followUp;
+ }
+
+ public void setFollowUp( boolean followUp )
+ {
+ this.followUp = followUp;
+ }
+
public String getLastSenderName()
{
return lastSenderFirstname + " " + lastSenderSurname;
=== modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/message/UserMessage.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/message/UserMessage.java 2011-12-26 10:07:59 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/message/UserMessage.java 2012-02-14 20:27:19 +0000
@@ -55,6 +55,8 @@
private User user;
private boolean read;
+
+ private boolean followUp;
public UserMessage()
{
@@ -123,6 +125,18 @@
this.read = read;
}
+ @XmlElement
+ @JsonProperty
+ public boolean isFollowUp()
+ {
+ return followUp;
+ }
+
+ public void setFollowUp( boolean followUp )
+ {
+ this.followUp = followUp;
+ }
+
@Override
public int hashCode()
{
=== modified file 'dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/message/hibernate/HibernateMessageConversationStore.java'
--- dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/message/hibernate/HibernateMessageConversationStore.java 2012-02-14 19:19:27 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/message/hibernate/HibernateMessageConversationStore.java 2012-02-14 20:27:19 +0000
@@ -66,7 +66,10 @@
"select mc.messageconversationid, mc.uid, mc.subject, mc.lastupdated, ui.surname, ui.firstname, ( " +
"select isread from usermessage " +
"where usermessage.usermessageid=mu.usermessageid " +
- "and mu.messageconversationid=mc.messageconversationid ) as isread " +
+ "and mu.messageconversationid=mc.messageconversationid ) as isread, ( " +
+ "select isfollowup from usermessage " +
+ "where usermessage.usermessageid=mu.usermessageid " +
+ "and mu.messageconversationid=mc.messageconversationid ) as isfollowup " +
"from messageconversation mc " +
"left join messageconversation_usermessages mu on mc.messageconversationid=mu.messageconversationid " +
"left join usermessage um on mu.usermessageid=um.usermessageid " +
@@ -97,6 +100,7 @@
conversation.setLastSenderSurname( resultSet.getString( 5 ) );
conversation.setLastSenderFirstname( resultSet.getString( 6 ) );
conversation.setRead( resultSet.getBoolean( 7 ) );
+ conversation.setFollowUp( resultSet.getBoolean( 8 ) );
return conversation;
}
=== modified file 'dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/startup/TableAlteror.java'
--- dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/startup/TableAlteror.java 2012-02-12 19:57:05 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/startup/TableAlteror.java 2012-02-14 20:27:19 +0000
@@ -324,6 +324,7 @@
executeSql( "ALTER TABLE message DROP COLUMN messagekey" );
executeSql( "ALTER TABLE message DROP COLUMN sentdate" );
executeSql( "ALTER TABLE usermessage DROP COLUMN messagedate" );
+ executeSql( "UPDATE usermessage SET isfollowup=false WHERE isfollowup is null" );
executeSql( "DROP TABLE message_usermessages" );
// create code unique constraints
=== modified file 'dhis-2/dhis-services/dhis-service-core/src/main/resources/org/hisp/dhis/message/hibernate/UserMessage.hbm.xml'
--- dhis-2/dhis-services/dhis-service-core/src/main/resources/org/hisp/dhis/message/hibernate/UserMessage.hbm.xml 2011-08-04 07:52:24 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/resources/org/hisp/dhis/message/hibernate/UserMessage.hbm.xml 2012-02-14 20:27:19 +0000
@@ -19,5 +19,7 @@
<property name="read" column="isread" not-null="true" />
+ <property name="followUp" column="isfollowup" not-null="false" />
+
</class>
</hibernate-mapping>
=== added file 'dhis-2/dhis-web/dhis-web-dashboard-integration/src/main/java/org/hisp/dhis/dashboard/message/action/ToggleFollowUpAction.java'
--- dhis-2/dhis-web/dhis-web-dashboard-integration/src/main/java/org/hisp/dhis/dashboard/message/action/ToggleFollowUpAction.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/ToggleFollowUpAction.java 2012-02-14 20:27:19 +0000
@@ -0,0 +1,68 @@
+package org.hisp.dhis.dashboard.message.action;
+
+import org.hisp.dhis.message.MessageConversation;
+import org.hisp.dhis.message.MessageService;
+import org.hisp.dhis.user.CurrentUserService;
+
+import com.opensymphony.xwork2.Action;
+
+public class ToggleFollowUpAction
+implements Action
+{
+ // -------------------------------------------------------------------------
+ // Dependencies
+ // -------------------------------------------------------------------------
+
+ private MessageService messageService;
+
+ public void setMessageService( MessageService messageService )
+ {
+ this.messageService = messageService;
+ }
+
+ private CurrentUserService currentUserService;
+
+ public void setCurrentUserService( CurrentUserService currentUserService )
+ {
+ this.currentUserService = currentUserService;
+ }
+
+ // -------------------------------------------------------------------------
+ // Input
+ // -------------------------------------------------------------------------
+
+ private Integer id;
+
+ public void setId( Integer id )
+ {
+ this.id = id;
+ }
+
+ // -------------------------------------------------------------------------
+ // Output
+ // -------------------------------------------------------------------------
+
+ private String message;
+
+ public String getMessage()
+ {
+ return message;
+ }
+
+ // -------------------------------------------------------------------------
+ // Action implementation
+ // -------------------------------------------------------------------------
+
+ @Override
+ public String execute()
+ throws Exception
+ {
+ MessageConversation conversation = messageService.getMessageConversation( id );
+
+ message = String.valueOf( conversation.toggleFollowUp( currentUserService.getCurrentUser() ) );
+
+ messageService.updateMessageConversation( conversation );
+
+ 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-01-05 20:39:23 +0000
+++ dhis-2/dhis-web/dhis-web-dashboard-integration/src/main/resources/META-INF/dhis/beans.xml 2012-02-14 20:27:19 +0000
@@ -96,5 +96,11 @@
<property name="messageService" ref="org.hisp.dhis.message.MessageService" />
<property name="currentUserService" ref="org.hisp.dhis.user.CurrentUserService" />
</bean>
+
+ <bean id="org.hisp.dhis.dashboard.message.action.ToggleFollowUpAction" class="org.hisp.dhis.dashboard.message.action.ToggleFollowUpAction"
+ scope="prototype">
+ <property name="messageService" ref="org.hisp.dhis.message.MessageService" />
+ <property name="currentUserService" ref="org.hisp.dhis.user.CurrentUserService" />
+ </bean>
</beans>
=== 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-08-04 11:10:11 +0000
+++ dhis-2/dhis-web/dhis-web-dashboard-integration/src/main/resources/struts.xml 2012-02-14 20:27:19 +0000
@@ -113,6 +113,11 @@
<action name="removeMessageRedirect" class="org.hisp.dhis.dashboard.message.action.RemoveMessageAction">
<result name="success" type="redirect">message.action</result>
</action>
+
+ <action name="toggleFollowUp" class="org.hisp.dhis.dashboard.message.action.ToggleFollowUpAction">
+ <result name="success" type="velocity-json">/dhis-web-commons/ajax/jsonResponseSuccess.vm</result>
+ <param name="onExceptionReturn">plainTextError</param>
+ </action>
</package>
</struts>
=== 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-10-26 06:17:34 +0000
+++ dhis-2/dhis-web/dhis-web-dashboard-integration/src/main/webapp/dhis-web-dashboard-integration/javascript/message.js 2012-02-14 20:27:19 +0000
@@ -70,9 +70,25 @@
}
$( "#replyButton" ).attr( "disabled", "disabled" );
+
setHeaderWaitMessage( i18n_sending_message );
- $.postUTF8( "sendReply.action", { id:id, text:text }, function() {
+ $.postUTF8( "sendReply.action", { id:id, text:text }, function()
+ {
window.location.href = "readMessage.action?id=" + id;
} );
}
+
+function toggleFollowUp( id, followUp )
+{
+ var imageId = "followUp" + id;
+
+ var url = "toggleFollowUp.action?id=" + id;
+
+ $.getJSON( url, function( json )
+ {
+ var imageSrc = json.message == "true" ? "../images/marked.png" : "../images/unmarked.png";
+
+ $( "#" + imageId ).attr( "src", imageSrc );
+ } );
+}
=== modified file 'dhis-2/dhis-web/dhis-web-dashboard-integration/src/main/webapp/dhis-web-dashboard-integration/message.vm'
--- dhis-2/dhis-web/dhis-web-dashboard-integration/src/main/webapp/dhis-web-dashboard-integration/message.vm 2012-02-14 19:19:27 +0000
+++ dhis-2/dhis-web/dhis-web-dashboard-integration/src/main/webapp/dhis-web-dashboard-integration/message.vm 2012-02-14 20:27:19 +0000
@@ -12,13 +12,16 @@
<table style="width:90%" class="plainList">
<tr>
+ <th></th>
<th>$i18n.getString( "sender" )</th>
<th>$i18n.getString( "subject" )</th>
<th>$i18n.getString( "date" )</th>
- <th>$i18n.getString( "operations" )</th>
+ <th></th>
</tr>
#foreach( $conversation in $conversations )
<tr id="tr${conversation.id}" #if( !$conversation.read )class="unread bold"#end>
+ <td style="width:40px" onclick="toggleFollowUp( '${conversation.id}' )">
+ <img id="followUp${conversation.id}" #if( $conversation.followUp ) src="../images/marked.png"#else src="../images/unmarked.png"#end></td>
<td style="width:200px" onclick="read( '${conversation.id}' )">$encoder.htmlEncode( $conversation.lastSenderName )</td>
<td onclick="read( '${conversation.id}' )">$encoder.htmlEncode( $conversation.subject )</td>
<td onclick="read( '${conversation.id}' )" style="width:80px">$format.formatDate( $conversation.lastUpdated )</td>