dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #12233
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 3713: Fix bug: Don't save compulsory value of dataelements while adding / updating program-stage.
------------------------------------------------------------
revno: 3713
committer: Tran Chau <tran.hispvietnam@xxxxxxxxx>
branch nick: dhis2
timestamp: Tue 2011-05-24 09:10:33 +0700
message:
Fix bug: Don't save compulsory value of dataelements while adding / updating program-stage.
modified:
dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/java/org/hisp/dhis/patient/action/programstage/AddProgramStageAction.java
dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/java/org/hisp/dhis/patient/action/programstage/UpdateProgramStageAction.java
dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/addProgramStageForm.vm
dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/updateProgramStageForm.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-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/java/org/hisp/dhis/patient/action/programstage/AddProgramStageAction.java'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/java/org/hisp/dhis/patient/action/programstage/AddProgramStageAction.java 2011-05-23 06:10:58 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/java/org/hisp/dhis/patient/action/programstage/AddProgramStageAction.java 2011-05-24 02:10:33 +0000
@@ -118,11 +118,11 @@
this.minDaysFromStart = minDaysFromStart;
}
- private List<Integer> selectedList = new ArrayList<Integer>();
+ private List<Integer> selectedDataElementsValidator = new ArrayList<Integer>();
- public void setSelectedList( List<Integer> selectedList )
+ public void setSelectedDataElementsValidator( List<Integer> selectedDataElementsValidator )
{
- this.selectedList = selectedList;
+ this.selectedDataElementsValidator = selectedDataElementsValidator;
}
private List<Boolean> compulsories = new ArrayList<Boolean>();
@@ -154,9 +154,9 @@
programStageService.saveProgramStage( programStage );
- for ( int i = 0; i < this.selectedList.size(); i++ )
+ for ( int i = 0; i < this.selectedDataElementsValidator.size(); i++ )
{
- DataElement dataElement = dataElementService.getDataElement( selectedList.get( i ) );
+ DataElement dataElement = dataElementService.getDataElement( selectedDataElementsValidator.get( i ) );
ProgramStageDataElement programStageDataElement = new ProgramStageDataElement( programStage, dataElement,
this.compulsories.get( i ) );
programStageDataElementService.addProgramStageDataElement( programStageDataElement );
=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/java/org/hisp/dhis/patient/action/programstage/UpdateProgramStageAction.java'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/java/org/hisp/dhis/patient/action/programstage/UpdateProgramStageAction.java 2011-02-21 04:00:27 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/java/org/hisp/dhis/patient/action/programstage/UpdateProgramStageAction.java 2011-05-24 02:10:33 +0000
@@ -106,11 +106,11 @@
this.minDaysFromStart = minDaysFromStart;
}
- private List<Integer> selectedList = new ArrayList<Integer>();
+ private List<Integer> selectedDataElementsValidator = new ArrayList<Integer>();
- public void setSelectedList( List<Integer> selectedList )
+ public void setSelectedDataElementsValidator( List<Integer> selectedDataElementsValidator )
{
- this.selectedList = selectedList;
+ this.selectedDataElementsValidator = selectedDataElementsValidator;
}
private List<Boolean> compulsories = new ArrayList<Boolean>();
@@ -141,9 +141,9 @@
Set<ProgramStageDataElement> programStageDataElements = new HashSet<ProgramStageDataElement>( programStage
.getProgramStageDataElements() );
- for ( int i = 0; i < this.selectedList.size(); i++ )
+ for ( int i = 0; i < this.selectedDataElementsValidator.size(); i++ )
{
- DataElement dataElement = dataElementService.getDataElement( selectedList.get( i ) );
+ DataElement dataElement = dataElementService.getDataElement( selectedDataElementsValidator.get( i ) );
ProgramStageDataElement programStageDataElement = programStageDataElementService.get( programStage,
dataElement );
@@ -162,7 +162,6 @@
programStageDataElements.remove( programStageDataElement );
}
-
}
for ( ProgramStageDataElement psdeDelete : programStageDataElements )
=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/addProgramStageForm.vm'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/addProgramStageForm.vm 2011-04-28 08:15:18 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/addProgramStageForm.vm 2011-05-24 02:10:33 +0000
@@ -10,15 +10,20 @@
<script>
jQuery( function(){
- validation( 'addProgramStageForm', function( form ){ form.submit() }, function(){
+ validation( 'addProgramStageForm', function( form ){
+ form.submit();
+ }, function(){
selectedDataElementsValidator = jQuery( "#selectedDataElementsValidator" );
+ selectedDataElementsValidator.empty();
+
compulsories = jQuery( "#compulsories" );
- selectedDataElementsValidator.empty();
compulsories.empty();
- jQuery("#selectedList").find("tr").each( function( i, item ){
+
+ jQuery("#selectedList").find("tr").each( function( i, item ){
selectedDataElementsValidator.append( "<option value='" + item.id + "' selected='true'>" + item.id + "</option>" );
- compulsory = jQuery( item ).find( "input[name='compulsory']:first");
- compulsories.append( "<option value='" + compulsory.attr('checked') + "' selected='true'>" + compulsory.attr('checked') + "</option>" );
+ var compulsory = jQuery( item ).find( "input[name='compulsory']:first");
+ var checked = compulsory.attr('checked') ? true : false;
+ compulsories.append( "<option value='" + checked + "' selected='true'>" + checked + "</option>" );
});
});
@@ -29,7 +34,7 @@
<h3>$i18n.getString( "add_new_program_stage" )</h3>
-<form id="addProgramStageForm" name="addProgramStageForm" action="addProgramStage.action" method="post">
+<form id="addProgramStageForm" name="addProgramStageForm" action="addProgramStage.action" method="get">
<div style="display:inline">
<input type="hidden" id="id" name="id" value="$program.id"/>
@@ -97,15 +102,12 @@
<tbody id="selectedList"></tbody>
</table>
</div>
- <select id="selectedDataElementsValidator" name="selectedList" multiple="multiple" class="{validate:{required:true}}" style="display:none"></select>
- <select id="compulsories" name="compulsories" multiple="multiple" style="display:none"></select>
- </td>
-
+ </td>
</tr>
-
</tbody>
</table>
-
+<select id="selectedDataElementsValidator" name='selectedDataElementsValidator' multiple="multiple" class="{validate:{required:true}}" style="display:none"></select>
+<select id="compulsories" name='compulsories' multiple="multiple" style="display:none"></select>
<p>
<input type="submit" value="$i18n.getString( 'add' )" style="width:10em"/>
<input type="button" value="$i18n.getString( 'cancel' )" onclick="window.location.href='programStage.action'" style="width:10em"/>
=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/updateProgramStageForm.vm'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/updateProgramStageForm.vm 2011-04-28 08:15:18 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/updateProgramStageForm.vm 2011-05-24 02:10:33 +0000
@@ -13,15 +13,17 @@
form.submit() ;
}, function(){
selectedDataElementsValidator = jQuery( "#selectedDataElementsValidator" );
+ selectedDataElementsValidator.empty();
+
compulsories = jQuery( "#compulsories" );
- selectedDataElementsValidator.empty();
compulsories.empty();
+
jQuery("#selectedList").find("tr").each( function( i, item ){
selectedDataElementsValidator.append( "<option value='" + item.id + "' selected='true'>" + item.id + "</option>" );
var compulsory = jQuery( item ).find( "input[name='compulsory']:first");
- compulsories.append( "<option value='" + compulsory.attr('checked') + "' selected='true'>" + compulsory.attr('checked') + "</option>" );
+ var checked = compulsory.attr('checked') ? true : false;
+ compulsories.append( "<option value='" + checked + "' selected='true'>" + checked + "</option>" );
});
-
});
checkValueIsExist( "name", "validateProgramStage.action", {id:$programStage.id});
@@ -105,7 +107,7 @@
#foreach ( $programStageDataElement in $programStageDataElements )
<tr ondblclick="unSelectDataElement( this )" id="$programStageDataElement.dataElement.id" class="selected">
<td onclick="select(this)">$encoder.htmlEncode( $programStageDataElement.dataElement.name )</td>
- <td><input type="checkbox" name="compulsory" value="$programStageDataElement.dataElement.id"/></td>
+ <td><input type="checkbox" name="compulsory" value="$programStageDataElement.dataElement.id" #if($programStageDataElement.compulsory == true ) checked #end /></td>
</tr>
#end
</tbody>
@@ -115,8 +117,8 @@
</tr>
</tbody>
</table>
-<select id="selectedDataElementsValidator" name="selectedList" multiple="multiple" class="{validate:{required:true}}" style="display:none"> </select>
-<select id="compulsories" name="compulsories" multiple="multiple" style="display:none"></select>
+<select id="selectedDataElementsValidator" name='selectedDataElementsValidator' multiple="multiple" class="{validate:{required:true}}" style="display:none"> </select>
+<select id="compulsories" name='compulsories' multiple="multiple" style="display:none"></select>
<p>
<input type="submit" value="$i18n.getString( 'update' )" style="width:10em"/>
<input type="button" value="$i18n.getString( 'cancel' )" onclick="window.location.href='programStage.action'" style="width:10em"/>