← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 9087: Move Auto-save data entry form user-sertting to custom entry form editor.

 

------------------------------------------------------------
revno: 9087
committer: Tran Chau <tran.hispvietnam@xxxxxxxxx>
branch nick: dhis2
timestamp: Tue 2012-11-20 21:43:33 +0700
message:
  Move Auto-save data entry form user-sertting to custom entry form editor.
added:
  dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataset/src/main/java/org/hisp/dhis/dataset/action/dataentryform/SetAutoSaveSettingAction.java
modified:
  dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/settings/userGeneralSettings.vm
  dhis-2/dhis-web/dhis-web-commons/src/main/java/org/hisp/dhis/settings/user/action/SetGeneralSettingsAction.java
  dhis-2/dhis-web/dhis-web-commons/src/main/resources/i18n_global.properties
  dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataset/src/main/resources/META-INF/dhis/beans.xml
  dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataset/src/main/resources/org/hisp/dhis/dataset/i18n_module.properties
  dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataset/src/main/resources/struts.xml
  dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataset/src/main/webapp/dhis-web-maintenance-dataset/javascript/dataEntryForm.js
  dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataset/src/main/webapp/dhis-web-maintenance-dataset/javascript/viewDataEntryForm.js
  dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataset/src/main/webapp/dhis-web-maintenance-dataset/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-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/settings/userGeneralSettings.vm'
--- dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/settings/userGeneralSettings.vm	2012-10-16 13:26:20 +0000
+++ dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/settings/userGeneralSettings.vm	2012-11-20 14:43:33 +0000
@@ -5,7 +5,6 @@
 				currentLocale: getFieldValue( 'currentLocale' ),
 				currentLocaleDb: getFieldValue( 'currentLocaleDb' ),
 				currentStyle: getFieldValue( 'currentStyle' ),
-				autoSave: jQuery( '#autoSave' ).is(':checked' ),
                 messageEmailNotification: jQuery( '#messageEmailNotification' ).is(':checked' ),
                 messageSmsNotification: jQuery( '#messageSmsNotification' ).is(':checked' )
 			}, function ( json ) {
@@ -50,11 +49,6 @@
 </div>
 
 <div class="setting">
-	<input type="checkbox" id="autoSave" name="autoSave" #if( $autoSave ) checked="checked"#end/>
-	<label for="autoSave">$i18n.getString( "auto_save_data_entry_forms" )</label>
-</div>
-
-<div class="setting">
 	<input type="checkbox" id="messageEmailNotification" name="messageEmailNotification" #if( $messageEmailNotification ) checked="checked"#end/>
 	<label for="messageEmailNotification">$i18n.getString( "enable_message_email_notifications" )</label>
 </div>

=== modified file 'dhis-2/dhis-web/dhis-web-commons/src/main/java/org/hisp/dhis/settings/user/action/SetGeneralSettingsAction.java'
--- dhis-2/dhis-web/dhis-web-commons/src/main/java/org/hisp/dhis/settings/user/action/SetGeneralSettingsAction.java	2012-10-16 13:26:20 +0000
+++ dhis-2/dhis-web/dhis-web-commons/src/main/java/org/hisp/dhis/settings/user/action/SetGeneralSettingsAction.java	2012-11-20 14:43:33 +0000
@@ -27,7 +27,6 @@
  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 
-import static org.hisp.dhis.user.UserSettingService.AUTO_SAVE_DATA_ENTRY_FORM;
 import static org.hisp.dhis.user.UserSettingService.KEY_DB_LOCALE;
 import static org.hisp.dhis.user.UserSettingService.KEY_MESSAGE_EMAIL_NOTIFICATION;
 import static org.hisp.dhis.user.UserSettingService.KEY_MESSAGE_SMS_NOTIFICATION;
@@ -78,13 +77,6 @@
     // Input
     // -------------------------------------------------------------------------
 
-    private Boolean autoSave;
-
-    public void setAutoSave( Boolean autoSave )
-    {
-        this.autoSave = autoSave;
-    }
-
     private String currentLocale;
 
     public void setCurrentLocale( String locale )
@@ -147,9 +139,7 @@
             .trimToNull( currentLocaleDb ) ) );
 
         styleManager.setUserStyle( currentStyle );
