dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #12098
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 3625: Load Beneficiary Attribute module by ajax ( patient module ) - Finish.
------------------------------------------------------------
revno: 3625
committer: Tran Chau <tran.hispvietnam@xxxxxxxxx>
branch nick: dhis2
timestamp: Mon 2011-05-16 16:29:20 +0700
message:
Load Beneficiary Attribute module by ajax ( patient module ) - Finish.
modified:
dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/addPatientAttributeForm.vm
dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/javascript/patientAttribute.js
dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/patientAttribute.vm
dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/updatePatientAttibuteForm.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/webapp/dhis-web-maintenance-patient/addPatientAttributeForm.vm'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/addPatientAttributeForm.vm 2011-05-16 06:44:39 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/addPatientAttributeForm.vm 2011-05-16 09:29:20 +0000
@@ -1,23 +1,30 @@
<script>
- var i18n_remove_option = '$encoder.jsEscape( $i18n.getString( "remove_option" ) , "'") ';
- var i18n_field_is_required = '$encoder.jsEscape( $i18n.getString( "field_is_required" ) , "'") ';
var isSubmit = true;
- jQuery("#addPatientAttributeForm").ready( function(){
- validation( 'addPatientAttributeForm', function(form){
- if( isSubmit && ATTRIBUTE_OPTION.checkOnSubmit() ) {
- form.submit(i18n_field_is_required);
+ jQuery(document).ready( function(){
+
+ validation( 'addPatientAttributeForm', function(form){
+ if( isSubmit )
+ {
+ addPatientAttribute();
}
}, function(){
- isSubmit = true;
+ isSubmit = ATTRIBUTE_OPTION.checkOnSubmit();
- var fields = $("#addPatientAttributeForm").serializeArray();
- jQuery.each(fields, function(i, field) {
- if( field.name.match("^attrOption")=='attrOption' && field.value == ""){
- setInnerHTML("attrMessage", i18n_field_is_required);
- isSubmit = false;
- }
- });
- });
+ if( isSubmit )
+ {
+ var fields = $("#addPatientAttributeForm").serializeArray();
+ jQuery.each(fields, function(i, field) {
+ if( field.name.match("^attrOption")=='attrOption' && field.value == ""){
+ setInnerHTML( "attrMessage", i18n_field_is_required );
+ isSubmit = false;
+ }
+ });
+
+ }else
+ {
+ setInnerHTML( "attrMessage", i18n_at_least_2_option );
+ }
+ });
jQuery("#attributeComboRow").hide();
@@ -29,7 +36,7 @@
<input type="button" value="$i18n.getString( 'back' )" onclick="javascript:onClickBackBtn();" style="width:10em">
<h3>$i18n.getString( "add_new_patient_attribute" )</h3>
-<form id="addPatientAttributeForm" method="post">
+<form id="addPatientAttributeForm" name='addPatientAttributeForm' action='addPatientAttribute.action' method="post">
<table id="attrTable">
<thead>
@@ -103,7 +110,7 @@
</tbody>
</table>
<p>
- <input type="button" value="$i18n.getString( 'add' )" style="width:10em" onclick="addPatientAttribute();"/>
+ <input type="submit" value="$i18n.getString( 'add' )" style="width:10em" />
</p>
</form>
=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/javascript/patientAttribute.js'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/javascript/patientAttribute.js 2011-05-16 06:44:39 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/javascript/patientAttribute.js 2011-05-16 09:29:20 +0000
@@ -62,7 +62,7 @@
});
if( $("input","#attrOptionContainer").length < 2)
{
- alert(i118_at_least_2_option);
+ //alert(i18n_at_least_2_option);
return false;
}else return true;
}
@@ -97,7 +97,7 @@
},
createInput : function ()
{
- return "<tr><td><input type='text' name='attrOptions' style='width:28em'/><a href='#' style='text-decoration: none; margin-left:0.5em;' title='"+i18n_remove_option+"' onClick='ATTRIBUTE_OPTION.remove(this,null)'>[ - ]</a></td></tr>";
+ return "<tr><td><input type='text' id='attrOptions' name='attrOptions' style='width:28em'/><a href='#' style='text-decoration: none; margin-left:0.5em;' title='"+i18n_remove_option+"' onClick='ATTRIBUTE_OPTION.remove(this,null)'>[ - ]</a></td></tr>";
}
}
@@ -123,7 +123,7 @@
$.ajax({
type: "POST",
url: 'addPatientAttribute.action',
- data: getParamsForDiv('editPatientAttributeForm'),
+ data: getParamsForDiv('addPatientAttributeForm'),
success: function( json ) {
if( json.response == 'success')
{
@@ -159,15 +159,18 @@
$.ajax({
type: "POST",
url: 'updatePatientAttribute.action',
- data: getParamsForDiv('editPatientAttributeForm'),
+ data: getParamsForDiv('updatePatientAttributeForm'),
+ dataType: 'json',
success: function( json ) {
if( json.response == 'success')
{
onClickBackBtn();
}
}
- });
- return false;
+ });
+
+ return false;
+
}
// ------------------------------------------------------------------
=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/patientAttribute.vm'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/patientAttribute.vm 2011-05-16 06:44:39 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/patientAttribute.vm 2011-05-16 09:29:20 +0000
@@ -22,4 +22,8 @@
var i18n_combo = '$encoder.jsEscape( $i18n.getString( "combo" ) , "'")';
var i18n_processing = '$encoder.jsEscape( $i18n.getString( "processing" ) , "'")';
var i18n_done = '$encoder.jsEscape( $i18n.getString( "done" ) , "'")';
+
+ var i18n_remove_option = '$encoder.jsEscape( $i18n.getString( "remove_option" ) , "'") ';
+ var i18n_at_least_2_option = '$encoder.jsEscape( $i18n.getString( "at_least_2_option" ) , "'") ';
+ var i18n_field_is_required = '$encoder.jsEscape( $i18n.getString( "field_is_required" ) , "'") ';
</script>
=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/updatePatientAttibuteForm.vm'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/updatePatientAttibuteForm.vm 2011-05-16 08:08:41 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/updatePatientAttibuteForm.vm 2011-05-16 09:29:20 +0000
@@ -1,25 +1,30 @@
<script>
- var i18n_remove_option = '$encoder.jsEscape( $i18n.getString( "remove_option" ) , "'") ';
- var i118_at_least_2_option = '$encoder.jsEscape( $i18n.getString( "at_least_2_option" ) , "'") ';
- var i18n_field_is_required = '$encoder.jsEscape( $i18n.getString( "field_is_required" ) , "'") ';
var isSubmit = true;
jQuery(document).ready( function(){
validation( 'updatePatientAttributeForm', function(form){
- if( isSubmit && ATTRIBUTE_OPTION.checkOnSubmit() ) {
- form.submit(i18n_field_is_required);
+ if( isSubmit )
+ {
+ updatePatientAttribute();
}
}, function(){
- isSubmit = true;
+ isSubmit = ATTRIBUTE_OPTION.checkOnSubmit();
- var fields = $("#addPatientAttributeForm").serializeArray();
- jQuery.each(fields, function(i, field) {
- if( field.name.match("^attrOption")=='attrOption' && field.value == ""){
- setInnerHTML("attrMessage", i18n_field_is_required);
- isSubmit = false;
- }
- });
+ if( isSubmit )
+ {
+ var fields = $("#addPatientAttributeForm").serializeArray();
+ jQuery.each(fields, function(i, field) {
+ if( field.name.match("^attrOption")=='attrOption' && field.value == ""){
+ setInnerHTML( "attrMessage", i18n_field_is_required );
+ isSubmit = false;
+ }
+ });
+
+ }else
+ {
+ setInnerHTML( "attrMessage", i18n_at_least_2_option );
+ }
});
checkValueIsExist( "name", "validatePatientAttribute.action", {id:getFieldValue('id')});
@@ -31,7 +36,7 @@
<h3>$i18n.getString( "update_patient_attribute" )</h3>
-<form id="updatePatientAttributeForm" name="updatePatientAttributeForm" action='#' method="post" onsubmit='return updatePatientAttribute();'>
+<form id="updatePatientAttributeForm" name="updatePatientAttributeForm" action='updatePatientAttribute.action' method="post" >
<div style="display:inline">
<input type="hidden" id="id" name="id" value="$patientAttribute.id">