dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #21906
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 10486: Add auto-save functionality for designing case entry form.
------------------------------------------------------------
revno: 10486
committer: Tran Chau <tran.hispvietnam@xxxxxxxxx>
branch nick: dhis2
timestamp: Fri 2013-04-05 14:07:19 +0700
message:
Add auto-save functionality for designing case entry form.
added:
dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/java/org/hisp/dhis/patient/action/dataentryform/SetAutoSaveDataEntrySettingAction.java
modified:
dhis-2/dhis-api/src/main/java/org/hisp/dhis/user/UserSettingService.java
dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/java/org/hisp/dhis/patient/action/dataentryform/ViewDataEntryFormAction.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/resources/org/hisp/dhis/patient/i18n_module.properties
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/viewDataEntryForm.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/viewDataEntryForm.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-api/src/main/java/org/hisp/dhis/user/UserSettingService.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/user/UserSettingService.java 2013-01-16 05:49:06 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/user/UserSettingService.java 2013-04-05 07:07:19 +0000
@@ -51,6 +51,7 @@
final String KEY_MESSAGE_SMS_NOTIFICATION = "keyMessageSmsNotification";
final String KEY_DB_LOCALE = "keyLocaleUserSetting";
final String KEY_GENERATE_REPORT_INTERFACE = "keyGenerateReportInterface";
+ final String AUTO_SAVE_CASE_ENTRY_FORM = "autoSaveCaseEntryForm";
final List<Integer> DASHBOARD_CHARTS_TO_DISPLAY = Arrays.asList( 4, 6, 8 );
=== added file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/java/org/hisp/dhis/patient/action/dataentryform/SetAutoSaveDataEntrySettingAction.java'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/java/org/hisp/dhis/patient/action/dataentryform/SetAutoSaveDataEntrySettingAction.java 1970-01-01 00:00:00 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/java/org/hisp/dhis/patient/action/dataentryform/SetAutoSaveDataEntrySettingAction.java 2013-04-05 07:07:19 +0000
@@ -0,0 +1,76 @@
+/*
+ * Copyright (c) 2004-2009, University of Oslo
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ * * Redistributions of source code must retain the above copyright notice, this
+ * list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following disclaimer in the documentation
+ * and/or other materials provided with the distribution.
+ * * Neither the name of the HISP project nor the names of its contributors may
+ * be used to endorse or promote products derived from this software without
+ * specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
+ * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
+ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+package org.hisp.dhis.patient.action.dataentryform;
+
+import org.hisp.dhis.user.UserSettingService;
+
+import com.opensymphony.xwork2.Action;
+
+/**
+ * @author Chau Thu Tran
+ *
+ * @version SetAutoSaveDataEntrySettingAction.java 01:12:09 PM Apr 05, 2013 $
+ */
+public class SetAutoSaveDataEntrySettingAction
+ implements Action
+{
+ // -------------------------------------------------------------------------
+ // Dependencies
+ // -------------------------------------------------------------------------
+
+ private UserSettingService userSettingService;
+
+ public void setUserSettingService( UserSettingService userSettingService )
+ {
+ this.userSettingService = userSettingService;
+ }
+
+ // -------------------------------------------------------------------------
+ // Input / Output
+ // -------------------------------------------------------------------------
+
+ private boolean autoSave;
+
+ public void setAutoSave( boolean autoSave )
+ {
+ this.autoSave = autoSave;
+ }
+
+ // -------------------------------------------------------------------------
+ // Implementation Action
+ // -------------------------------------------------------------------------
+
+ public String execute()
+ throws Exception
+ {
+ userSettingService.saveUserSetting( UserSettingService.AUTO_SAVE_CASE_ENTRY_FORM, autoSave );
+
+ return SUCCESS;
+ }
+
+}
=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/java/org/hisp/dhis/patient/action/dataentryform/ViewDataEntryFormAction.java'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/java/org/hisp/dhis/patient/action/dataentryform/ViewDataEntryFormAction.java 2013-02-26 08:38:13 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/java/org/hisp/dhis/patient/action/dataentryform/ViewDataEntryFormAction.java 2013-04-05 07:07:19 +0000
@@ -41,6 +41,7 @@
import org.hisp.dhis.program.ProgramStageService;
import org.hisp.dhis.program.comparator.ProgramStageNameComparator;
import org.hisp.dhis.setting.SystemSettingManager;
+import org.hisp.dhis.user.UserSettingService;
import com.opensymphony.xwork2.Action;
@@ -92,6 +93,13 @@
this.systemSettingManager = systemSettingManager;
}
+ private UserSettingService userSettingService;
+
+ public void setUserSettingService( UserSettingService userSettingService )
+ {
+ this.userSettingService = userSettingService;
+ }
+
// -------------------------------------------------------------------------
// Getters & Setters
// -------------------------------------------------------------------------
@@ -152,6 +160,13 @@
return flags;
}
+ private boolean autoSave;
+
+ public boolean getAutoSave()
+ {
+ return autoSave;
+ }
+
// -------------------------------------------------------------------------
// Action implementation
// -------------------------------------------------------------------------
@@ -211,7 +226,9 @@
Collections.sort( dataElements, new IdentifiableObjectNameComparator() );
flags = systemSettingManager.getFlags();
-
+
+ autoSave = (Boolean) userSettingService.getUserSetting( UserSettingService.AUTO_SAVE_CASE_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-03-29 04:26:45 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/resources/META-INF/dhis/beans.xml 2013-04-05 07:07:19 +0000
@@ -163,8 +163,7 @@
ref="org.hisp.dhis.patient.PatientIdentifierTypeService" />
<property name="patientAttributeService"
ref="org.hisp.dhis.patient.PatientAttributeService" />
- <property name="currentUserService"
- ref="org.hisp.dhis.user.CurrentUserService" />
+ <property name="currentUserService" ref="org.hisp.dhis.user.CurrentUserService" />
</bean>
<bean id="org.hisp.dhis.patient.action.program.GetProgramListAction"
@@ -231,15 +230,17 @@
scope="prototype">
<property name="programService" ref="org.hisp.dhis.program.ProgramService" />
</bean>
-
- <bean id="org.hisp.dhis.patient.action.program.ShowProgramUserroleFormAction"
+
+ <bean
+ id="org.hisp.dhis.patient.action.program.ShowProgramUserroleFormAction"
class="org.hisp.dhis.patient.action.program.ShowProgramUserroleFormAction"
scope="prototype">
<property name="userService" ref="org.hisp.dhis.user.UserService" />
<property name="programService" ref="org.hisp.dhis.program.ProgramService" />
</bean>
-
- <bean id="org.hisp.dhis.patient.action.program.DefineProgramUserroleAction"
+
+ <bean
+ id="org.hisp.dhis.patient.action.program.DefineProgramUserroleAction"
class="org.hisp.dhis.patient.action.program.DefineProgramUserroleAction"
scope="prototype">
<property name="userService" ref="org.hisp.dhis.user.UserService" />
@@ -378,13 +379,14 @@
<property name="programStageSectionService"
ref="org.hisp.dhis.program.ProgramStageSectionService" />
</bean>
-
+
<bean
id="org.hisp.dhis.patient.action.programstage.GetProgramStageSectionListAction"
class="org.hisp.dhis.patient.action.programstage.GetProgramStageSectionListAction"
scope="prototype">
<property name="programStageService" ref="org.hisp.dhis.program.ProgramStageService" />
- <property name="programStageSectionService" ref="org.hisp.dhis.program.ProgramStageSectionService" />
+ <property name="programStageSectionService"
+ ref="org.hisp.dhis.program.ProgramStageSectionService" />
</bean>
<!-- Data Entry Form -->
@@ -418,6 +420,9 @@
<property name="systemSettingManager">
<ref bean="org.hisp.dhis.setting.SystemSettingManager" />
</property>
+ <property name="userSettingService">
+ <ref bean="org.hisp.dhis.user.UserSettingService" />
+ </property>
</bean>
<bean
@@ -484,6 +489,13 @@
</property>
</bean>
+ <bean
+ id="org.hisp.dhis.patient.action.dataentryform.SetAutoSaveDataEntrySettingAction"
+ class="org.hisp.dhis.patient.action.dataentryform.SetAutoSaveDataEntrySettingAction"
+ scope="prototype">
+ <property name="userSettingService" ref="org.hisp.dhis.user.UserSettingService" />
+ </bean>
+
<!-- PatientRegistrationForm -->
<bean
@@ -497,7 +509,7 @@
<ref bean="org.hisp.dhis.program.ProgramService" />
</property>
</bean>
-
+
<bean
id="org.hisp.dhis.patient.action.dataentryform.DelRegistrationFormAction"
class="org.hisp.dhis.patient.action.dataentryform.DelRegistrationFormAction"
@@ -1051,7 +1063,7 @@
<ref bean="org.hisp.dhis.user.CurrentUserService" />
</property>
<property name="notifier" ref="notifier" />
- <property name="aggregateConditionTask" ref="aggregateQueryBuilder"/>
+ <property name="aggregateConditionTask" ref="aggregateQueryBuilder" />
</bean>
</beans>
\ No newline at end of file
=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/resources/org/hisp/dhis/patient/i18n_module.properties'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/resources/org/hisp/dhis/patient/i18n_module.properties 2013-03-25 08:55:41 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/resources/org/hisp/dhis/patient/i18n_module.properties 2013-04-05 07:07:19 +0000
@@ -366,4 +366,7 @@
last_month = Last month
last_3_month = Last 3 months
last_6_month = Last 6 months
-last_12_month = Last 12 months
\ No newline at end of file
+last_12_month = Last 12 months
+auto_save_data_entry_forms = Auto save data entry forms
+save_and_close = Save and close
+delete_this_form = Delete this form
\ No newline at end of file
=== 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 2013-03-08 13:27:22 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/resources/struts.xml 2013-04-05 07:07:19 +0000
@@ -498,6 +498,13 @@
programStage.action?id=${programId}
</result>
</action>
+
+ <action name="autoSaveDataEntryForm"
+ class="org.hisp.dhis.patient.action.dataentryform.SaveDataEntryFormAction">
+ <result name="success" type="velocity-json">
+ ../dhis-web-commons/ajax/jsonResponseSuccess.vm
+ </result>
+ </action>
<action name="delDataEntryForm"
class="org.hisp.dhis.patient.action.dataentryform.DelDataEntryFormAction">
@@ -530,6 +537,13 @@
/dhis-web-maintenance-patient/dataEntryFormCode.vm
</result>
</action>
+
+ <action name="setAutoSaveDataEntrySetting"
+ class="org.hisp.dhis.patient.action.dataentryform.SetAutoSaveDataEntrySettingAction">
+ <result name="success" type="velocity-json">
+ ../dhis-web-commons/ajax/jsonResponseSuccess.vm
+ </result>
+ </action>
<!-- Patient Registration Form -->
=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/javascript/viewDataEntryForm.js'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/javascript/viewDataEntryForm.js 2013-04-05 02:48:22 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/javascript/viewDataEntryForm.js 2013-04-05 07:07:19 +0000
@@ -2,6 +2,7 @@
var dataElementSelector;
var otherProgramStageDataElements;
var existedDataEntry;
+var timeout;
jQuery(function(){
dataElementSelector = jQuery("#dataElementSelection").dialog({
@@ -33,6 +34,7 @@
$(":button").button();
$(":submit").button();
$("#saveButton").button("option", "icons", { primary: "ui-icon-disk" });
+ $("#saveAndCloseButton").button("option", "icons", { primary: "ui-icon-disk" });
$("#cancelButton").button("option", "icons", { primary: "ui-icon-cancel" });
$("#deleteButton").button("option", "icons", { primary: "ui-icon-trash" });
$("#insertButton").button("option", "icons", { primary: "ui-icon-plusthick" });
@@ -297,4 +299,63 @@
var html = "<img src=\"" + image + "\" title=\"" + $("#imageDialog :selected").text() + "\">";
var oEditor = $("#designTextarea").ckeditorGet();
oEditor.insertHtml( html );
+}
+
+// -------------------------------------------------------
+// Auto-save data entry form
+// -------------------------------------------------------
+
+function setAutoSaveDataEntrySetting(_autoSave)
+{
+ jQuery.postJSON("setAutoSaveDataEntrySetting.action", {autoSave:_autoSave}, function(json) {
+ autoSave = _autoSave;
+ if (_autoSave) {
+ window.setTimeout( "validateDataEntryFormTimeout( false );", 600 );
+ }
+ else{
+ window.clearTimeout(timeOut);
+ }
+ });
+}
+
+function validateDataEntryFormTimeout()
+{
+ validateDataEntryForm();
+ timeOut = window.setTimeout( "validateDataEntryFormTimeout();", 60000 );
+}
+
+function validateDataEntryForm()
+{
+ $.post( 'validateDataEntryForm.action',
+ {
+ name: getFieldValue('name'),
+ dataEntryFormId: getFieldValue('dataEntryFormId')
+ },
+ function( json )
+ {
+ if ( json.response == 'success' )
+ {
+ autoSaveDataEntryForm();
+ }
+ else if ( json.response = 'error' )
+ {
+ setHeaderDelayMessage( json.message );
+ }
+ } );
+}
+
+function autoSaveDataEntryForm()
+{
+ $.postUTF8( 'autoSaveDataEntryForm.action',
+ {
+ name: getFieldValue('name'),
+ designTextarea: jQuery("#designTextarea").ckeditorGet().getData(),
+ programId: getFieldValue('programId'),
+ programStageId: getFieldValue('programStageId'),
+ dataEntryFormId: getFieldValue('dataEntryFormId')
+ },
+ function( json )
+ {
+ setHeaderDelayMessage( i18n_save_success );
+ } );
}
\ 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-05 02:48:22 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/javascript/viewPatientRegistationForm.js 2013-04-05 07:07:19 +0000
@@ -298,4 +298,21 @@
var html = "<img src=\"" + image + "\" title=\"" + $("#imageDialog :selected").text() + "\">";
var oEditor = $("#designTextarea").ckeditorGet();
oEditor.insertHtml( html );
-}
\ No newline at end of file
+}
+
+// --------------------------------------------------------------------------
+// Auto-save
+// --------------------------------------------------------------------------
+
+function setAutoSaveSetting(_autoSave)
+{
+ jQuery.postJSON("setAutoSaveSetting.action", {autoSave:_autoSave}, function(json) {
+ autoSave = _autoSave;
+ if (_autoSave) {
+ window.setTimeout( "validateDataEntryFormTimeout( false );", 60000 );
+ }
+ else{
+ window.clearTimeout(timeOut);
+ }
+ });
+}
=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/viewDataEntryForm.vm'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/viewDataEntryForm.vm 2013-04-05 02:48:22 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/viewDataEntryForm.vm 2013-04-05 07:07:19 +0000
@@ -18,9 +18,9 @@
var i18n_dataelement_is_inserted = '$encoder.jsEscape( $i18n.getString( "dataelement_is_inserted" ) , "'" )';
var i18n_specify_dataelememt = '$encoder.jsEscape( $i18n.getString( "specify_dataelememt" ) , "'" )';
var i18n_choose_existing_dataentry ='$encoder.jsEscape( $i18n.getString( "choose_existing_dataentry" ) , "'" )';
- var i18n_dataelement = "$i18n.getString( 'dataelement' )";
+ var i18n_dataelement = '$encoder.jsEscape( $i18n.getString( "dataelement" ) , "'" )';
var i18n_dataelement_of_orther_program_stage = "$i18n.getString( 'dataelement_of_orther_program_stage' )";
-
+ var i18n_save_success = '$encoder.jsEscape( $i18n.getString( "save_success" ) , "'" )';
var previousName = '';
</script>
@@ -102,7 +102,8 @@
<table width="100%">
<tr>
<td>
- <button type="submit" id="saveButton">$i18n.getString( 'save' )</button>
+ <button type="button" id="saveButton" onclick="validateDataEntryForm();">$i18n.getString( 'save' )</button>
+ <button type="submit" id="saveAndCloseButton">$i18n.getString( 'save_and_close' )</button>
<button type="button" id="cancelButton" onclick="window.location='programStage.action?id=$!programStage.program.id'">$i18n.getString( 'cancel' )</button>
<span style="color:#606060">|</span>
#if( !$existingDataEntryForms.isEmpty() )
@@ -118,9 +119,11 @@
#if( $!dataEntryForm )
<span style="color:#606060">|</span>
- <button type="button" id="deleteButton" onclick="deleteDataEntryForm( $programStage.dataEntryForm.id, $programStage.id )">$i18n.getString( 'delete' )</button>
+ <button type="button" id="deleteButton" onclick="deleteDataEntryForm( $programStage.dataEntryForm.id, $programStage.id )">$i18n.getString( 'delete_this_form' )</button>
#end
- </td>
+
+ <input type="checkbox" id="autoSave" name="autoSave" #if($autoSave && $autoSave=="true") checked #end onchange="setAutoSaveDataEntrySetting(this.checked)" />$i18n.getString( 'auto_save_data_entry_forms' )
+ </td>
</tr>
</table>