-
-        userSettingService.saveUserSetting( AUTO_SAVE_DATA_ENTRY_FORM, autoSave );
-
+        
         userSettingService.saveUserSetting( KEY_MESSAGE_EMAIL_NOTIFICATION, messageEmailNotification );
 
         userSettingService.saveUserSetting( KEY_MESSAGE_SMS_NOTIFICATION, messageSmsNotification );

=== modified file 'dhis-2/dhis-web/dhis-web-commons/src/main/resources/i18n_global.properties'
--- dhis-2/dhis-web/dhis-web-commons/src/main/resources/i18n_global.properties	2012-11-14 19:23:18 +0000
+++ dhis-2/dhis-web/dhis-web-commons/src/main/resources/i18n_global.properties	2012-11-20 14:43:33 +0000
@@ -337,7 +337,6 @@
 db_language=Database language
 language=Interface language
 use_db_locale_no_translation=Use database locale / no translation
-auto_save_data_entry_forms=Auto-save data entry forms
 style=Style
 user_general_settings=User General Settings
 user_message_settings=User Message Settings

=== added file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataset/src/main/java/org/hisp/dhis/dataset/action/dataentryform/SetAutoSaveSettingAction.java'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataset/src/main/java/org/hisp/dhis/dataset/action/dataentryform/SetAutoSaveSettingAction.java	1970-01-01 00:00:00 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataset/src/main/java/org/hisp/dhis/dataset/action/dataentryform/SetAutoSaveSettingAction.java	2012-11-20 14:43:33 +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.dataset.action.dataentryform;
+
+import org.hisp.dhis.user.UserSettingService;
+
+import com.opensymphony.xwork2.Action;
+
+/**
+ * @author Chau Thu Tran
+ * 
+ * @version SetAutoSaveSettingAction.java 2:23:02 PM Nov 20, 2012 $
+ */
+public class SetAutoSaveSettingAction
+    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_DATA_ENTRY_FORM, autoSave );
+
+        return SUCCESS;
+    }
+
+}

=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataset/src/main/resources/META-INF/dhis/beans.xml'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataset/src/main/resources/META-INF/dhis/beans.xml	2012-09-24 21:54:54 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataset/src/main/resources/META-INF/dhis/beans.xml	2012-11-20 14:43:33 +0000
@@ -303,6 +303,13 @@
     </property>
   </bean>
 		
+  <bean id="org.hisp.dhis.dataset.action.dataentryform.SetAutoSaveSettingAction" class="org.hisp.dhis.dataset.action.dataentryform.SetAutoSaveSettingAction"
+    scope="prototype">
+    <property name="userSettingService">
+      <ref bean="org.hisp.dhis.user.UserSettingService" />
+    </property>
+  </bean>
+		
 	<!-- Compulsory data elements -->
 
   <bean id="org.hisp.dhis.dataset.action.compulsory.GetCompulsoryDataElementsAction" class="org.hisp.dhis.dataset.action.compulsory.GetCompulsoryDataElementsAction"

=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataset/src/main/resources/org/hisp/dhis/dataset/i18n_module.properties'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataset/src/main/resources/org/hisp/dhis/dataset/i18n_module.properties	2012-11-03 20:59:22 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataset/src/main/resources/org/hisp/dhis/dataset/i18n_module.properties	2012-11-20 14:43:33 +0000
@@ -105,4 +105,5 @@
 complete_allowed_only_if_validation_passes=Complete allowed only if validation passes
 notification_recipients=Complete notification recipients
 skip_offline=Skip Offline
-object_not_deleted_associated_by_objects=Object not deleted because it is associated by objects of type
\ No newline at end of file
+object_not_deleted_associated_by_objects=Object not deleted because it is associated by objects of type
+auto_save_data_entry_forms=Auto-save data entry forms
\ No newline at end of file

