dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #11820
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 3469: Used ajax to reload list of "Define validation Data Element Associations" instead of reloading th...
------------------------------------------------------------
revno: 3469
committer: Hieu <hieu.hispvietnam@xxxxxxxxx>
branch nick: dhis2
timestamp: Tue 2011-04-26 16:00:27 +0700
message:
Used ajax to reload list of "Define validation Data Element Associations" instead of reloading the whole page.
added:
dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/loadValidationDEAssociation.vm
modified:
dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/java/org/hisp/dhis/patient/action/validation/AddProgramStageDEValidationAction.java
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/webapp/dhis-web-maintenance-patient/javascript/programStageDEValidation.js
dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/validationDEAssociations.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/validation/AddProgramStageDEValidationAction.java'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/java/org/hisp/dhis/patient/action/validation/AddProgramStageDEValidationAction.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/validation/AddProgramStageDEValidationAction.java 2011-04-26 09:00:27 +0000
@@ -73,6 +73,8 @@
private Integer rightDataElementId;
+ private ProgramStageDataElementValidation validation;
+
// -------------------------------------------------------------------------
// Setters
// -------------------------------------------------------------------------
@@ -128,6 +130,15 @@
}
// -------------------------------------------------------------------------
+ // Output
+ // -------------------------------------------------------------------------
+
+ public ProgramStageDataElementValidation getValidation()
+ {
+ return validation;
+ }
+
+ // -------------------------------------------------------------------------
// Action Implementation
// -------------------------------------------------------------------------
@@ -135,7 +146,7 @@
public String execute()
throws Exception
{
- ProgramStageDataElementValidation validation = new ProgramStageDataElementValidation();
+ validation = new ProgramStageDataElementValidation();
validation.setDescription( description );
@@ -178,10 +189,12 @@
// ---------------------------------------------------------------------
// Operator
// ---------------------------------------------------------------------
-
+
validation.setOperator( operator );
- validationService.saveProgramStageDataElementValidation( validation );
+ int id = validationService.saveProgramStageDataElementValidation( validation );
+
+ validation = validationService.getProgramStageDataElementValidation( id );
return SUCCESS;
}
=== 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 2011-04-26 02:06:38 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/resources/struts.xml 2011-04-26 09:00:27 +0000
@@ -1179,8 +1179,8 @@
<action name="addProgramStageDEValidation"
class="org.hisp.dhis.patient.action.validation.AddProgramStageDEValidationAction">
- <result name="success" type="velocity-xml">
- /dhis-web-maintenance-patient/responseSuccess.vm</result>
+ <result name="success" type="velocity">
+ /dhis-web-maintenance-patient/loadValidationDEAssociation.vm</result>
</action>
<action name="removeProgramStageDEValidation"
=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/javascript/programStageDEValidation.js'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/javascript/programStageDEValidation.js 2010-05-12 02:15:26 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/javascript/programStageDEValidation.js 2011-04-26 09:00:27 +0000
@@ -31,21 +31,24 @@
function addProgramStageDEValidation()
{
- var params = 'description=' + getFieldValue( 'description' );
- params += '&leftProgramStageId=' + getFieldValue( 'leftProgramStageId' );
- params += '&leftDataElementId=' + getFieldValue( 'leftDataElementId' );
- params += '&operator=' + getFieldValue( 'operator' );
- params += '&rightProgramStageId=' + getFieldValue( 'rightProgramStageId' );
- params += '&rightDataElementId=' + getFieldValue( 'rightDataElementId' );
-
- var request = new Request();
- request.setResponseTypeXML( 'xmlObject' );
- request.setCallbackSuccess( function(data){
- window.location.reload();
- } );
-
- request.sendAsPost( params );
- request.send( "addProgramStageDEValidation.action");
+ jQuery.post( "addProgramStageDEValidation.action",
+ {
+ 'programId': getFieldValue( 'programId' ),
+ 'description': getFieldValue( 'description' ),
+ 'leftProgramStageId': getFieldValue( 'leftProgramStageId' ),
+ 'leftDataElementId': getFieldValue( 'leftDataElementId' ),
+ 'operator': getFieldValue( 'operator' ),
+ 'rightProgramStageId': getFieldValue( 'rightProgramStageId' ),
+ 'rightDataElementId': getFieldValue( 'rightDataElementId' )
+ },
+ function(data){
+ jQuery( "table.listTable tbody#list tr:last" ).after( data );
+ 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");
+ }
+ );
}
// -----------------------------------------------------------------------------
=== added file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/loadValidationDEAssociation.vm'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/loadValidationDEAssociation.vm 1970-01-01 00:00:00 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/loadValidationDEAssociation.vm 2011-04-26 09:00:27 +0000
@@ -0,0 +1,12 @@
+<tr id="tr${validation.id}">
+ <td>$validation.description</td>
+ <td>[$validation.leftProgramStageDataElement.programStage.name.$validation.leftProgramStageDataElement.dataElement.name]
+ #if($validation.operator == '-1') <
+ #elseif($validation.operator == '0') =
+ #else >
+ #end
+ [$validation.rightProgramStageDataElement.programStage.name.$validation.rightProgramStageDataElement.dataElement.name]</td>
+ <td>
+ <a href="javascript:removeProgramStageDEValidation( '$validation.id', '$encoder.htmlEncode( $validation.description )' )" title="$i18n.getString( 'remove' )"><img src="../images/delete.png" alt="$i18n.getString( 'remove' )"></a>
+ </td>
+</tr>
\ No newline at end of file
=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/validationDEAssociations.vm'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/validationDEAssociations.vm 2010-05-14 04:13:36 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/validationDEAssociations.vm 2011-04-26 09:00:27 +0000
@@ -66,20 +66,9 @@
</tr>
</thead>
<tbody id="list">
- #foreach($validation in $validations)
- <tr id="tr${validation.id}">
- <td>$validation.description</td>
- <td>[$validation.leftProgramStageDataElement.programStage.name.$validation.leftProgramStageDataElement.dataElement.name]
- #if($validation.operator == '-1') <
- #elseif($validation.operator == '0') =
- #else >
+ #foreach($validation in $validations)
+ #parse( "/dhis-web-maintenance-patient/loadValidationDEAssociation.vm" )
#end
- [$validation.rightProgramStageDataElement.programStage.name.$validation.rightProgramStageDataElement.dataElement.name]</td>
- <td>
- <a href="javascript:removeProgramStageDEValidation( '$validation.id', '$encoder.jsEncode( $validation.description )' )" title="$i18n.getString( "remove" )"><img src="../images/delete.png" alt="$i18n.getString( "remove" )"></a>
- </td>
- </tr>
- #end
</tbody>
</table>