← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 3714: local vn - Applied file patch from Hieu. Fixed bug upload for excel template list.

 

------------------------------------------------------------
revno: 3714
committer: catakim <catakim@kavo-PC>
branch nick: dhis2_May
timestamp: Tue 2011-05-24 10:49:29 +0700
message:
  local vn - Applied file patch from Hieu. Fixed bug upload for excel template list.
modified:
  local/vn/dhis-web-excel-reporting/src/main/java/org/hisp/dhis/reportexcel/filemanager/action/ValidateUploadExcelFile.java
  local/vn/dhis-web-excel-reporting/src/main/webapp/dhis-web-excel-reporting/excelTemplateList.vm
  local/vn/dhis-web-excel-reporting/src/main/webapp/dhis-web-excel-reporting/javascript/exceltemplate.js


--
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 'local/vn/dhis-web-excel-reporting/src/main/java/org/hisp/dhis/reportexcel/filemanager/action/ValidateUploadExcelFile.java'
--- local/vn/dhis-web-excel-reporting/src/main/java/org/hisp/dhis/reportexcel/filemanager/action/ValidateUploadExcelFile.java	2011-05-13 09:38:17 +0000
+++ local/vn/dhis-web-excel-reporting/src/main/java/org/hisp/dhis/reportexcel/filemanager/action/ValidateUploadExcelFile.java	2011-05-24 03:49:29 +0000
@@ -156,7 +156,7 @@
 
         File output = new File( templateDirectoryConfig, uploadFileName );
 
-        if ( output.exists() )
+        if ( output != null && output.exists() )
         {
             message = i18n.getString( "override_confirm" );
 

=== modified file 'local/vn/dhis-web-excel-reporting/src/main/webapp/dhis-web-excel-reporting/excelTemplateList.vm'
--- local/vn/dhis-web-excel-reporting/src/main/webapp/dhis-web-excel-reporting/excelTemplateList.vm	2011-05-23 05:36:39 +0000
+++ local/vn/dhis-web-excel-reporting/src/main/webapp/dhis-web-excel-reporting/excelTemplateList.vm	2011-05-24 03:49:29 +0000
@@ -2,21 +2,9 @@
 //-----------------------------------------------------------------------
 //init jQuery validation for uploadfile
 //-----------------------------------------------------------------------
-	jQuery(document).ready(
-		function()
-		{
-			jQuery("#uploadForm").validate({
-				 meta:"validate"
-				,errorElement:"td"
-				,submitHandler: function(form)
-				{
-					validateUploadExcelTemplate(form);
-				}
-			});
-
-			tableSorter( 'listTable' );				
-		}
-	);
+	jQuery(document).ready( function() {
+		tableSorter( 'listTable' );				
+	});
 
 </script>
 <input type="hidden" id="curLocaleCode" value="$locale.getLanguage()_$locale.getCountry()"/>
@@ -29,7 +17,7 @@
 			<td width="18%" style=" width:25% ">$i18n.getString( 'select_excel_file' ):</td>
 			<td width="82%">
 				<input type="file" id="upload" name="upload" onChange="enable('uploadButton');" />				
-				<input name="uploadButton" id="uploadButton" type="submit" value="$i18n.getString( 'upload_file' )" />    
+				<input name="uploadButton" id="uploadButton" type="button" value="$i18n.getString( 'upload_file' )" onclick="validateUploadExcelTemplate()" disabled />    
 			</td>  
 			<td></td>			
 		</tr>

=== modified file 'local/vn/dhis-web-excel-reporting/src/main/webapp/dhis-web-excel-reporting/javascript/exceltemplate.js'
--- local/vn/dhis-web-excel-reporting/src/main/webapp/dhis-web-excel-reporting/javascript/exceltemplate.js	2011-05-23 05:36:39 +0000
+++ local/vn/dhis-web-excel-reporting/src/main/webapp/dhis-web-excel-reporting/javascript/exceltemplate.js	2011-05-24 03:49:29 +0000
@@ -217,7 +217,7 @@
 	return true;
 }
 
-function validateUploadExcelTemplate(form)
+function validateUploadExcelTemplate()
 {        
 	jQuery( "#upload" ).upload( 'validateUploadExcelTemplate.action',
 		function(data)
@@ -231,10 +231,24 @@
 			}
 			else if ( type == 'input' )
 			{
-				if ( window.confirm( i18n_confirm_override ) ) form.submit();
-				else return;
-			}
-			else form.submit();
+				if ( !window.confirm( i18n_confirm_override ) ) return;
+				else uploadExcelTemplate();
+			}
+			else uploadExcelTemplate();
+		}, 'xml'
+	);
+}
+	
+function uploadExcelTemplate()
+{
+	jQuery( "#upload" ).upload( 'uploadExcelTemplate.action',
+		function( data, e ) {
+			try {
+				window.location.reload();
+			}
+			catch(e) {
+				alert(e);
+			}
 		}
 	);
 }
\ No newline at end of file