dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #16193
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 6092: Use jQuery methods insteads of Request object in dhis-web-caseentry.
------------------------------------------------------------
revno: 6092
committer: Tran Chau <tran.hispvietnam@xxxxxxxxx>
branch nick: dhis2
timestamp: Thu 2012-02-23 16:58:41 +0700
message:
Use jQuery methods insteads of Request object in dhis-web-caseentry.
modified:
dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/addRelationshipForm.vm
dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/javascript/commons.js
dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/javascript/entry.js
dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/javascript/form.js
dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/javascript/patient.js
dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/javascript/relationshipPatient.js
dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/javascript/report.js
dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/reportSelect.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-caseentry/src/main/webapp/dhis-web-caseentry/addRelationshipForm.vm'
--- dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/addRelationshipForm.vm 2012-02-01 09:10:08 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/addRelationshipForm.vm 2012-02-23 09:58:41 +0000
@@ -80,8 +80,8 @@
#end
</select>
<em title="$i18n.getString( 'required' )" class="required">*</em>
- <input type="text" id="searchText" name="searchText" maxlength="30" onchange="validateSearchPartner('$patient.id');"/>
- <input type="button" value="$i18n.getString( 'search' )" onclick="validateSearchPartner('$patient.id')"/>
+ <input type="text" id="searchText" name="searchText" maxlength="30" onchange="validateSearchPartner();"/>
+ <input type="button" value="$i18n.getString( 'search' )" onclick="validateSearchPartner()"/>
</td>
</tr>
<tr>
=== modified file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/javascript/commons.js'
--- dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/javascript/commons.js 2012-02-09 03:38:44 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/javascript/commons.js 2012-02-23 09:58:41 +0000
@@ -87,7 +87,7 @@
}
else if( $(this).attr('type') != 'button' )
{
- params += elementId + "="+ htmlEncode(jQuery(this).val()) + "&";
+ params += elementId + "="+ jQuery(this).val() + "&";
}
});
=== modified file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/javascript/entry.js'
--- dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/javascript/entry.js 2012-02-22 09:14:13 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/javascript/entry.js 2012-02-23 09:58:41 +0000
@@ -406,16 +406,22 @@
this.save = function()
{
- var params = 'dataElementId=' + dataElementId;
+ var params = 'dataElementId=' + dataElementId;
params += '&value=' + value;
params += '&providedByAnotherFacility=' + providedByAnotherFacility;
-
- var request = new Request();
- request.setCallbackSuccess( handleResponse );
- request.setCallbackError( handleHttpError );
- request.setResponseTypeXML( 'status' );
- request.sendAsPost( params );
- request.send( 'saveValue.action');
+
+ $.ajax({
+ type: "POST",
+ url: "saveValue.action",
+ data: params,
+ dataType: "xml",
+ success: function(result){
+ handleResponse (result);
+ },
+ error: function(request,status,errorThrown) {
+ handleHttpError (request);
+ }
+ });
};
function handleResponse( rootElement )
@@ -469,13 +475,19 @@
var params = 'dataElementId=' + dataElementId;
params += '&value=' + value;
params += '&providedByAnotherFacility=' + providedByAnotherFacility;
-
- var request = new Request();
- request.setCallbackSuccess( handleResponse );
- request.setCallbackError( handleHttpError );
- request.setResponseTypeXML( 'status' );
- request.sendAsPost( params );
- request.send( 'saveDateValue.action' );
+
+ $.ajax({
+ type: "POST",
+ url: "saveDateValue.action",
+ data: params,
+ dataType: "xml",
+ success: function(result){
+ handleResponse (result);
+ },
+ error: function(request,status,errorThrown) {
+ handleHttpError (request);
+ }
+ });
};
function handleResponse( rootElement )
@@ -551,12 +563,20 @@
this.save = function()
{
- var request = new Request();
- request.setCallbackSuccess( handleResponseCheckBox );
- request.setCallbackError( handleHttpErrorCheckBox );
- request.setResponseTypeXML( 'status' );
- request.send( 'saveProvidingFacility.action?dataElementId=' + dataElementId
- +'&providedByAnotherFacility=' + providedByAnotherFacility );
+ var params = 'dataElementId=' + dataElementId
+ + '&providedByAnotherFacility=' + providedByAnotherFacility ;
+ $.ajax({
+ type: "POST",
+ url: "saveProvidingFacility.action",
+ data: params,
+ dataType: "xml",
+ success: function(result){
+ handleResponse (result);
+ },
+ error: function(request,status,errorThrown) {
+ handleHttpError (request);
+ }
+ });
};
function handleResponseCheckBox( rootElement )
@@ -606,20 +626,26 @@
this.save = function()
{
- var request = new Request();
- request.setCallbackSuccess( handleResponse );
- request.setCallbackError( handleHttpError );
- request.setResponseTypeXML( 'status' );
-
var params = "executionDate=" + executionDate;
params += "&programStageId=" + programStageId;
- request.sendAsPost(params);
-
- request.send( "saveExecutionDate.action");
+
+ $.ajax({
+ type: "POST",
+ url: "saveExecutionDate.action",
+ data: params,
+ dataType: "xml",
+ success: function(result){
+ handleResponse (result);
+ },
+ error: function(request,status,errorThrown) {
+ handleHttpError (request);
+ }
+ });
};
function handleResponse( rootElement )
{
+ rootElement = rootElement.getElementsByTagName( 'message' )[0];
var codeElement = rootElement.getAttribute( 'type' );
if ( codeElement == 'success' )
{
=== modified file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/javascript/form.js'
--- dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/javascript/form.js 2012-02-06 02:56:02 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/javascript/form.js 2012-02-23 09:58:41 +0000
@@ -107,18 +107,16 @@
return (e)? e.which : null;
}
-function validateSearch( event )
-{
- var request = new Request();
- request.setResponseTypeXML( 'message' );
- request.setCallbackSuccess( searchValidationCompleted );
- request.sendAsPost('searchText=' + getFieldValue( 'searchText' ));
- request.send( 'validateSearch.action' );
+function validateSearch()
+{
+ $.post( 'validateSearch.action',{ searchText:getFieldValue( 'searchText' )}
+ , searchValidationCompleted );
}
function searchValidationCompleted( messageElement )
{
- var type = messageElement.getAttribute( 'type' );
+ messageElement = messageElement.getElementsByTagName( 'message' )[0];
+ var type = messageElement.getAttribute( 'type' );
var message = messageElement.firstChild.nodeValue;
if ( type == 'success' )
@@ -146,7 +144,6 @@
showWarningMessage( message );
}
}
-
// -------------------------------------------------------------------------
// Show Patient chart list
// -------------------------------------------------------------------------
=== modified file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/javascript/patient.js'
--- dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/javascript/patient.js 2012-02-16 07:54:34 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/javascript/patient.js 2012-02-23 09:58:41 +0000
@@ -776,11 +776,19 @@
this.save = function()
{
- var request = new Request();
- request.setCallbackSuccess( handleResponse );
- request.setCallbackError( handleHttpError );
- request.setResponseTypeXML( 'status' );
- request.send( 'saveDueDate.action?programStageInstanceId=' + programStageInstanceId + '&dueDate=' + dueDate );
+ var params = 'programStageInstanceId=' + programStageInstanceId + '&dueDate=' + dueDate;
+ $.ajax({
+ type: "POST",
+ url: "saveDueDate.action",
+ data: params,
+ dataType: "xml",
+ success: function(result){
+ handleResponse (result);
+ },
+ error: function(request,status,errorThrown) {
+ handleHttpError (request);
+ }
+ });
};
function handleResponse( rootElement )
=== modified file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/javascript/relationshipPatient.js'
--- dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/javascript/relationshipPatient.js 2011-12-28 06:21:57 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/javascript/relationshipPatient.js 2012-02-23 09:58:41 +0000
@@ -43,18 +43,21 @@
}
function validateAddRelationshipPatient()
-{
- var request = new Request();
- request.setResponseTypeXML( 'message' );
- request.setCallbackSuccess( addRelationshipPatientCompleted );
- request.sendAsPost( getParamsForDiv('addRelationshipDiv') );
- request.send( "validateAddRelationshipPatient.action" );
-
+{
+ $.ajax({
+ type: "POST",
+ url: "validateAddRelationshipPatient.action",
+ data: getParamsForDiv('addRelationshipDiv'),
+ dataType: "xml",
+ success:addRelationshipPatientCompleted
+ });
+
return false;
}
function addRelationshipPatientCompleted( messageElement )
{
+ messageElement = messageElement.getElementsByTagName( 'message' )[0];
var type = messageElement.getAttribute( 'type' );
var message = messageElement.firstChild.nodeValue;
@@ -84,25 +87,24 @@
{
jQuery('#loaderDiv').show();
$.ajax({
- type: "POST",
- url: 'addRelationshipPatient.action',
- data: getParamsForDiv('addRelationshipDiv'),
- success: function( json ) {
- hideById('addRelationshipDiv');
- showById('selectDiv');
- showById('searchPatientDiv');
- showById('listPatientDiv');
- jQuery('#loaderDiv').hide();
-
- if( getFieldValue( 'isShowPatientList' ) == 'false' )
- {
- showRelationshipList( getFieldValue('id') );
- }else
- {
- loadPatientList();
- }
- }
- });
+ type: "POST",
+ url: 'addRelationshipPatient.action',
+ data: getParamsForDiv('addRelationshipDiv'),
+ success: function( json ) {
+ hideById('addRelationshipDiv');
+ showById('selectDiv');
+ showById('searchPatientDiv');
+ showById('listPatientDiv');
+ jQuery('#loaderDiv').hide();
+
+ if( getFieldValue( 'isShowPatientList' ) == 'false' )
+ {
+ showRelationshipList( getFieldValue('id') );
+ }else
+ {
+ loadPatientList();
+ }
+ }});
return false;
}
@@ -197,25 +199,24 @@
}
}
-
-
//-----------------------------------------------------------------------------
// Search Relationship Partner
//-----------------------------------------------------------------------------
function validateSearchPartner()
-{
- var request = new Request();
- request.setResponseTypeXML( 'message' );
- request.setCallbackSuccess( searchValidationCompleted );
- request.sendAsPost(getParamsForDiv('relationshipSelectForm'));
- request.send( 'validateSearchRelationship.action' );
-
- return false;
+{
+ $.ajax({
+ url: 'validateSearchRelationship.action',
+ type:"POST",
+ data: getParamsForDiv('relationshipSelectForm'),
+ dataType: "xml",
+ success: searchValidationCompleted
+ });
}
function searchValidationCompleted( messageElement )
{
+ messageElement = messageElement.getElementsByTagName( 'message' )[0];
var type = messageElement.getAttribute( 'type' );
var message = messageElement.firstChild.nodeValue;
@@ -266,24 +267,27 @@
var relTypeId = relationshipTypeId.substr( 0, relationshipTypeId.indexOf(':') );
var relName = relationshipTypeId.substr( relationshipTypeId.indexOf(':') + 1, relationshipTypeId.length );
- var url = 'saveRelationship.action?' +
- 'patientId=' + getFieldValue('patientId') +
+ var params = 'patientId=' + getFieldValue('patientId') +
'&partnerId=' + partnerId +
'&relationshipTypeId=' + relTypeId +
'&relationshipName=' + relName ;
jQuery('#loaderDiv').show();
- var request = new Request();
- request.setResponseTypeXML( 'message' );
- request.setCallbackSuccess( addRelationshipCompleted );
- request.send( url );
+ $.ajax({
+ url: 'saveRelationship.action',
+ type:"POST",
+ data: params,
+ dataType: "xml",
+ success: addRelationshipCompleted
+ });
+
return false;
-
}
function addRelationshipCompleted( messageElement )
{
+ messageElement = messageElement.getElementsByTagName( 'message' )[0];
var type = messageElement.getAttribute( 'type' );
var message = messageElement.firstChild.nodeValue;
=== modified file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/javascript/report.js'
--- dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/javascript/report.js 2012-02-17 16:46:22 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/javascript/report.js 2012-02-23 09:58:41 +0000
@@ -4,57 +4,51 @@
{
showLoader();
setInnerHTML( 'contentDiv','' );
- jQuery.postJSON( "getPrograms.action",
- {
- },
- function( json )
- {
- setFieldValue( 'orgunitname', orgUnitNames[0] );
-
- clearListById('programId');
- if( json.programs.length == 0)
- {
- disable('programId');
- disable('startDate');
- disable('endDate');
- disable('generateBtn');
- }
- else
- {
- addOptionById( 'programId', "", i18n_please_select_a_program );
-
- for ( var i in json.programs )
- {
- addOptionById( 'programId', json.programs[i].id, json.programs[i].name );
- }
- enable('programId');
- enable('startDate');
- enable('endDate');
- enable('generateBtn');
- }
-
- hideLoader();
- });
+ jQuery.postJSON( "getPrograms.action",{},
+ function( json )
+ {
+ setFieldValue( 'orgunitname', orgUnitNames[0] );
+
+ clearListById('programId');
+ if( json.programs.length == 0)
+ {
+ disable('programId');
+ disable('startDate');
+ disable('endDate');
+ disable('generateBtn');
+ }
+ else
+ {
+ addOptionById( 'programId', "", i18n_please_select_a_program );
+
+ for ( var i in json.programs )
+ {
+ addOptionById( 'programId', json.programs[i].id, json.programs[i].name );
+ }
+ enable('programId');
+ enable('startDate');
+ enable('endDate');
+ enable('generateBtn');
+ }
+
+ hideLoader();
+ });
}
selection.setListenerFunction( organisationUnitSelected );
function validateAndGenerateReport()
{
- var url = 'validateReportParameters.action?' +
- 'startDate=' + getFieldValue( 'startDate' ) +
- '&endDate=' + getFieldValue( 'endDate' ) ;
-
- var request = new Request();
- request.setResponseTypeXML( 'message' );
- request.setCallbackSuccess( reportValidationCompleted );
- request.send( url );
-
- return false;
+ $.post( 'validateReportParameters.action',
+ {
+ startDate :getFieldValue( 'startDate' ) ,
+ endDate: getFieldValue( 'endDate' )
+ },reportValidationCompleted );
}
function reportValidationCompleted( messageElement )
-{
+{
+ messageElement = messageElement.getElementsByTagName( 'message' )[0];
var type = messageElement.getAttribute( 'type' );
var message = messageElement.firstChild.nodeValue;
hideById( 'contentDiv' );
=== modified file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/reportSelect.vm'
--- dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/reportSelect.vm 2012-02-17 17:00:18 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/reportSelect.vm 2012-02-23 09:58:41 +0000
@@ -7,7 +7,7 @@
</script>
<h3>$i18n.getString( "program_summary_report" ) #openHelp('program_summary_report')</h3>
-<form id="reportForm" name="reportForm" method="post" action="reportSelect.action">
+<form id="reportForm" name="reportForm" method="post">
<div class="inputCriteria" style="width:530px;height:160px;margin-bottom:20px;">