=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataset/src/main/resources/struts.xml'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataset/src/main/resources/struts.xml	2012-10-31 13:56:02 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataset/src/main/resources/struts.xml	2012-11-20 14:43:33 +0000
@@ -202,6 +202,10 @@
     <action name="getSelectedDataElements" class="org.hisp.dhis.dataset.action.dataentryform.GetSelectedDataElementsAction">
       <result name="success" type="velocity-xml">/dhis-web-maintenance-dataset/responseSelDataElementList.vm</result>
     </action>
+    
+    <action name="setAutoSaveSetting" class="org.hisp.dhis.dataset.action.dataentryform.SetAutoSaveSettingAction">
+      <result name="success" type="velocity-json">../dhis-web-commons/ajax/jsonResponseSuccess.vm</result>
+    </action>
 
 	<!-- Compulsory data elements -->
 

=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataset/src/main/webapp/dhis-web-maintenance-dataset/javascript/dataEntryForm.js'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataset/src/main/webapp/dhis-web-maintenance-dataset/javascript/dataEntryForm.js	2012-06-04 16:20:41 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataset/src/main/webapp/dhis-web-maintenance-dataset/javascript/dataEntryForm.js	2012-11-20 14:43:33 +0000
@@ -71,5 +71,5 @@
 function validateDataEntryFormTimeout()
 {
 	validateDataEntryForm( false );
-	window.setTimeout( "validateDataEntryFormTimeout();", 60000 );
+	timeOut = window.setTimeout( "validateDataEntryFormTimeout();", 60000 );
 }

=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataset/src/main/webapp/dhis-web-maintenance-dataset/javascript/viewDataEntryForm.js'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataset/src/main/webapp/dhis-web-maintenance-dataset/javascript/viewDataEntryForm.js	2012-09-18 11:29:01 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataset/src/main/webapp/dhis-web-maintenance-dataset/javascript/viewDataEntryForm.js	2012-11-20 14:43:33 +0000
@@ -2,6 +2,7 @@
 var currentDynamicElementCode = null;
 var currentCategoryComboId = null;
 var currentCategoryComboName = null;
+var timeOut;
 
 $( document ).ready( function() {
 	
@@ -194,9 +195,9 @@
 	
 	$("#dynamicElementSelector").dblclick(insertDynamicElement);
 	
-	if( autoSave == 'true' )
+	if( autoSave )
 	{
-		window.setTimeout( "validateDataEntryFormTimeout( false );", 60000 );
+		timeOut = window.setTimeout( "validateDataEntryFormTimeout( false );", 60000 );
 	}
 });
 
@@ -440,3 +441,18 @@
 
 	return result;
 }
+ 
+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-dataset/src/main/webapp/dhis-web-maintenance-dataset/viewDataEntryForm.vm'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataset/src/main/webapp/dhis-web-maintenance-dataset/viewDataEntryForm.vm	2012-09-19 08:34:26 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataset/src/main/webapp/dhis-web-maintenance-dataset/viewDataEntryForm.vm	2012-11-20 14:43:33 +0000
@@ -94,6 +94,7 @@
         <button type="button" id="cancelButton" onclick="window.location.href='dataSet.action'">$i18n.getString( 'cancel' )</button>&nbsp;&nbsp;<span style="color:#606060">|</span>&nbsp;
         <button type="button" id="insertDataElementsButton" >$i18n.getString( 'insert_data_elements' )</button>&nbsp;&nbsp;<span style="color:#606060">|</span>&nbsp;
         <button type="button" id="delete" onclick="removeDataEntryForm( '$dataSet.id', '$dataEntryForm.id', '$dataEntryForm.name' )">$i18n.getString( 'delete' )</button>
+		<input type="checkbox" id="autoSave" name="autoSave" #if($autoSave && $autoSave=="true") checked #end onchange="setAutoSaveSetting(this.checked)" />$i18n.getString( 'auto_save_data_entry_forms' )
       </td>          
 	  <script>
 		if(stat == "EDIT")