=== added file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/caseentry/RemoveSingleEventAction.java' --- dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/caseentry/RemoveSingleEventAction.java 1970-01-01 00:00:00 +0000 +++ dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/caseentry/RemoveSingleEventAction.java 2014-04-30 12:57:22 +0000 @@ -0,0 +1,140 @@ +/* + * 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.caseentry; + +import java.util.Collection; + +import org.hisp.dhis.common.DeleteNotAllowedException; +import org.hisp.dhis.i18n.I18n; +import org.hisp.dhis.program.Program; +import org.hisp.dhis.program.ProgramInstance; +import org.hisp.dhis.program.ProgramInstanceService; +import org.hisp.dhis.program.ProgramService; +import org.hisp.dhis.program.ProgramStageInstanceService; +import org.hisp.dhis.trackedentity.TrackedEntityInstance; +import org.hisp.dhis.trackedentity.TrackedEntityInstanceService; +import org.springframework.beans.factory.annotation.Autowired; + +import com.opensymphony.xwork2.Action; + +/** + * @author Chau Thu Tran + * + * @version $ RemoveSingleEventAction.java Apr 30, 2014 5:56:25 PM $ + */ +public class RemoveSingleEventAction + implements Action +{ + // ------------------------------------------------------------------------- + // Dependency + // ------------------------------------------------------------------------- + @Autowired + private TrackedEntityInstanceService entityInstanceService; + + @Autowired + private ProgramService programService; + + @Autowired + private ProgramInstanceService programInstanceService; + + @Autowired + private ProgramStageInstanceService programStageInstanceService; + + private I18n i18n; + + public void setI18n( I18n i18n ) + { + this.i18n = i18n; + } + + // ------------------------------------------------------------------------- + // Getter && Setter + // ------------------------------------------------------------------------- + + private String entityInstanceId; + + public void setEntityInstanceId( String entityInstanceId ) + { + this.entityInstanceId = entityInstanceId; + } + + private String programId; + + public void setProgramId( String programId ) + { + this.programId = programId; + } + + // ------------------------------------------------------------------------- + // Output + // ------------------------------------------------------------------------- + + private String message; + + public String getMessage() + { + return message; + } + + // ------------------------------------------------------------------------- + // Action Implementation + // ------------------------------------------------------------------------- + + @Override + public String execute() + throws Exception + { + try + { + TrackedEntityInstance entityInstance = entityInstanceService.getTrackedEntityInstance( entityInstanceId ); + + Program program = programService.getProgram( programId ); + + Collection programInstances = programInstanceService.getProgramInstances( entityInstance, + program ); + if ( programInstances != null ) + { + ProgramInstance programInstance = programInstances.iterator().next(); + + programStageInstanceService.deleteProgramStageInstance( programInstance.getProgramStageInstances() + .iterator().next() ); + programInstanceService.deleteProgramInstance( programInstance ); + } + } + catch ( DeleteNotAllowedException ex ) + { + if ( ex.getErrorCode().equals( DeleteNotAllowedException.ERROR_ASSOCIATED_BY_OTHER_OBJECTS ) ) + { + message = i18n.getString( "object_not_deleted_associated_by_objects" ) + " " + ex.getMessage(); + + return ERROR; + } + } + 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 2014-04-24 16:30:48 +0000 +++ dhis-2/dhis-web/dhis-web-caseentry/src/main/resources/META-INF/dhis/beans.xml 2014-04-30 12:57:22 +0000 @@ -751,6 +751,12 @@ scope="prototype"> + + + === 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 2014-04-26 13:20:00 +0000 +++ dhis-2/dhis-web/dhis-web-caseentry/src/main/resources/struts.xml 2014-04-30 12:57:22 +0000 @@ -842,7 +842,7 @@ style/style.css F_TRACKED_ENTITY_INSTANCE_DASHBOARD - + @@ -854,6 +854,17 @@ F_PROGRAM_INSTANCE_DELETE + + + /dhis-web-commons/ajax/jsonResponseSuccess.vm + + + /dhis-web-commons/ajax/jsonResponseError.vm + + F_PROGRAM_INSTANCE_DELETE + + ' + programName + '
' + html); + setInnerHTML( 'programNameDiv', '

' + programName + '

'); var completed = jQuery('#entryFormContainer input[id=completed]').val(); var irregular = jQuery('#entryFormContainer input[id=irregular]').val(); showById('inputCriteriaDiv'); @@ -51,6 +53,7 @@ function showSearchForm() { + hideById('programNameDiv'); hideById('singleDataEntryFormDiv'); hideById('addNewDiv'); showById('searchDiv'); @@ -140,6 +143,7 @@ hideById('enrollmentDiv'); hideById('listRelationshipDiv'); hideById('addRelationshipDiv'); + hideById('programNameDiv'); hideById('singleDataEntryFormDiv'); hideById('migrationEntityInstanceDiv'); setInnerHTML('entityInstanceDashboard', ''); @@ -251,24 +255,23 @@ colVal = (colVal=='true')? i18n_yes : i18n_no; } - table += "" + colVal + ""; + + i18n_data_entry + + "'>" + colVal + ""; } // Operations column table += ""; - table += ""
 				+ i18n_data_entry
 				+ ""; - table += "" + i18n_remove
 				+ ""; @@ -357,3 +360,34 @@ loadDataEntry( json.activeProgramStageInstanceId ); }); }; + +function removeSingleEvent(uid) +{ + var result = window.confirm( i18n_comfirm_delete_event ); + + if ( result ) + { + jQuery.getJSON( "removeSingleEvent.action", + { + entityInstanceId: uid, + programId: getFieldValue('program') + }, + function( json ) + { + if ( json.response == "success" ) + { + $( "tr#tr" + uid ).remove(); + + $( "table.listTable tbody tr" ).removeClass( "listRow listAlternateRow" ); + $( "table.listTable tbody tr:odd" ).addClass( "listAlternateRow" ); + $( "table.listTable tbody tr:even" ).addClass( "listRow" ); + $( "table.listTable tbody" ).trigger("update"); + showSuccessMessage( i18n_delete_success ); + } + else if ( json.response == "error" ) + { + showWarningMessage( json.message ); + } + }); + } +} === modified file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/javascript/singleEvent.js' --- dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/javascript/singleEvent.js 2014-04-26 13:20:00 +0000 +++ dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/javascript/singleEvent.js 2014-04-30 12:57:22 +0000 @@ -62,10 +62,11 @@ }); } -function showUpdateTrackedEntityInstanceForm( entityInstanceId ) +function showUpdateEventForm( entityInstanceId ) { showLoader(); hideById('searchDiv'); + hideById('programNameDiv'); hideById('singleDataEntryFormDiv'); hideById('dataEntryMenu'); showById('eventActionMenu'); === modified file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/singleEventSelect.vm' --- dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/singleEventSelect.vm 2014-04-24 16:30:48 +0000 +++ dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/singleEventSelect.vm 2014-04-30 12:57:22 +0000 @@ -50,6 +50,7 @@
+