dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #22253
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 10670: Improve and change validate functions when to add/update custom registration form.
------------------------------------------------------------
revno: 10670
committer: Tran Chau <tran.hispvietnam@xxxxxxxxx>
branch nick: dhis2
timestamp: Tue 2013-04-23 11:30:31 +0700
message:
Improve and change validate functions when to add/update custom registration form.
modified:
dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/java/org/hisp/dhis/patient/action/dataentryform/SavePatientRegistrationFormAction.java
dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/java/org/hisp/dhis/patient/action/dataentryform/ValidateDataEntryFormAction.java
dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/javascript/viewPatientRegistationForm.js
dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/viewPatientRegistationForm.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/dataentryform/SavePatientRegistrationFormAction.java'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/java/org/hisp/dhis/patient/action/dataentryform/SavePatientRegistrationFormAction.java 2013-04-08 04:21:21 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/java/org/hisp/dhis/patient/action/dataentryform/SavePatientRegistrationFormAction.java 2013-04-23 04:30:31 +0000
@@ -91,13 +91,6 @@
this.designTextarea = designTextarea;
}
- private Integer id;
-
- public void setId( Integer id )
- {
- this.id = id;
- }
-
private Integer programId;
public void setProgramId( Integer programId )
@@ -121,9 +114,16 @@
{
PatientRegistrationForm registrationForm = null;
- if ( id != null )
- {
- registrationForm = patientRegistrationFormService.getPatientRegistrationForm( id );
+ Program program = null;
+
+ if ( programId == null )
+ {
+ registrationForm = patientRegistrationFormService.getCommonPatientRegistrationForm();
+ }
+ else
+ {
+ program = programService.getProgram( programId );
+ registrationForm = patientRegistrationFormService.getPatientRegistrationForm( program );
}
// ---------------------------------------------------------------------
@@ -137,7 +137,6 @@
registrationForm.setDataEntryForm( dataEntryForm );
if ( programId != null )
{
- Program program = programService.getProgram( programId );
registrationForm.setProgram( program );
}
patientRegistrationFormService.savePatientRegistrationForm( registrationForm );
@@ -153,7 +152,7 @@
Integer dataEntryFormId = dataEntryFormService.getDataEntryFormByName( name ).getId();
message = dataEntryFormId + "";
-
+
return SUCCESS;
}
=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/java/org/hisp/dhis/patient/action/dataentryform/ValidateDataEntryFormAction.java'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/java/org/hisp/dhis/patient/action/dataentryform/ValidateDataEntryFormAction.java 2012-01-11 05:31:53 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/java/org/hisp/dhis/patient/action/dataentryform/ValidateDataEntryFormAction.java 2013-04-23 04:30:31 +0000
@@ -98,7 +98,7 @@
if ( match != null && (dataEntryFormId == null || match.getId() != dataEntryFormId.intValue()) )
{
- message = i18n.getString( "duplicate_names" );
+ message = i18n.getString( "name_exists" );
return ERROR;
}
=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/javascript/viewPatientRegistationForm.js'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/javascript/viewPatientRegistationForm.js 2013-04-18 06:45:36 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/javascript/viewPatientRegistationForm.js 2013-04-23 04:30:31 +0000
@@ -121,7 +121,7 @@
function getRequiredFields()
{
var requiredFields = {};
- if( getFieldValue("disableRegistrationFields")=='false' )
+ if( getFieldValue("disableRegistrationFields")!='true' )
{
requiredFields['fixedattributeid=registrationDate'] = i18n_registration_date;
requiredFields['fixedattributeid=fullName'] = i18n_full_name;
@@ -210,7 +210,6 @@
function validateForm( checkViolate )
{
- var result = false;
requiredFields = getRequiredFields();
if( Object.keys(requiredFields).length > 0 )
@@ -218,7 +217,6 @@
if ( byId('autoSave').checked )
{
setHeaderMessage( i18n_save_unsuccess_please_insert_all_required_fields );
- return;
}
else
{
@@ -240,20 +238,11 @@
});
}
-
return false;
}
else
{
- setFieldValue('requiredField','everything_is_ok');
- setInnerHTML( 'designTextarea' , jQuery("#designTextarea").ckeditorGet().getData() );
- if(isSave='true'){
- autoSavePatientRegistrationForm();
- }
- else
- {
- byId('saveDataEntryForm').submit();
- }
+ return true;
}
}
@@ -382,6 +371,7 @@
if( name =='' || name.length<4 || name.length > 150 )
{
setHeaderDelayMessage( i18n_enter_a_name );
+ return;
}
else if ( !validateForm() )
{
@@ -389,7 +379,7 @@
}
else
{
- $.post( 'validateDataEntryForm.action',
+ $.postUTF8( 'validateDataEntryForm.action',
{
name: getFieldValue('name'),
dataEntryFormId: getFieldValue('dataEntryFormId')
=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/viewPatientRegistationForm.vm'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/viewPatientRegistationForm.vm 2013-04-18 06:45:36 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/viewPatientRegistationForm.vm 2013-04-23 04:30:31 +0000
@@ -20,7 +20,6 @@
jQuery("#designTextarea").ckeditorGet().setData('$encoder.jsEscape( $!registrationForm.dataEntryForm.htmlCode, "'" )');
#end
- checkValueIsExist( "name", "validateDataEntryForm.action", { dataEntryFormId: getFieldValue('dataEntryFormId') } );
});
var i18n_dataelement_is_inserted = '$encoder.jsEscape( $i18n.getString( "dataelement_is_inserted" ) , "'" )';
@@ -53,9 +52,8 @@
<form id="saveDataEntryForm" name="saveDataEntryForm" action="savePatientRegistrationForm.action" method="post" onsubmit="return validateForm();">
-<input type="hidden" name="id" id="id" value="$!registrationForm.id"/>
<input type="hidden" name="programId" id="programId" value="$!program.id"/>
-<input type="hidden" name="disableRegistrationFields" id="disableRegistrationFields" value="$program.disableRegistrationFields"/>
+<input type="hidden" name="disableRegistrationFields" id="disableRegistrationFields" value="$!program.disableRegistrationFields"/>
<input type="hidden" name="dataEntryFormId" id="dataEntryFormId" value="$!registrationForm.dataEntryForm.id"/>
<h3>$i18n.getString( "add_patient_registration_form" )</h3>
@@ -72,7 +70,7 @@
<label>$i18n.getString( "name" ) <em title="$i18n.getString( "required" )" class="required">*</em></label>
</td>
<td>
- <input type="text" id="name" value="$!registrationForm.dataEntryForm.name" name="name" class="{validate:{required:true,rangelength:[4,150],alphanumericwithbasicpuncspaces:true,firstletteralphabet:false}}" style="width:30em;">
+ <input type="text" id="name" value="$!registrationForm.dataEntryForm.name" name="name" class="{validate:{required:true,rangelength:[4,150],alphanumericwithbasicpuncspaces:true,firstletteralphabet:false}}" style="width:30em;" >
</td>
</tr>
<tr>
@@ -108,7 +106,7 @@
<button type="button" id="propertiesButton" onclick="openPropertiesSelector()"/>$i18n.getString( 'insert_properties' )</button>
<button type="button" id="insertImagesButton">$i18n.getString( 'insert_images' )</button>
<span style="color:#606060">|</span>
- <button type="button" id="deleteButton" onclick="deleteRegistrationForm( $registrationForm.id, '$registrationForm.dataEntryForm.name' )" #if($!registrationForm.dataEntryForm) style='display:none;' #end />$i18n.getString( 'delete_this_form' )</button>
+ <button type="button" id="deleteButton" #if($!registrationForm.dataEntryForm) style='display:none;' #else onclick="deleteRegistrationForm( $registrationForm.id, '$registrationForm.dataEntryForm.name' )" #end />$i18n.getString( 'delete_this_form' )</button>
<input type="checkbox" id="autoSave" name="autoSave" value='$!autoSave' #if($autoSave && $autoSave=="true") checked #end onchange="setAutoSaveRegistrationSetting(this.checked)" />$i18n.getString( 'auto_save_patient_registration_forms' )
</td>
</tr>
@@ -247,6 +245,7 @@
var i18n_confirm_delete = '$encoder.jsEscape( $i18n.getString( "confirm_delete_patient_registration_form" ) , "'" )';
var i18n_save_unsuccess_please_insert_all_required_fields = '$encoder.jsEscape( $i18n.getString( "save_unsuccess" ) , "'" )' + '. ' + '$encoder.jsEscape( $i18n.getString( "please_insert_all_required_fields" ) , "'" )';
var i18n_validate_success = '$encoder.jsEscape( $i18n.getString( "validate_success" ) , "'" )';
+ var i18n_name_exists = '$encoder.jsEscape( $i18n.getString( "name_exists" ) , "'" )';
jQuery(document).ready( function(){
openPropertiesSelector();