=== 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 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" /> - + - - - - @@ -378,13 +379,14 @@ - + - + @@ -418,6 +420,9 @@ + + + + + + + - + - + \ 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} + + + + ../dhis-web-commons/ajax/jsonResponseSuccess.vm + + @@ -530,6 +537,13 @@ /dhis-web-maintenance-patient/dataEntryFormCode.vm + + + + ../dhis-web-commons/ajax/jsonResponseSuccess.vm + + === 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 = ""; 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 = ""; 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 = ''; @@ -102,7 +102,8 @@ + + $i18n.getString( 'auto_save_data_entry_forms' ) +
- + +   |  #if( !$existingDataEntryForms.isEmpty() ) @@ -118,9 +119,11 @@ #if( $!dataEntryForm )   |  - + #end -