dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #23724
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 11546: Allow to remove messages in patient daashboard.
------------------------------------------------------------
revno: 11546
committer: Tran Chau <tran.hispvietnam@xxxxxxxxx>
branch nick: dhis2
timestamp: Thu 2013-08-01 10:02:12 +0700
message:
Allow to remove messages in patient daashboard.
added:
dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/reminder/RemoveSmsAction.java
modified:
dhis-2/dhis-api/src/main/java/org/hisp/dhis/sms/outbound/OutboundSmsService.java
dhis-2/dhis-services/dhis-service-sms/src/main/java/org/hisp/dhis/sms/outbound/OutboundSmsServiceImpl.java
dhis-2/dhis-services/dhis-service-sms/src/main/java/org/hisp/dhis/sms/outbound/TestOutboundSmsService.java
dhis-2/dhis-services/dhis-service-sms/src/main/java/org/hisp/dhis/sms/smslib/SmsLibService.java
dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/reminder/RemovePatientCommentAction.java
dhis-2/dhis-web/dhis-web-caseentry/src/main/resources/META-INF/dhis/beans.xml
dhis-2/dhis-web/dhis-web-caseentry/src/main/resources/org/hisp/dhis/caseentry/i18n_module.properties
dhis-2/dhis-web/dhis-web-caseentry/src/main/resources/struts.xml
dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/eventMessage.vm
dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/javascript/commons.js
dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/visitSchedule.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/sms/outbound/OutboundSmsService.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/sms/outbound/OutboundSmsService.java 2013-07-16 06:53:26 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/sms/outbound/OutboundSmsService.java 2013-08-01 03:02:12 +0000
@@ -66,4 +66,6 @@
void deleteById( Integer outboundSmsId );
List<OutboundSms> getOutboundSms( OutboundSmsStatus status );
+
+ OutboundSms getOutboundSms( int id );
}
=== modified file 'dhis-2/dhis-services/dhis-service-sms/src/main/java/org/hisp/dhis/sms/outbound/OutboundSmsServiceImpl.java'
--- dhis-2/dhis-services/dhis-service-sms/src/main/java/org/hisp/dhis/sms/outbound/OutboundSmsServiceImpl.java 2013-07-16 06:53:26 +0000
+++ dhis-2/dhis-services/dhis-service-sms/src/main/java/org/hisp/dhis/sms/outbound/OutboundSmsServiceImpl.java 2013-08-01 03:02:12 +0000
@@ -177,6 +177,12 @@
outboundSmsStore.delete( sms );
}
+ @Override
+ public OutboundSms getOutboundSms( int id )
+ {
+ return outboundSmsStore.get( id );
+ }
+
// -------------------------------------------------------------------------
// Support methods
// -------------------------------------------------------------------------
=== modified file 'dhis-2/dhis-services/dhis-service-sms/src/main/java/org/hisp/dhis/sms/outbound/TestOutboundSmsService.java'
--- dhis-2/dhis-services/dhis-service-sms/src/main/java/org/hisp/dhis/sms/outbound/TestOutboundSmsService.java 2013-07-16 06:53:26 +0000
+++ dhis-2/dhis-services/dhis-service-sms/src/main/java/org/hisp/dhis/sms/outbound/TestOutboundSmsService.java 2013-08-01 03:02:12 +0000
@@ -156,7 +156,7 @@
public void deleteById( Integer outboundSmsId )
{
}
-
+
@Override
public String getDefaultGateway()
{
@@ -178,4 +178,10 @@
// TODO Auto-generated method stub
return null;
}
+
+ @Override
+ public OutboundSms getOutboundSms( int id )
+ {
+ return null;
+ }
}
=== modified file 'dhis-2/dhis-services/dhis-service-sms/src/main/java/org/hisp/dhis/sms/smslib/SmsLibService.java'
--- dhis-2/dhis-services/dhis-service-sms/src/main/java/org/hisp/dhis/sms/smslib/SmsLibService.java 2013-07-19 06:04:09 +0000
+++ dhis-2/dhis-services/dhis-service-sms/src/main/java/org/hisp/dhis/sms/smslib/SmsLibService.java 2013-08-01 03:02:12 +0000
@@ -99,7 +99,12 @@
{
this.smsConsumer = smsConsumer;
}
-
+
+ public OutboundSms getOutboundSms( int id )
+ {
+ return outboundSmsStore.get( id );
+ }
+
@Override
public boolean isEnabled()
{
=== modified file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/reminder/RemovePatientCommentAction.java'
--- dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/reminder/RemovePatientCommentAction.java 2012-09-11 13:35:26 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/reminder/RemovePatientCommentAction.java 2013-08-01 03:02:12 +0000
@@ -91,7 +91,9 @@
.getProgramStageInstance( programStageInstanceId );
programStageInstance.getPatientComments().remove( patientComment );
-
+
+ commentService.deletePatientComment( patientComment );
+
programStageInstanceService.updateProgramStageInstance( programStageInstance );
return SUCCESS;
=== added file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/reminder/RemoveSmsAction.java'
--- dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/reminder/RemoveSmsAction.java 1970-01-01 00:00:00 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/reminder/RemoveSmsAction.java 2013-08-01 03:02:12 +0000
@@ -0,0 +1,127 @@
+/*
+ * Copyright (c) 2004-2013, 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.
+ */
+
+package org.hisp.dhis.caseentry.action.reminder;
+
+import org.hisp.dhis.program.ProgramInstance;
+import org.hisp.dhis.program.ProgramInstanceService;
+import org.hisp.dhis.program.ProgramStageInstance;
+import org.hisp.dhis.program.ProgramStageInstanceService;
+import org.hisp.dhis.sms.outbound.OutboundSms;
+import org.hisp.dhis.sms.outbound.OutboundSmsService;
+
+import com.opensymphony.xwork2.Action;
+
+/**
+ * @author Chau Thu Tran
+ *
+ * @version $ RemoveSmsAction.java Jul 31, 2013 2:20:01 PM $
+ */
+public class RemoveSmsAction
+ implements Action
+{
+
+ // -------------------------------------------------------------------------
+ // Dependencies
+ // -------------------------------------------------------------------------
+
+ private ProgramInstanceService programInstanceService;
+
+ public void setProgramInstanceService( ProgramInstanceService programInstanceService )
+ {
+ this.programInstanceService = programInstanceService;
+ }
+
+ private ProgramStageInstanceService programStageInstanceService;
+
+ public void setProgramStageInstanceService( ProgramStageInstanceService programStageInstanceService )
+ {
+ this.programStageInstanceService = programStageInstanceService;
+ }
+
+ private OutboundSmsService outboundSmsService;
+
+ public void setOutboundSmsService( OutboundSmsService outboundSmsService )
+ {
+ this.outboundSmsService = outboundSmsService;
+ }
+
+ // -------------------------------------------------------------------------
+ // Input
+ // -------------------------------------------------------------------------
+
+ private int id;
+
+ public void setId( int id )
+ {
+ this.id = id;
+ }
+
+ private Integer programInstanceId;
+
+ public void setProgramInstanceId( Integer programInstanceId )
+ {
+ this.programInstanceId = programInstanceId;
+ }
+
+ private Integer programStageInstanceId;
+
+ public void setProgramStageInstanceId( Integer programStageInstanceId )
+ {
+ this.programStageInstanceId = programStageInstanceId;
+ }
+
+ // -------------------------------------------------------------------------
+ // Action implementation
+ // -------------------------------------------------------------------------
+
+ public String execute()
+ {
+ OutboundSms outboundSms = outboundSmsService.getOutboundSms( id );
+
+ if ( programInstanceId != null )
+ {
+ ProgramInstance programInstance = programInstanceService.getProgramInstance( programInstanceId );
+
+ programInstance.getOutboundSms().remove( outboundSms );
+
+ programInstanceService.updateProgramInstance( programInstance );
+ }
+ else if ( programStageInstanceId != null )
+ {
+ ProgramStageInstance programStageInstance = programStageInstanceService
+ .getProgramStageInstance( programStageInstanceId );
+
+ programStageInstance.getOutboundSms().remove( outboundSms );
+
+ programStageInstanceService.updateProgramStageInstance( programStageInstance );
+ }
+
+ return SUCCESS;
+ }
+
+}
=== modified file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/resources/META-INF/dhis/beans.xml'
--- dhis-2/dhis-web/dhis-web-caseentry/src/main/resources/META-INF/dhis/beans.xml 2013-07-31 06:51:17 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/resources/META-INF/dhis/beans.xml 2013-08-01 03:02:12 +0000
@@ -1133,7 +1133,7 @@
<property name="programInstanceService" ref="org.hisp.dhis.program.ProgramInstanceService" />
</bean>
- <!-- Comment -->
+ <!-- Comment && Message -->
<bean id="org.hisp.dhis.caseentry.action.reminder.AddPatientCommentAction"
class="org.hisp.dhis.caseentry.action.reminder.AddPatientCommentAction"
@@ -1164,6 +1164,18 @@
ref="org.hisp.dhis.patientdatavalue.PatientDataValueService" />
</bean>
+ <bean
+ id="org.hisp.dhis.caseentry.action.reminder.RemoveSmsAction"
+ class="org.hisp.dhis.caseentry.action.reminder.RemoveSmsAction"
+ scope="prototype">
+ <property name="programInstanceService"
+ ref="org.hisp.dhis.program.ProgramInstanceService" />
+ <property name="programStageInstanceService"
+ ref="org.hisp.dhis.program.ProgramStageInstanceService" />
+ <property name="outboundSmsService"
+ ref="org.hisp.dhis.sms.outbound.OutboundSmsService" />
+ </bean>
+
<!-- Program-stage-completeness -->
<bean
=== modified file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/resources/org/hisp/dhis/caseentry/i18n_module.properties'
--- dhis-2/dhis-web/dhis-web-caseentry/src/main/resources/org/hisp/dhis/caseentry/i18n_module.properties 2013-07-31 06:51:17 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/resources/org/hisp/dhis/caseentry/i18n_module.properties 2013-08-01 03:02:12 +0000
@@ -667,4 +667,5 @@
custom_form_name = Custom form name
use_orgunits_from_level = Use organisation units from level
message = Message
-add_patient = Add person
\ No newline at end of file
+add_patient = Add person
+confirmation_delete_message = Are you sure you want to delete this message ?
\ No newline at end of file
=== modified file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/resources/struts.xml'
--- dhis-2/dhis-web/dhis-web-caseentry/src/main/resources/struts.xml 2013-07-26 03:52:08 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/resources/struts.xml 2013-08-01 03:02:12 +0000
@@ -1104,7 +1104,7 @@
<param name="requiredAuthorities">F_PROGRAM_INSTANCE_DELETE</param>
</action>
- <!-- Comment -->
+ <!-- Comment && Message -->
<action name="addPatientComment"
class="org.hisp.dhis.caseentry.action.reminder.AddPatientCommentAction">
@@ -1114,7 +1114,14 @@
</action>
<action name="removePatientComment"
- class="org.hisp.dhis.caseentry.action.reminder.RemovePatientCommentAction">
+ class="org.hisp.dhis.caseentry.action.reminder.RemoveSmsAction">
+ <result name="success" type="velocity-json">/dhis-web-commons/ajax/jsonResponseSuccess.vm
+ </result>
+ <param name="requiredAuthorities">F_PATIENT_COMMENT_DELETE</param>
+ </action>
+
+ <action name="removeSms"
+ class="org.hisp.dhis.caseentry.action.reminder.RemoveSmsAction">
<result name="success" type="velocity-json">/dhis-web-commons/ajax/jsonResponseSuccess.vm
</result>
<param name="requiredAuthorities">F_PATIENT_COMMENT_DELETE</param>
=== modified file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/eventMessage.vm'
--- dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/eventMessage.vm 2013-07-25 06:08:47 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/eventMessage.vm 2013-08-01 03:02:12 +0000
@@ -13,6 +13,7 @@
<th class="{sorter: false}">$i18n.getString( "sender" )</th>
<th class="{sorter: false}">$i18n.getString( "type" )</th>
<th class="{sorter: false}">$i18n.getString( "message" )</th>
+ <th class="{sorter: false}">$i18n.getString( "operation" )</th>
</tr>
</thead>
<tbody id='commentReportTB' name="messageTB">
@@ -25,6 +26,9 @@
<td>$comment.creator</td>
<td>$i18n.getString('comment')</td>
<td>$comment.commentText</td>
+ <td>
+ <a href="javascript:removeComment( '$programStageInstance.id', '$comment.id' )" title="$i18n.getString( 'remove' )"><img src="../images/delete.png" alt="$i18n.getString( 'remove' )"></a>
+ </td>
</tr>
#set( $mark = !$mark )
#end
@@ -36,6 +40,9 @@
<td>$sms.sender</td>
<td>$i18n.getString('message')</td>
<td>$sms.message</td>
+ <td>
+ <a href="javascript:removeMessage( $programInstances.id, '', $sms.id )" title="$i18n.getString( 'remove' )"><img src="../images/delete.png" alt="$i18n.getString( 'remove' )"></a>
+ </td>
</tr>
#set( $mark = !$mark )
#end
@@ -47,6 +54,9 @@
<td>$sms.sender</td>
<td>$i18n.getString('message')</td>
<td>$sms.message</td>
+ <td>
+ <a href="javascript:removeMessage('', $programStageInstance.id, $sms.id )" title="$i18n.getString( 'remove' )"><img src="../images/delete.png" alt="$i18n.getString( 'remove' )"></a>
+ </td>
</tr>
#set( $mark = !$mark )
#end
@@ -57,6 +67,8 @@
<input type='button' id="showCommentBtn" name="showCommentBtn" value='$i18n.getString("show_hide_more")' onclick='commentDivToggle(false);'>
<input type='button' id="hideCommentBtn" name="hideCommentBtn" value='$i18n.getString("show_hide_more")' onclick='commentDivToggle(true);'>
<script>
+ var i18n_confirmation_delete_message = '$encoder.jsEscape( $i18n.getString( "confirmation_delete_message" ) , "'" )';
+ var i18n_deleting = '$encoder.jsEscape( $i18n.getString( "deleting" ) , "'" )';
commentDivToggle(true);
tableSorter( 'messageList' );
var sorting = [[0,1]];
=== modified file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/javascript/commons.js'
--- dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/javascript/commons.js 2013-07-30 06:16:43 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/javascript/commons.js 2013-08-01 03:02:12 +0000
@@ -1930,15 +1930,52 @@
function removeComment( programStageInstanceId, commentId )
{
- jQuery.postUTF8( 'removePatientComment.action',
+ var result = window.confirm( i18n_confirmation_delete_message );
+
+ if ( result )
+ {
+ setHeaderWaitMessage( i18n_deleting );
+ jQuery.postUTF8( 'removePatientComment.action',
{
programStageInstanceId: programStageInstanceId,
id: commentId
}, function ( json )
{
- showSuccessMessage( json.message );
hideById( 'comment_' + commentId );
- } );
+
+ jQuery( "tr#comment_" + commentId ).remove();
+ jQuery( "table.listTable tbody tr" ).removeClass( "listRow listAlternateRow" );
+ jQuery( "table.listTable tbody tr:odd" ).addClass( "listAlternateRow" );
+ jQuery( "table.listTable tbody tr:even" ).addClass( "listRow" );
+ jQuery( "table.listTable tbody" ).trigger("update");
+ setHeaderDelayMessage( i18n_delete_success );
+ } );
+ }
+}
+
+function removeMessage(programInstanceId, programStageInstanceId, smsId )
+{
+ var result = window.confirm( i18n_confirmation_delete_message);
+
+ if ( result )
+ {
+ setHeaderWaitMessage( i18n_deleting );
+ jQuery.postUTF8( 'removeSms.action',
+ {
+ programInstanceId: programInstanceId,
+ programStageInstanceId: programStageInstanceId,
+ id: smsId
+ },
+ function ( json )
+ {
+ jQuery( "tr#tr" + smsId ).remove();
+ jQuery( "table.listTable tbody tr" ).removeClass( "listRow listAlternateRow" );
+ jQuery( "table.listTable tbody tr:odd" ).addClass( "listAlternateRow" );
+ jQuery( "table.listTable tbody tr:even" ).addClass( "listRow" );
+ jQuery( "table.listTable tbody" ).trigger("update");
+ setHeaderDelayMessage( i18n_delete_success );
+ } );
+ }
}
function commentDivToggle(isHide)
=== modified file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/visitSchedule.vm'
--- dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/visitSchedule.vm 2013-07-25 04:21:38 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/visitSchedule.vm 2013-08-01 03:02:12 +0000
@@ -133,7 +133,7 @@
<th>$i18n.getString( "status" )</th>
<th colspan='2'>$i18n.getString( "message" )</th>
#if( $auth.hasAccess( "dhis-web-caseentry", "removeCurrentEncounter" ) )
- <th>$i18n.getString( "remove" )</th>
+ <th>$i18n.getString( "operation" )</th>
#end
</tr>
<tbody>