dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #17861
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 7279: Sort program-stages by Scheduled days from start.
------------------------------------------------------------
revno: 7279
committer: Tran Chau <tran.hispvietnam@xxxxxxxxx>
branch nick: dhis2
timestamp: Wed 2012-06-13 10:59:26 +0700
message:
Sort program-stages by Scheduled days from start.
removed:
dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/java/org/hisp/dhis/patient/action/programstage/ShowSortProgramStageFormAction.java
dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/sortProgramStageForm.vm
added:
dhis-2/dhis-api/src/main/java/org/hisp/dhis/program/comparator/ProgramStageMinDaysComparator.java
dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/app/images/data.png
dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/app/images/options.png
dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/app/images/organisationunit.png
modified:
dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/app/app.js
dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/java/org/hisp/dhis/patient/action/programstage/GetProgramStageListAction.java
dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/java/org/hisp/dhis/patient/action/programstage/SaveProgramStageSortOrderAction.java
dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/resources/META-INF/dhis/beans.xml
dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/resources/org/hisp/dhis/patient/i18n_module.properties
dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/resources/struts.xml
--
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/program/comparator/ProgramStageMinDaysComparator.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/program/comparator/ProgramStageMinDaysComparator.java 1970-01-01 00:00:00 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/program/comparator/ProgramStageMinDaysComparator.java 2012-06-13 03:59:26 +0000
@@ -0,0 +1,45 @@
+/*
+ * Copyright (c) 2004-2012, 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.program.comparator;
+
+import java.util.Comparator;
+
+import org.hisp.dhis.program.ProgramStage;
+
+/**
+ * @author Chau Thu Tran
+ *
+ * @version $ProgramStageMinDaysComparator.java Jun 12, 2012 3:22:20 PM$
+ */
+public class ProgramStageMinDaysComparator implements Comparator<ProgramStage>
+{
+ public int compare( ProgramStage programStage1, ProgramStage programStage2 )
+ {
+ return programStage1.getMinDaysFromStart() - programStage2.getMinDaysFromStart();
+ }
+}
=== modified file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/app/app.js'
--- dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/app/app.js 2012-06-12 06:02:21 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/app/app.js 2012-06-13 03:59:26 +0000
@@ -1138,7 +1138,7 @@
success: function() {
var rowIdx = e.rowIdx;
var colIdx = e.colIdx + 1;
- if( e.colIdx == TR.datatable.datatable.columns.length - 1 ){
+ if( e.colIdx == TR.datatable.datatable.columns.length - 2 ){
colIdx = 0;
rowIdx++;
}
=== added file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/app/images/data.png'
Binary files dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/app/images/data.png 1970-01-01 00:00:00 +0000 and dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/app/images/data.png 2012-06-13 03:59:26 +0000 differ
=== added file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/app/images/options.png'
Binary files dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/app/images/options.png 1970-01-01 00:00:00 +0000 and dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/app/images/options.png 2012-06-13 03:59:26 +0000 differ
=== added file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/app/images/organisationunit.png'
Binary files dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/app/images/organisationunit.png 1970-01-01 00:00:00 +0000 and dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/app/images/organisationunit.png 2012-06-13 03:59:26 +0000 differ
=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/java/org/hisp/dhis/patient/action/programstage/GetProgramStageListAction.java'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/java/org/hisp/dhis/patient/action/programstage/GetProgramStageListAction.java 2012-05-23 16:19:55 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/java/org/hisp/dhis/patient/action/programstage/GetProgramStageListAction.java 2012-06-13 03:59:26 +0000
@@ -34,8 +34,6 @@
import org.hisp.dhis.program.Program;
import org.hisp.dhis.program.ProgramService;
import org.hisp.dhis.program.ProgramStage;
-import org.hisp.dhis.program.ProgramStageService;
-import org.hisp.dhis.program.comparator.ProgramStageNameComparator;
import org.hisp.dhis.program.comparator.ProgramStageOrderComparator;
import com.opensymphony.xwork2.Action;
@@ -58,13 +56,6 @@
this.programService = programService;
}
- private ProgramStageService programStageService;
-
- public void setProgramStageService( ProgramStageService programStageService )
- {
- this.programStageService = programStageService;
- }
-
// -------------------------------------------------------------------------
// Input/Output
// -------------------------------------------------------------------------
@@ -92,7 +83,7 @@
{
this.associations = associations;
}
-
+
private Program program;
public Program getProgram()
@@ -107,20 +98,11 @@
public String execute()
throws Exception
{
- if ( id != null )
- {
- program = programService.getProgram( id );
-
- associations = new ArrayList<ProgramStage>( program.getProgramStages() );
-
- Collections.sort( associations, new ProgramStageOrderComparator() );
- }
- else
- {
- associations = new ArrayList<ProgramStage>( programStageService.getAllProgramStages() );
-
- Collections.sort( associations, new ProgramStageNameComparator() );
- }
+ program = programService.getProgram( id );
+
+ associations = new ArrayList<ProgramStage>( program.getProgramStages() );
+
+ Collections.sort( associations, new ProgramStageOrderComparator() );
return SUCCESS;
}
=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/java/org/hisp/dhis/patient/action/programstage/SaveProgramStageSortOrderAction.java'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/java/org/hisp/dhis/patient/action/programstage/SaveProgramStageSortOrderAction.java 2011-03-31 01:42:05 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/java/org/hisp/dhis/patient/action/programstage/SaveProgramStageSortOrderAction.java 2012-06-13 03:59:26 +0000
@@ -28,10 +28,14 @@
package org.hisp.dhis.patient.action.programstage;
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.ProgramStageService;
+import org.hisp.dhis.program.comparator.ProgramStageMinDaysComparator;
import com.opensymphony.xwork2.Action;
@@ -47,6 +51,13 @@
// Dependency
// -------------------------------------------------------------------------
+ private ProgramService programService;
+
+ public void setProgramService( ProgramService programService )
+ {
+ this.programService = programService;
+ }
+
private ProgramStageService programStageService;
public void setProgramStageService( ProgramStageService programStageService )
@@ -58,20 +69,8 @@
// Input/Output
// -------------------------------------------------------------------------
- private List<Integer> programStageList;
-
- public void setProgramStageList( List<Integer> programStageList )
- {
- this.programStageList = programStageList;
- }
-
private Integer id;
- public Integer getId()
- {
- return id;
- }
-
public void setId( Integer id )
{
this.id = id;
@@ -80,24 +79,26 @@
// -------------------------------------------------------------------------
// Action implementation
// -------------------------------------------------------------------------
-
+
public String execute()
{
int stageInProgram = 1;
- List<ProgramStage> programStages = new ArrayList<ProgramStage>( programStageList.size() );
+ Program program = programService.getProgram( id );
- for ( Integer programStageId : programStageList )
+ if ( program.getProgramStages() != null )
{
- ProgramStage programStage = programStageService.getProgramStage( programStageId );
-
- programStages.add( programStage );
-
- programStage.setStageInProgram( stageInProgram++ );
-
- programStageService.updateProgramStage( programStage );
+ List<ProgramStage> programStages = new ArrayList<ProgramStage>( program.getProgramStages() );
+ Collections.sort( programStages, new ProgramStageMinDaysComparator() );
+
+ for ( ProgramStage programStage : programStages )
+ {
+ programStage.setStageInProgram( stageInProgram++ );
+
+ programStageService.updateProgramStage( programStage );
+ }
}
-
+
return SUCCESS;
}
}
=== removed file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/java/org/hisp/dhis/patient/action/programstage/ShowSortProgramStageFormAction.java'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/java/org/hisp/dhis/patient/action/programstage/ShowSortProgramStageFormAction.java 2011-03-31 01:42:05 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/java/org/hisp/dhis/patient/action/programstage/ShowSortProgramStageFormAction.java 1970-01-01 00:00:00 +0000
@@ -1,104 +0,0 @@
-/*
- * Copyright (c) 2004-2009, 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.patient.action.programstage;
-
-import java.util.ArrayList;
-import java.util.Collection;
-
-import org.hisp.dhis.program.Program;
-import org.hisp.dhis.program.ProgramService;
-import org.hisp.dhis.program.ProgramStage;
-
-import com.opensymphony.xwork2.Action;
-
-/**
- * @author Abyot Asalefew Gizaw
- * @version $Id$
- */
-public class ShowSortProgramStageFormAction
- implements Action
-{
- // -------------------------------------------------------------------------
- // Dependency
- // -------------------------------------------------------------------------
-
- private ProgramService programService;
-
- public void setProgramService( ProgramService programService )
- {
- this.programService = programService;
- }
-
- // -------------------------------------------------------------------------
- // Input/Output
- // -------------------------------------------------------------------------
-
- private Integer id;
-
- public Integer getId()
- {
- return id;
- }
-
- public void setId( Integer id )
- {
- this.id = id;
- }
-
- private Program program;
-
- public Program getProgram()
- {
- return program;
- }
-
- public void setProgram( Program program )
- {
- this.program = program;
- }
-
- private Collection<ProgramStage> programStages = new ArrayList<ProgramStage>();
-
- public Collection<ProgramStage> getProgramStages()
- {
- return programStages;
- }
-
- // -------------------------------------------------------------------------
- // Action implementation
- // -------------------------------------------------------------------------
-
- public String execute()
- {
- program = programService.getProgram( id );
-
- programStages = program.getProgramStages();
-
- return SUCCESS;
- }
-}
=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/resources/META-INF/dhis/beans.xml'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/resources/META-INF/dhis/beans.xml 2012-06-04 04:06:04 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/resources/META-INF/dhis/beans.xml 2012-06-13 03:59:26 +0000
@@ -239,7 +239,6 @@
class="org.hisp.dhis.patient.action.programstage.GetProgramStageListAction"
scope="prototype">
<property name="programService" ref="org.hisp.dhis.program.ProgramService" />
- <property name="programStageService" ref="org.hisp.dhis.program.ProgramStageService" />
</bean>
<bean id="org.hisp.dhis.patient.action.programstage.GetProgramStageAction"
@@ -256,17 +255,11 @@
</bean>
<bean
- id="org.hisp.dhis.patient.action.programstage.ShowSortProgramStageFormAction"
- class="org.hisp.dhis.patient.action.programstage.ShowSortProgramStageFormAction"
- scope="prototype">
- <property name="programService" ref="org.hisp.dhis.program.ProgramService" />
- </bean>
-
- <bean
id="org.hisp.dhis.patient.action.programstage.SaveProgramStageSortOrderAction"
class="org.hisp.dhis.patient.action.programstage.SaveProgramStageSortOrderAction"
scope="prototype">
<property name="programStageService" ref="org.hisp.dhis.program.ProgramStageService" />
+ <property name="programService" ref="org.hisp.dhis.program.ProgramService" />
</bean>
<bean
=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/resources/org/hisp/dhis/patient/i18n_module.properties'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/resources/org/hisp/dhis/patient/i18n_module.properties 2012-06-04 10:03:56 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/resources/org/hisp/dhis/patient/i18n_module.properties 2012-06-13 03:59:26 +0000
@@ -143,7 +143,7 @@
compulsory=Compulsory
design_data_entry_form=Design data entry form
no_of_char=Number of characters
-letter=Letter
+letter_only=Letter Only
duration_in_days=Duration in days
program_attribute=Program Attribute
program_attribute_management=Program attribute management
@@ -244,4 +244,5 @@
stage_visited = Stage visited
report_date = Report date
program_stage_properties = Program stage properties
-allow_provided_elsewhere = Allow provided elsewhere
\ No newline at end of file
+allow_provided_elsewhere = Allow provided elsewhere
+save_success=Save successful
\ No newline at end of file
=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/resources/struts.xml'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/resources/struts.xml 2012-06-04 04:06:04 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/resources/struts.xml 2012-06-13 03:59:26 +0000
@@ -267,7 +267,7 @@
<action name="programStage"
class="org.hisp.dhis.patient.action.programstage.GetProgramStageListAction">
<result name="success" type="velocity">/main.vm</result>
- <param name="page">/dhis-web-maintenance-patient/programStageList.vm</param>
+ <param name="page">/dhis-web-maintenance-patient/programStage.vm</param>
<param name="javascripts">javascript/programStage.js</param>
</action>
@@ -333,17 +333,17 @@
<param name="requiredAuthorities">F_PROGRAMSTAGE_DELETE</param>
</action>
- <action name="showSortProgramStageForm"
- class="org.hisp.dhis.patient.action.programstage.ShowSortProgramStageFormAction">
- <result name="success" type="velocity">/main.vm</result>
- <param name="page">/dhis-web-maintenance-patient/sortProgramStageForm.vm</param>
- <param name="requiredAuthorities">F_PROGRAMSTAGE_ADD</param>
- </action>
-
<action name="saveProgramStageSortOder"
class="org.hisp.dhis.patient.action.programstage.SaveProgramStageSortOrderAction">
- <result name="success" type="redirect">programStage.action?id=${id}
- </result>
+ <result name="success" type="velocity-json">
+ /dhis-web-commons/ajax/jsonResponseSuccess.vm</result>
+ </action>
+
+ <action name="programStageList"
+ class="org.hisp.dhis.patient.action.programstage.GetProgramStageListAction">
+ <result name="success" type="velocity">/content.vm</result>
+ <param name="page">/dhis-web-maintenance-patient/programStageList.vm</param>
+ <param name="javascripts">javascript/programStage.js</param>
</action>
<!-- Data Entry Form -->
=== removed file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/sortProgramStageForm.vm'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/sortProgramStageForm.vm 2012-03-30 05:33:37 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/sortProgramStageForm.vm 1970-01-01 00:00:00 +0000
@@ -1,36 +0,0 @@
-<h3>$i18n.getString( "program_stage_sort_order" )</h3>
-
-<form id="sortProgramStageForm" name="sortProgramStageForm" action="saveProgramStageSortOder.action" method="post" onsubmit="selectAllById('programStageList');">
-
-<div style="display:inline">
- <input type="hidden" id="id" name="id" value="$program.id">
-</div>
-<table>
-
- <tr><td></td></tr>
- <tr>
- <td>$encoder.htmlEncode( $program.name )</td>
- </tr>
- <tr>
- <td>
- <select size="15" id="programStageList" name="programStageList" multiple="multiple" style="min-width:20em;height:20em">
- #foreach ( $programStage in $programStages )
- <option value="$programStage.id">$encoder.htmlEncode( $programStage.name )</option>
- #end
- </select>
- </td>
-
- <td valign="top" align="center">
- <a href="#" onclick="moveUpSelectedOption('programStageList')"><img src="../images/move_up.png" border="0" alt=""></a><br><br>
- <a href="#" onclick="moveDownSelectedOption('programStageList')"><img src="../images/move_down.png" border="0" alt=""></a>
- </td>
-
- <tr>
-</table>
-
-<p>
- <input type="submit" value="$i18n.getString( "save" )" style="width:10em">
- <input type="button" value="$i18n.getString( "cancel" )" onclick="window.location.href='programStage.action?id=$program.id'" style="width:10em">
-</p>
-
-</form>