=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-program/src/main/java/org/hisp/dhis/trackedentity/action/programstage/AddProgramStageAction.java' --- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-program/src/main/java/org/hisp/dhis/trackedentity/action/programstage/AddProgramStageAction.java 2014-07-26 14:38:39 +0000 +++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-program/src/main/java/org/hisp/dhis/trackedentity/action/programstage/AddProgramStageAction.java 2014-07-27 12:49:21 +0000 @@ -29,6 +29,7 @@ */ import java.util.ArrayList; +import java.util.Collections; import java.util.HashSet; import java.util.List; import java.util.Set; @@ -41,6 +42,7 @@ import org.hisp.dhis.program.ProgramStageDataElement; import org.hisp.dhis.program.ProgramStageDataElementService; import org.hisp.dhis.program.ProgramStageService; +import org.hisp.dhis.program.comparator.ProgramStageMinDaysComparator; import org.hisp.dhis.trackedentity.TrackedEntityInstanceReminder; import org.hisp.dhis.user.UserGroup; import org.hisp.dhis.user.UserGroupService; @@ -376,11 +378,15 @@ reminders.add( reminder ); } programStage.setReminders( reminders ); - program.getProgramStages().add( programStage ); + programStageService.saveProgramStage( programStage ); - programStageService.saveProgramStage( programStage ); - + List programStages = new ArrayList( program.getProgramStages() ); + Collections.sort( programStages, new ProgramStageMinDaysComparator() ); + program.getProgramStages().clear(); + program.setProgramStages(programStages); + programService.updateProgram( program ); + for ( int i = 0; i < this.selectedDataElementsValidator.size(); i++ ) { DataElement dataElement = dataElementService.getDataElement( selectedDataElementsValidator.get( i ) ); === removed file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-program/src/main/java/org/hisp/dhis/trackedentity/action/programstage/SaveProgramStageSortOrderAction.java' --- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-program/src/main/java/org/hisp/dhis/trackedentity/action/programstage/SaveProgramStageSortOrderAction.java 2014-07-26 14:38:39 +0000 +++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-program/src/main/java/org/hisp/dhis/trackedentity/action/programstage/SaveProgramStageSortOrderAction.java 1970-01-01 00:00:00 +0000 @@ -1,90 +0,0 @@ -package org.hisp.dhis.trackedentity.action.programstage; - -/* - * Copyright (c) 2004-2014, 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.ArrayList; -import java.util.Collections; -import java.util.List; - -import org.hisp.dhis.program.Program; -import org.hisp.dhis.program.ProgramService; -import org.hisp.dhis.program.ProgramStage; -import org.hisp.dhis.program.comparator.ProgramStageMinDaysComparator; - -import com.opensymphony.xwork2.Action; - -/** - * @author Abyot Asalefew Gizaw - * @version $Id$ - */ -public class SaveProgramStageSortOrderAction - implements Action -{ - - // ------------------------------------------------------------------------- - // Dependency - // ------------------------------------------------------------------------- - - private ProgramService programService; - - public void setProgramService( ProgramService programService ) - { - this.programService = programService; - } - - // ------------------------------------------------------------------------- - // Input/Output - // ------------------------------------------------------------------------- - - private Integer id; - - public void setId( Integer id ) - { - this.id = id; - } - - // ------------------------------------------------------------------------- - // Action implementation - // ------------------------------------------------------------------------- - - public String execute() - { - Program program = programService.getProgram( id ); - - if ( program.getProgramStages() != null ) - { - List programStages = new ArrayList( program.getProgramStages() ); - Collections.sort( programStages, new ProgramStageMinDaysComparator() ); - program.setProgramStages(programStages); - programService.updateProgram( program ); - } - - return SUCCESS; - } -} === modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-program/src/main/java/org/hisp/dhis/trackedentity/action/programstage/UpdateProgramStageAction.java' --- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-program/src/main/java/org/hisp/dhis/trackedentity/action/programstage/UpdateProgramStageAction.java 2014-07-26 14:38:39 +0000 +++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-program/src/main/java/org/hisp/dhis/trackedentity/action/programstage/UpdateProgramStageAction.java 2014-07-27 12:49:21 +0000 @@ -29,19 +29,24 @@ */ import java.util.ArrayList; +import java.util.Collections; import java.util.HashSet; import java.util.List; import java.util.Set; import org.hisp.dhis.dataelement.DataElement; import org.hisp.dhis.dataelement.DataElementService; +import org.hisp.dhis.program.Program; +import org.hisp.dhis.program.ProgramService; import org.hisp.dhis.program.ProgramStage; import org.hisp.dhis.program.ProgramStageDataElement; import org.hisp.dhis.program.ProgramStageDataElementService; import org.hisp.dhis.program.ProgramStageService; +import org.hisp.dhis.program.comparator.ProgramStageMinDaysComparator; import org.hisp.dhis.trackedentity.TrackedEntityInstanceReminder; import org.hisp.dhis.user.UserGroup; import org.hisp.dhis.user.UserGroupService; +import org.springframework.beans.factory.annotation.Autowired; import com.opensymphony.xwork2.Action; @@ -85,6 +90,9 @@ this.userGroupService = userGroupService; } + @Autowired + private ProgramService programService; + // ------------------------------------------------------------------------- // Input/Output // ------------------------------------------------------------------------- @@ -375,6 +383,13 @@ programStageService.updateProgramStage( programStage ); + Program program = programStage.getProgram(); + List programStages = new ArrayList( program.getProgramStages() ); + Collections.sort( programStages, new ProgramStageMinDaysComparator() ); + program.getProgramStages().clear(); + program.setProgramStages(programStages); + programService.updateProgram( program ); + Set programStageDataElements = new HashSet( programStage.getProgramStageDataElements() ); === modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-program/src/main/resources/META-INF/dhis/beans.xml' --- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-program/src/main/resources/META-INF/dhis/beans.xml 2014-07-26 14:38:39 +0000 +++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-program/src/main/resources/META-INF/dhis/beans.xml 2014-07-27 12:49:21 +0000 @@ -300,13 +300,6 @@ - - - - === modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-program/src/main/resources/struts.xml' --- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-program/src/main/resources/struts.xml 2014-07-26 14:38:39 +0000 +++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-program/src/main/resources/struts.xml 2014-07-27 12:49:21 +0000 @@ -362,13 +362,6 @@ F_PROGRAMSTAGE_DELETE - - - /dhis-web-commons/ajax/jsonResponseSuccess.vm - - - /content.vm === modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-program/src/main/webapp/dhis-web-maintenance-program/javascript/programStage.js' --- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-program/src/main/webapp/dhis-web-maintenance-program/javascript/programStage.js 2014-06-21 09:56:19 +0000 +++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-program/src/main/webapp/dhis-web-maintenance-program/javascript/programStage.js 2014-07-27 12:49:21 +0000 @@ -44,33 +44,6 @@ } } -function sortProgramStages() -{ - var programId = getFieldValue('id'); - if( programId == "null" || programId == "" ) - { - showWarningMessage( i18n_please_select_program ); - } - else - { - jQuery.getJSON( 'saveProgramStageSortOder.action', { id: programId }, - function ( json ) { - showSuccessMessage( i18n_success ); - loadProgramStageList( programId ); - }); - } -} - -function loadProgramStageList( programId ) -{ - jQuery('#programStageListDiv').load('programStageList.action',{ - id: programId - }, - function( html ){ - setInnerHTML('programStageListDiv', html ); - }); -} - // ----------------------------------------------------------------------------- // View details // ----------------------------------------------------------------------------- === modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-program/src/main/webapp/dhis-web-maintenance-program/programStage.vm' --- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-program/src/main/webapp/dhis-web-maintenance-program/programStage.vm 2014-07-26 14:38:39 +0000 +++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-program/src/main/webapp/dhis-web-maintenance-program/programStage.vm 2014-07-27 12:49:21 +0000 @@ -21,7 +21,6 @@ #if( $program.type=='1' )
-
#end