dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #22267
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 10672: Fix bugs in Design custom registration form and small change this ui.
------------------------------------------------------------
revno: 10672
committer: Tran Chau <tran.hispvietnam@xxxxxxxxx>
branch nick: dhis2
timestamp: Wed 2013-04-24 11:07:59 +0700
message:
Fix bugs in Design custom registration form and small change this ui.
modified:
dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/java/org/hisp/dhis/patient/action/dataentryform/DelRegistrationFormAction.java
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/java/org/hisp/dhis/patient/action/dataentryform/ViewPatientRegistrationFormAction.java
dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/resources/META-INF/dhis/beans.xml
dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/javascript/patientRegistrationForm.js
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/patientRegistrationForm.vm
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/DelRegistrationFormAction.java'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/java/org/hisp/dhis/patient/action/dataentryform/DelRegistrationFormAction.java 2013-02-01 08:40:49 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/java/org/hisp/dhis/patient/action/dataentryform/DelRegistrationFormAction.java 2013-04-24 04:07:59 +0000
@@ -29,6 +29,8 @@
import org.hisp.dhis.patient.PatientRegistrationForm;
import org.hisp.dhis.patient.PatientRegistrationFormService;
+import org.hisp.dhis.program.Program;
+import org.hisp.dhis.program.ProgramService;
import com.opensymphony.xwork2.Action;
@@ -51,6 +53,13 @@
this.patientRegistrationFormService = patientRegistrationFormService;
}
+ private ProgramService programService;
+
+ public void setProgramService( ProgramService programService )
+ {
+ this.programService = programService;
+ }
+
// -------------------------------------------------------------------------
// Getters & setters
// -------------------------------------------------------------------------
@@ -61,7 +70,7 @@
{
this.id = id;
}
-
+
// -------------------------------------------------------------------------
// Action implementation
// -------------------------------------------------------------------------
@@ -69,10 +78,12 @@
public String execute()
throws Exception
{
- PatientRegistrationForm registrationForm = patientRegistrationFormService.getPatientRegistrationForm( id );
+ Program program = programService.getProgram( id );
+
+ PatientRegistrationForm registrationForm = patientRegistrationFormService.getPatientRegistrationForm( program );
patientRegistrationFormService.deletePatientRegistrationForm( registrationForm );
-
+
return SUCCESS;
}
}
=== 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-23 04:30:31 +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-24 04:07:59 +0000
@@ -76,7 +76,7 @@
// -------------------------------------------------------------------------
// Getters & Setters
// -------------------------------------------------------------------------
-
+
private String name;
public void setName( String name )
=== 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 2013-04-23 04:30:31 +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-24 04:07:59 +0000
@@ -94,15 +94,19 @@
public String execute()
throws Exception
{
+ name = name.trim();
+
DataEntryForm match = dataEntryFormService.getDataEntryFormByName( name );
- if ( match != null && (dataEntryFormId == null || match.getId() != dataEntryFormId.intValue()) )
+ if ( match != null && (dataEntryFormId == null || match.getId() != dataEntryFormId ) )
{
- message = i18n.getString( "name_exists" );
+ message = i18n.getString( "duplicate_names" );
return ERROR;
}
+ message = i18n.getString( "everything_is_ok" );
+
return SUCCESS;
}
}
=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/java/org/hisp/dhis/patient/action/dataentryform/ViewPatientRegistrationFormAction.java'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/java/org/hisp/dhis/patient/action/dataentryform/ViewPatientRegistrationFormAction.java 2013-04-18 06:45:36 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/java/org/hisp/dhis/patient/action/dataentryform/ViewPatientRegistrationFormAction.java 2013-04-24 04:07:59 +0000
@@ -102,14 +102,7 @@
// -------------------------------------------------------------------------
// Getters & Setters
// -------------------------------------------------------------------------
-
- private Integer id;
-
- public void setId( Integer id )
- {
- this.id = id;
- }
-
+
private Integer programId;
public void setProgramId( Integer programId )
@@ -170,14 +163,14 @@
programs.removeAll( programService.getPrograms( Program.SINGLE_EVENT_WITHOUT_REGISTRATION ) );
- if ( id != null )
+ if ( programId == null )
{
- registrationForm = patientRegistrationFormService.getPatientRegistrationForm( id );
+ registrationForm = patientRegistrationFormService.getCommonPatientRegistrationForm();
}
-
- if ( programId != null )
+ else
{
program = programService.getProgram( programId );
+ registrationForm = patientRegistrationFormService.getPatientRegistrationForm( program );
}
// ---------------------------------------------------------------------
@@ -203,7 +196,8 @@
flags = systemSettingManager.getFlags();
- autoSave = (Boolean) userSettingService.getUserSetting( UserSettingService.AUTO_SAVE_PATIENT_REGISTRATION_ENTRY_FORM, false );
+ autoSave = (Boolean) userSettingService.getUserSetting(
+ UserSettingService.AUTO_SAVE_PATIENT_REGISTRATION_ENTRY_FORM, false );
return SUCCESS;
}
=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/resources/META-INF/dhis/beans.xml'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/resources/META-INF/dhis/beans.xml 2013-04-18 06:45:36 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/resources/META-INF/dhis/beans.xml 2013-04-24 04:07:59 +0000
@@ -517,6 +517,9 @@
<property name="patientRegistrationFormService">
<ref bean="org.hisp.dhis.patient.PatientRegistrationFormService" />
</property>
+ <property name="programService">
+ <ref bean="org.hisp.dhis.program.ProgramService" />
+ </property>
</bean>
<bean
=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/javascript/patientRegistrationForm.js'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/javascript/patientRegistrationForm.js 2013-02-04 03:48:00 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/javascript/patientRegistrationForm.js 2013-04-24 04:07:59 +0000
@@ -1,22 +1,22 @@
-function addNewForm(){
- window.location.href='viewPatientRegistrationForm.action?programId=' + getFieldValue('programId');
+function addNewForm( programId ){
+ window.location.href='viewPatientRegistrationForm.action?programId=' + programId;
}
function updateNewForm( registrationFormId, programId ){
window.location.href='viewPatientRegistrationForm.action?programId=' + programId + '&id=' + registrationFormId;
}
-function removeRegistrationForm( registrationFormId, name, programId, programName )
+function removeRegistrationForm( programId, programName )
{
- removeItem( registrationFormId, name, i18n_confirm_delete, 'delRegistrationFormAction.action' );
-
- if(programId=='')
- {
- jQuery('#programId').prepend('<option value="" selected>' + i18n_please_select + '</option>');
- }
- else
- {
- jQuery('#programId').append('<option value="' + programId + '" selected>' + programName + '</option>');
+ var result = window.confirm( i18n_confirm_delete + "\n\n" + programName );
+
+ if ( result )
+ {
+ jQuery.postJSON("delRegistrationFormAction.action", {id:programId}
+ , function(json) {
+ hideById('active_' + programId);
+ showById('define_' + programId);
+ });
}
}
\ 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/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-23 04:30:31 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/javascript/viewPatientRegistationForm.js 2013-04-24 04:07:59 +0000
@@ -181,7 +181,6 @@
function validateFormOnclick()
{
- setFieldValue('requiredField','');
var requiredFields = getRequiredFields();
var violate = "";
if( Object.keys(requiredFields).length > 0 )
@@ -220,7 +219,6 @@
}
else
{
- setFieldValue('requiredField','');
var violate = '<h3>' + i18n_please_insert_all_required_fields + '<h3>';
for (var idx in requiredFields){
violate += " - " + requiredFields[idx] + '<br>';
@@ -365,17 +363,17 @@
timeOut = window.setTimeout( "validateRegistrationFormTimeout();", interval );
}
-function validateDataEntryForm()
+function validateDataEntryForm(form)
{
var name = getFieldValue('name');
if( name =='' || name.length<4 || name.length > 150 )
{
setHeaderDelayMessage( i18n_enter_a_name );
- return;
+ return false;
}
else if ( !validateForm() )
{
- return;
+ return false;
}
else
{
@@ -388,7 +386,14 @@
{
if ( json.response == 'success' )
{
- autoSavePatientRegistrationForm();
+ if( form != undefined)
+ {
+ form.submit();
+ }
+ else
+ {
+ autoSavePatientRegistrationForm();
+ }
}
else if ( json.response = 'error' )
{
@@ -414,3 +419,12 @@
setHeaderDelayMessage( i18n_save_success );
} );
}
+
+function deleteRegistrationFormFromView()
+{
+ var result = window.confirm( i18n_confirm_delete + '\n\n' + name );
+ if ( result )
+ {
+ window.location.href = 'delRegistrationEntryFormAction.action?id=' + id;
+ }
+}
=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/patientRegistrationForm.vm'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/patientRegistrationForm.vm 2013-03-07 05:15:13 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/patientRegistrationForm.vm 2013-04-24 04:07:59 +0000
@@ -8,24 +8,6 @@
#set($display = 'none')
#end
#end
- <tr>
- <td>
- <label>$i18n.getString('program')</label>
- <select name="programId" id="programId" style="width:20em" >
- #if( $display == 'block' )
- <option value=''>[$i18n.getString('All')]</option>
- #end
- #foreach($program in $programs)
- <option value='$program.id'>$encoder.htmlEncode($program.displayName)</option>
- #end
- </select>
- </td>
- #if($programs.size() > 0 || $display == 'block' )
- <td align="right">
- <input type="button" value="$i18n.getString( 'add_new' )" onclick="addNewForm();" style="width:70px;">
- </td>
- #end
- </tr>
<tr>
<td style="vertical-align:top" colspan='2'>
@@ -35,29 +17,42 @@
<col width="40">
<thead>
<tr>
- <th>$i18n.getString( "name" )</th>
<th>$i18n.getString( "program" )</th>
+ <th>$i18n.getString( "data_entry" )</th>
<th class="{sorter: false}">$i18n.getString( "operations" )</th>
</tr>
</thead>
<tbody class="list">
#foreach( $registrationForm in $registrationForms )
- <tr id="tr${registrationForm.id}">
- <td>$encoder.htmlEncode( $registrationForm.dataEntryForm.name )</td>
+ <tr id="tr${registrationForm.program.id}">
<td>
#if($registrationForm.program)
$encoder.htmlEncode( $registrationForm.program.name )
#else
$i18n.getString('all')
#end
+ </td>
+ <td>
+ $encoder.htmlEncode( $registrationForm.dataEntryForm.name )
</td>
<td style="text-align:center">
<a href="javascript:updateNewForm($registrationForm.id, '$!registrationForm.program.id')" title="$i18n.getString( 'edit' )"><img src="../images/edit.png" alt="$i18n.getString( 'edit' )"></a>
- <a href="javascript:removeRegistrationForm( '$registrationForm.id', '$encoder.jsEncode( $registrationForm.dataEntryForm.name )', '$!registrationForm.program.id', '$encoder.jsEncode( $!registrationForm.program.name )' )" title="$i18n.getString( "remove" )"><img src="../images/delete.png" alt="$i18n.getString( 'remove' )"></a>
+ <a href="javascript:removeRegistrationForm( '$registrationForm.program.id', '$encoder.jsEncode( $registrationForm.program.name )')" title="$i18n.getString( "remove" )"><img id='active_$registrationForm.program.id' src="../images/delete.png" alt="$i18n.getString( 'remove' )"></a>
+ <img id='define_$registrationForm.program.id' style='display:none;' src='../images/delete-denied.png' title='$i18n.getString("remove")'>
</td>
</tr>
#end
+ #foreach($program in $programs)
+ <tr id="tr${registrationForm.id}">
+ <td>$encoder.htmlEncode( $program.name )</td>
+ <td>[$i18n.getString('none')]</td>
+ <td style="text-align:center">
+ <a href="javascript:addNewForm($program.id)" title="$i18n.getString( 'design_data_entry_form' )"><img src="../images/add.png" alt="$i18n.getString( 'design_data_entry_form' )"></a>
+ <img src='../images/delete-denied.png' title='$i18n.getString("remove")'>
+ </td>
+ </tr>
+ #end
</tbody>
</table>
</td>
=== 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-23 04:30:31 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/viewPatientRegistationForm.vm 2013-04-24 04:07:59 +0000
@@ -11,8 +11,7 @@
{
validation( 'saveDataEntryForm', function( form )
{
- setInnerHTML( 'designTextarea' , jQuery("#designTextarea").ckeditorGet().getData() );
- form.submit();
+ validateDataEntryForm(form);
} );
jQuery('#designTextarea').ckeditor();
@@ -50,7 +49,7 @@
}
</style>
-<form id="saveDataEntryForm" name="saveDataEntryForm" action="savePatientRegistrationForm.action" method="post" onsubmit="return validateForm();">
+<form id="saveDataEntryForm" name="saveDataEntryForm" action="savePatientRegistrationForm.action" method="post">
<input type="hidden" name="programId" id="programId" value="$!program.id"/>
<input type="hidden" name="disableRegistrationFields" id="disableRegistrationFields" value="$!program.disableRegistrationFields"/>
@@ -82,7 +81,6 @@
<tr>
<th>
$i18n.getString( "design_patient_registration_form" )
- <input type='hidden' id='requiredField' name='requiredField' class="{validate:{required:true}}" title="$i18n.getString('please_insert_all_required_fields')">
</th>
</tr>
<tr>
@@ -106,7 +104,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" #if($!registrationForm.dataEntryForm) style='display:none;' #else onclick="deleteRegistrationForm( $registrationForm.id, '$registrationForm.dataEntryForm.name' )" #end />$i18n.getString( 'delete_this_form' )</button>
+ <button type="button" id="deleteButton" #if($!registrationForm.dataEntryForm) style='display:none;' #end onclick="deleteRegistrationFormFromView();" />$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>