dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #04626
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 1541: confirm upload exist excel template file
------------------------------------------------------------
revno: 1541
committer: Tran Thanh Tri <Tran Thanh Tri@compaq>
branch nick: trunk
timestamp: Thu 2010-03-04 12:58:44 +0700
message:
confirm upload exist excel template file
added:
dhis-2/dhis-web/dhis-web-excel-reporting/src/main/webapp/dhis-web-excel-reporting/responseInput.vm
modified:
dhis-2/dhis-web/dhis-web-excel-reporting/src/main/java/org/hisp/dhis/reportexcel/filemanager/action/ValidateUploadExcelTemplate.java
dhis-2/dhis-web/dhis-web-excel-reporting/src/main/resources/META-INF/dhis/beans.xml
dhis-2/dhis-web/dhis-web-excel-reporting/src/main/resources/org/hisp/dhis/reportexcel/i18n_module.properties
dhis-2/dhis-web/dhis-web-excel-reporting/src/main/resources/org/hisp/dhis/reportexcel/i18n_module_vi_VN.properties
dhis-2/dhis-web/dhis-web-excel-reporting/src/main/resources/struts.xml
dhis-2/dhis-web/dhis-web-excel-reporting/src/main/webapp/dhis-web-excel-reporting/excelTemplateList.vm
dhis-2/dhis-web/dhis-web-excel-reporting/src/main/webapp/dhis-web-excel-reporting/javascript/exceltemplate.js
dhis-2/dhis-web/dhis-web-excel-reporting/src/main/webapp/dhis-web-excel-reporting/javascript/reportItem.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 'dhis-2/dhis-web/dhis-web-excel-reporting/src/main/java/org/hisp/dhis/reportexcel/filemanager/action/ValidateUploadExcelTemplate.java'
--- dhis-2/dhis-web/dhis-web-excel-reporting/src/main/java/org/hisp/dhis/reportexcel/filemanager/action/ValidateUploadExcelTemplate.java 2010-02-25 09:05:59 +0000
+++ dhis-2/dhis-web/dhis-web-excel-reporting/src/main/java/org/hisp/dhis/reportexcel/filemanager/action/ValidateUploadExcelTemplate.java 2010-03-04 05:58:44 +0000
@@ -1,11 +1,5 @@
package org.hisp.dhis.reportexcel.filemanager.action;
-import java.io.File;
-
-import org.hisp.dhis.i18n.I18n;
-
-import com.opensymphony.xwork2.Action;
-
/*
* Copyright (c) 2004-2007, University of Oslo
* All rights reserved.
@@ -32,6 +26,14 @@
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
+
+import java.io.File;
+
+import org.hisp.dhis.i18n.I18n;
+import org.hisp.dhis.reportexcel.ReportLocationManager;
+
+import com.opensymphony.xwork2.Action;
+
/**
* @author Tran Thanh Tri
* @version $Id
@@ -41,6 +43,17 @@
{
private static final String TEMPLATE_TYPE = "application/vnd.ms-excel";
+ // -------------------------------------------
+ // Dependency
+ // -------------------------------------------
+
+ private ReportLocationManager reportLocationManager;
+
+ public void setReportLocationManager( ReportLocationManager reportLocationManager )
+ {
+ this.reportLocationManager = reportLocationManager;
+ }
+
// -------------------------------------------------------------------------
// Input & Output
// -------------------------------------------------------------------------
@@ -49,9 +62,9 @@
private String uploadContentType; // The content type of the file
-// private String uploadFileName; // The uploaded file name
-//
-// private String fileCaption;// The caption of the file entered by user
+ private String uploadFileName; // The uploaded file name
+ //
+ // private String fileCaption;// The caption of the file entered by user
private String message;
@@ -81,6 +94,11 @@
this.i18n = i18n;
}
+ public void setUploadFileName( String uploadFileName )
+ {
+ this.uploadFileName = uploadFileName;
+ }
+
// -------------------------------------------------------------------------
// Action implementation
// -------------------------------------------------------------------------
@@ -88,18 +106,32 @@
@Override
public String execute()
throws Exception
- {
+ {
+
if ( upload == null || !upload.exists() )
{
message = i18n.getString( "upload_file_null" );
+
return ERROR;
}
-
- if ( !TEMPLATE_TYPE.contains( uploadContentType ) )
+
+ if ( !TEMPLATE_TYPE.contains( uploadContentType ) )
{
message = i18n.getString( "file_type_not_supported" );
+
return ERROR;
}
+
+ File templateDirectoryConfig = reportLocationManager.getReportExcelTemplateDirectory();
+
+ File output = new File( templateDirectoryConfig, uploadFileName );
+
+ if ( output.exists() )
+ {
+ message = i18n.getString("override_confirm");
+
+ return INPUT;
+ }
return SUCCESS;
}
=== modified file 'dhis-2/dhis-web/dhis-web-excel-reporting/src/main/resources/META-INF/dhis/beans.xml'
--- dhis-2/dhis-web/dhis-web-excel-reporting/src/main/resources/META-INF/dhis/beans.xml 2010-02-25 09:05:59 +0000
+++ dhis-2/dhis-web/dhis-web-excel-reporting/src/main/resources/META-INF/dhis/beans.xml 2010-03-04 05:58:44 +0000
@@ -1314,7 +1314,9 @@
<bean
id="org.hisp.dhis.reportexcel.filemanager.action.ValidateUploadExcelTemplate"
class="org.hisp.dhis.reportexcel.filemanager.action.ValidateUploadExcelTemplate"
- scope="prototype">
+ scope="prototype">
+ <property name="reportLocationManager"
+ ref="org.hisp.dhis.reportexcel.ReportLocationManager" />
</bean>
</beans>
=== modified file 'dhis-2/dhis-web/dhis-web-excel-reporting/src/main/resources/org/hisp/dhis/reportexcel/i18n_module.properties'
--- dhis-2/dhis-web/dhis-web-excel-reporting/src/main/resources/org/hisp/dhis/reportexcel/i18n_module.properties 2010-02-25 09:05:59 +0000
+++ dhis-2/dhis-web/dhis-web-excel-reporting/src/main/resources/org/hisp/dhis/reportexcel/i18n_module.properties 2010-03-04 05:58:44 +0000
@@ -203,4 +203,6 @@
cell_exist = Exist one cell same sheet, row and column with this.
download = Download
upload_file_null = Upload file null
-file_type_not_supported = File type not supported
\ No newline at end of file
+file_type_not_supported = File type not supported
+override_confirm = File is exist. Do you want to override ?
+ready_in_use = File is ready in use. Can not delete !
\ No newline at end of file
=== modified file 'dhis-2/dhis-web/dhis-web-excel-reporting/src/main/resources/org/hisp/dhis/reportexcel/i18n_module_vi_VN.properties'
--- dhis-2/dhis-web/dhis-web-excel-reporting/src/main/resources/org/hisp/dhis/reportexcel/i18n_module_vi_VN.properties 2010-02-24 08:56:35 +0000
+++ dhis-2/dhis-web/dhis-web-excel-reporting/src/main/resources/org/hisp/dhis/reportexcel/i18n_module_vi_VN.properties 2010-03-04 05:58:44 +0000
@@ -201,4 +201,6 @@
use_only_letters_numbers_dot_only = Ch\u1ec9 nh\u1eadp K\u00fd t\u1ef1, S\u1ed1 cho t\u00ean t\u1eadp tin v\u00e0 D\u1ea5u ch\u1ea5m(.) cho ph\u1ea7n \u0111u\u00f4i m\u1edf r\u1ed9ng
cell_exist = \u0110\u00e3 t\u1ed3n t\u1ea1i m\u1ed9t excel item c\u00f3 c\u00f9ng d\u00f2ng, c\u1ed9t v\u00e0 sheet.
update_successful = C\u1eadp nh\u1eadt th\u00e0nh c\u00f4ng !
-download = T\u1ea3i v\u1ec1
\ No newline at end of file
+download = T\u1ea3i v\u1ec1
+override_confirm = File template n\u00e0y \u0111\u00e3 t\u1ed3n t\u1ea1i. B\u1ea1n c\u00f3 mu\u1ed1n ghi \u0111\u00e8 hay ko ?
+ready_in_use = File n\u00e0y \u0111ang \u0111\u01b0\u1ee3c d\u00f9ng, kh\u00f4ng th\u1ec3 x\u00f3a \u0111\u01b0\u1ee3c.
\ No newline at end of file
=== modified file 'dhis-2/dhis-web/dhis-web-excel-reporting/src/main/resources/struts.xml'
--- dhis-2/dhis-web/dhis-web-excel-reporting/src/main/resources/struts.xml 2010-02-27 19:05:00 +0000
+++ dhis-2/dhis-web/dhis-web-excel-reporting/src/main/resources/struts.xml 2010-03-04 05:58:44 +0000
@@ -1297,6 +1297,8 @@
/dhis-web-excel-reporting/responseSuccess.vm</result>
<result name="error" type="velocity-xml">
/dhis-web-excel-reporting/responseError.vm</result>
+ <result name="input" type="velocity-xml">
+ /dhis-web-excel-reporting/responseInput.vm</result>
</action>
</package>
=== modified file 'dhis-2/dhis-web/dhis-web-excel-reporting/src/main/webapp/dhis-web-excel-reporting/excelTemplateList.vm'
--- dhis-2/dhis-web/dhis-web-excel-reporting/src/main/webapp/dhis-web-excel-reporting/excelTemplateList.vm 2010-03-04 05:05:34 +0000
+++ dhis-2/dhis-web/dhis-web-excel-reporting/src/main/webapp/dhis-web-excel-reporting/excelTemplateList.vm 2010-03-04 05:58:44 +0000
@@ -1,6 +1,6 @@
<h3>$i18n.getString('excel_template_management')</h3>
-<form name="uploadForm" id="uploadForm" action="uploadExcelTemplate.action" onsubmit="return validateUploadExcelTemplate(document.getElementById('upload').value, 1);" method="post" enctype="multipart/form-data">
+<form name="uploadForm" id="uploadForm" action="uploadExcelTemplate.action" method="post" enctype="multipart/form-data">
<table>
<tr>
<td width="18%" style=" width:25% ">$i18n.getString( 'select_excel_file' ):</td>
@@ -65,7 +65,7 @@
var mode = '';
var i18n_confirm_rename = '$encoder.jsEscape($i18n.getString( 'confirm_rename' ) , "'")';
var i18n_confirm_delete = '$encoder.jsEscape($i18n.getString( 'confirm_delete' ) , "'")';
- var i18n_confirm_override = '$encoder.jsEscape($i18n.getString( 'confirm_override' ) , "'")';
+ var i18n_confirm_override = '$encoder.jsEscape($i18n.getString( 'override_confirm' ) , "'")';
var i18n_confirm_update_system = '$encoder.jsEscape($i18n.getString( 'confirm_update_system' ) , "'")';
var i18n_file_exists = '$encoder.jsEscape($i18n.getString( 'file_exists' ) , "'")';
var i18n_file_used_system = '$encoder.jsEscape($i18n.getString( 'file_used_system' ) , "'")';
=== modified file 'dhis-2/dhis-web/dhis-web-excel-reporting/src/main/webapp/dhis-web-excel-reporting/javascript/exceltemplate.js'
--- dhis-2/dhis-web/dhis-web-excel-reporting/src/main/webapp/dhis-web-excel-reporting/javascript/exceltemplate.js 2010-03-04 05:05:34 +0000
+++ dhis-2/dhis-web/dhis-web-excel-reporting/src/main/webapp/dhis-web-excel-reporting/javascript/exceltemplate.js 2010-03-04 05:58:44 +0000
@@ -38,28 +38,6 @@
}
}
-function validateUploadExistExcelTemplate ( fileName, columnIndex ) {
-
- var list = byId( 'list' );
-
- var rows = list.getElementsByTagName( 'tr' );
-
- for ( var i = 0; i < rows.length; i++ )
- {
- var cell = rows[i].getElementsByTagName( 'td' )[columnIndex-1];
- var value = cell.firstChild.nodeValue;
-
- if ( value.toLowerCase().indexOf( fileName.toLowerCase() ) != -1 )
- {
- // file is existsing
- return window.confirm( i18n_confirm_override );
- }
- }
-
- // normally upload
- return true;
-}
-
curTemplateName = '';
newTemplateName = '';
@@ -221,10 +199,8 @@
// Validate Upload Excel Template
//----------------------------------------------------------
-function validateUploadExcelTemplate( fileName, columnIndex ) {
-
- return validateUploadExistExcelTemplate( fileName, columnIndex );
-
+function validateUploadExcelTemplate()
+{
$.ajaxFileUpload
(
{
@@ -238,6 +214,12 @@
var type = data.getAttribute("type");
if(type=='error'){
setMessage(data.firstChild.nodeValue);
+ }else if(type=='input'){
+ if(window.confirm( i18n_confirm_override )){
+ document.forms['uploadForm'].submit();
+ }else{
+ return;
+ }
}else{
document.forms['uploadForm'].submit();
}
=== modified file 'dhis-2/dhis-web/dhis-web-excel-reporting/src/main/webapp/dhis-web-excel-reporting/javascript/reportItem.js'
--- dhis-2/dhis-web/dhis-web-excel-reporting/src/main/webapp/dhis-web-excel-reporting/javascript/reportItem.js 2010-03-03 07:33:59 +0000
+++ dhis-2/dhis-web/dhis-web-excel-reporting/src/main/webapp/dhis-web-excel-reporting/javascript/reportItem.js 2010-03-04 05:58:44 +0000
@@ -125,7 +125,7 @@
params += "&reportId=" + byId("reportId").value;
request.sendAsPost(params);
- request.send( "validateAddReportExcelItem.action" );
+ request.send( "validateAddReportExcelItem.action");
}
@@ -150,7 +150,7 @@
function addReportExcelItem() {
- $.post("addReportExcelItem.action",{
+ /*$.post("addReportExcelItem.action",{
name:$("#name").val(),
expression:$("#expression").val(),
row:$("#row").val(),
@@ -162,6 +162,24 @@
}, function (data){
window.location.reload();
},'xml');
+ */
+
+ var request = new Request();
+ request.setResponseTypeXML( 'xmlObject' );
+ request.setCallbackSuccess( validateAddReportExcelItemReceived );
+
+ var params = "name=" + byId("name").value;
+ params += "&expression=" + byId("expression").value;
+ params += "&row=" + byId("row").value;
+ params += "&column=" + byId("column").value;
+ params += "&sheetNo=" + byId("sheetNo").value;
+ params += "&reportId=" + byId("reportId").value;
+ params += "&itemType=" + byId("itemType").value;
+ params += "&periodType=" + byId("periodType").value;
+
+
+ //request.sendAsPost(params);
+ request.send( "addReportExcelItem.action?" + params);
}
=== added file 'dhis-2/dhis-web/dhis-web-excel-reporting/src/main/webapp/dhis-web-excel-reporting/responseInput.vm'
--- dhis-2/dhis-web/dhis-web-excel-reporting/src/main/webapp/dhis-web-excel-reporting/responseInput.vm 1970-01-01 00:00:00 +0000
+++ dhis-2/dhis-web/dhis-web-excel-reporting/src/main/webapp/dhis-web-excel-reporting/responseInput.vm 2010-03-04 05:58:44 +0000
@@ -0,0 +1,4 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<message type="input">$encoder.xmlEncode( $message )</message>
+
+