dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #04955
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 1653: Usability issues with static report web interface.
------------------------------------------------------------
revno: 1653
committer: Tran Chau <tran.hispvietnam@xxxxxxxxx>
branch nick: trunk
timestamp: Tue 2010-03-16 14:56:31 +0700
message:
Usability issues with static report web interface.
added:
dhis-2/dhis-web/dhis-web-dataentry/src/main/webapp/dhis-web-dataentry/responseInput.vm
dhis-2/dhis-web/dhis-web-reporting/src/main/java/org/hisp/dhis/reporting/document/action/UpdateDocumentAction.java
dhis-2/dhis-web/dhis-web-reporting/src/main/java/org/hisp/dhis/reporting/document/action/ValidateUpdateDocumentAction.java
dhis-2/dhis-web/dhis-web-reporting/src/main/webapp/dhis-web-reporting/updateDocumentForm.vm
modified:
dhis-2/dhis-web/dhis-web-reporting/src/main/resources/META-INF/dhis/beans.xml
dhis-2/dhis-web/dhis-web-reporting/src/main/resources/struts.xml
dhis-2/dhis-web/dhis-web-reporting/src/main/webapp/dhis-web-reporting/javascript/document.js
dhis-2/dhis-web/dhis-web-reporting/src/main/webapp/dhis-web-reporting/viewDocumentForm.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.
=== added file 'dhis-2/dhis-web/dhis-web-dataentry/src/main/webapp/dhis-web-dataentry/responseInput.vm'
--- dhis-2/dhis-web/dhis-web-dataentry/src/main/webapp/dhis-web-dataentry/responseInput.vm 1970-01-01 00:00:00 +0000
+++ dhis-2/dhis-web/dhis-web-dataentry/src/main/webapp/dhis-web-dataentry/responseInput.vm 2010-03-16 07:56:31 +0000
@@ -0,0 +1,2 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<message type="input">$encoder.xmlEncode( $message )</message>
=== added file 'dhis-2/dhis-web/dhis-web-reporting/src/main/java/org/hisp/dhis/reporting/document/action/UpdateDocumentAction.java'
--- dhis-2/dhis-web/dhis-web-reporting/src/main/java/org/hisp/dhis/reporting/document/action/UpdateDocumentAction.java 1970-01-01 00:00:00 +0000
+++ dhis-2/dhis-web/dhis-web-reporting/src/main/java/org/hisp/dhis/reporting/document/action/UpdateDocumentAction.java 2010-03-16 07:56:31 +0000
@@ -0,0 +1,161 @@
+package org.hisp.dhis.reporting.document.action;
+
+/*
+ * Copyright (c) 2004-2007, 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.
+ */
+
+import java.io.File;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.hisp.dhis.document.Document;
+import org.hisp.dhis.document.DocumentService;
+import org.hisp.dhis.external.location.LocationManager;
+
+import com.opensymphony.xwork2.Action;
+
+/**
+ * @author Lars Helge Overland
+ * @version $Id$
+ */
+public class UpdateDocumentAction
+ implements Action
+{
+ private static final Log log = LogFactory.getLog( UpdateDocumentAction.class );
+
+ private static final String HTTP_PREFIX = "http://";
+
+ private static final String HTTPS_PREFIX = "https://";
+
+ // -------------------------------------------------------------------------
+ // Dependencies
+ // -------------------------------------------------------------------------
+
+ private DocumentService documentService;
+
+ public void setDocumentService( DocumentService documentService )
+ {
+ this.documentService = documentService;
+ }
+
+ private LocationManager locationManager;
+
+ public void setLocationManager( LocationManager locationManager )
+ {
+ this.locationManager = locationManager;
+ }
+
+ // -------------------------------------------------------------------------
+ // Input
+ // -------------------------------------------------------------------------
+
+ private String name;
+
+ public void setName( String name )
+ {
+ this.name = name;
+ }
+
+ private String url;
+
+ public void setUrl( String url )
+ {
+ this.url = url;
+ }
+
+ private Boolean external;
+
+ public void setExternal( Boolean external )
+ {
+ this.external = external;
+ }
+
+ private File file;
+
+ public void setUpload( File file )
+ {
+ this.file = file;
+ }
+
+ private String fileName;
+
+ public void setUploadFileName( String fileName )
+ {
+ this.fileName = fileName;
+ }
+
+ private String contentType;
+
+ public void setUploadContentType( String contentType )
+ {
+ this.contentType = contentType;
+ }
+
+ private Integer id;
+
+ public void setId( Integer id )
+ {
+ this.id = id;
+ }
+
+ // -------------------------------------------------------------------------
+ // Action implementation
+ // -------------------------------------------------------------------------
+
+ public String execute()
+ throws Exception
+ {
+ Document document = documentService.getDocument( id );
+ document.setName( name );
+ document.setExternal( external );
+
+ if ( !external && file != null )
+ {
+ log.info( "Uploading file: '" + fileName + "', content-type: '" + contentType + "'" );
+
+ File destination = locationManager.getFileForWriting( fileName, DocumentService.DIR );
+ boolean fileMoved = file.renameTo( destination );
+
+ if ( !fileMoved )
+ {
+ throw new RuntimeException( "File was not uploaded" );
+ }
+ document.setUrl( fileName );
+ }
+ else if(external)
+ {
+ if ( !(url.startsWith( HTTP_PREFIX ) || url.startsWith( HTTPS_PREFIX )) )
+ {
+ url = HTTP_PREFIX + url;
+ }
+ document.setUrl( url );
+ }
+
+ documentService.saveDocument( document );
+
+ return SUCCESS;
+ }
+}
=== added file 'dhis-2/dhis-web/dhis-web-reporting/src/main/java/org/hisp/dhis/reporting/document/action/ValidateUpdateDocumentAction.java'
--- dhis-2/dhis-web/dhis-web-reporting/src/main/java/org/hisp/dhis/reporting/document/action/ValidateUpdateDocumentAction.java 1970-01-01 00:00:00 +0000
+++ dhis-2/dhis-web/dhis-web-reporting/src/main/java/org/hisp/dhis/reporting/document/action/ValidateUpdateDocumentAction.java 2010-03-16 07:56:31 +0000
@@ -0,0 +1,127 @@
+package org.hisp.dhis.reporting.document.action;
+
+/*
+ * Copyright (c) 2004-2007, 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.
+ */
+
+import org.hisp.dhis.document.Document;
+import org.hisp.dhis.document.DocumentService;
+import org.hisp.dhis.i18n.I18n;
+
+import com.opensymphony.xwork2.Action;
+
+/**
+ * @author Lars Helge Overland
+ * @version $Id$
+ */
+public class ValidateUpdateDocumentAction
+ implements Action
+{
+ // -------------------------------------------------------------------------
+ // Dependencies
+ // -------------------------------------------------------------------------
+
+ private DocumentService documentService;
+
+ public void setDocumentService( DocumentService documentService )
+ {
+ this.documentService = documentService;
+ }
+
+ private I18n i18n;
+
+ public void setI18n( I18n i18n )
+ {
+ this.i18n = i18n;
+ }
+
+ // -------------------------------------------------------------------------
+ // Input
+ // -------------------------------------------------------------------------
+
+ private Integer id;
+
+ public void setId( Integer id )
+ {
+ this.id = id;
+ }
+
+ private String name;
+
+ public void setName( String name )
+ {
+ this.name = name;
+ }
+
+ // -------------------------------------------------------------------------
+ // Output
+ // -------------------------------------------------------------------------
+
+ private String message;
+
+ public String getMessage()
+ {
+ return message;
+ }
+
+ // -------------------------------------------------------------------------
+ // Action implementation
+ // -------------------------------------------------------------------------
+
+ public String execute()
+ {
+ if ( name == null )
+ {
+ message = i18n.getString( "specify_name" );
+
+ return INPUT;
+ }
+ else
+ {
+ name = name.trim();
+
+ if ( name.length() == 0 )
+ {
+ message = i18n.getString( "specify_name" );
+
+ return INPUT;
+ }
+
+ Document match = documentService.getDocumentByName( name );
+
+ if ( match != null && (id == null || match.getId() != id) )
+ {
+ message = i18n.getString( "name_in_use" );
+
+ return INPUT;
+ }
+ }
+
+ message = i18n.getString( "everything_is_ok" );
+
+ return SUCCESS;
+ }
+}
=== modified file 'dhis-2/dhis-web/dhis-web-reporting/src/main/resources/META-INF/dhis/beans.xml'
--- dhis-2/dhis-web/dhis-web-reporting/src/main/resources/META-INF/dhis/beans.xml 2010-03-10 15:51:40 +0000
+++ dhis-2/dhis-web/dhis-web-reporting/src/main/resources/META-INF/dhis/beans.xml 2010-03-16 07:56:31 +0000
@@ -18,6 +18,15 @@
ref="org.hisp.dhis.external.location.LocationManager"/>
</bean>
+ <bean id="org.hisp.dhis.reporting.document.action.UpdateDocumentAction"
+ class="org.hisp.dhis.reporting.document.action.UpdateDocumentAction"
+ scope="prototype">
+ <property name="documentService"
+ ref="org.hisp.dhis.document.DocumentService"/>
+ <property name="locationManager"
+ ref="org.hisp.dhis.external.location.LocationManager"/>
+ </bean>
+
<bean id="org.hisp.dhis.reporting.document.action.GetDocumentAction"
class="org.hisp.dhis.reporting.document.action.GetDocumentAction"
scope="prototype">
=== modified file 'dhis-2/dhis-web/dhis-web-reporting/src/main/resources/struts.xml'
--- dhis-2/dhis-web/dhis-web-reporting/src/main/resources/struts.xml 2010-03-10 15:51:40 +0000
+++ dhis-2/dhis-web/dhis-web-reporting/src/main/resources/struts.xml 2010-03-16 07:56:31 +0000
@@ -22,6 +22,12 @@
<param name="requiredAuthorities">F_DOCUMENT_ADD</param>
</action>
+ <action name="updateDocument" class="org.hisp.dhis.reporting.document.action.UpdateDocumentAction">
+ <result name="success" type="redirect">displayViewDocumentForm.action</result>
+ <interceptor-ref name="fileUploadStack"/>
+ <param name="requiredAuthorities">F_DOCUMENT_UPDATE</param>
+ </action>
+
<action name="removeDocument" class="org.hisp.dhis.reporting.document.action.RemoveDocumentAction">
<result name="success" type="velocity-json">/dhis-web-commons/ajax/jsonResponseSuccess.vm</result>
<param name="requiredAuthorities">F_DOCUMENT_DELETE</param>
@@ -41,6 +47,14 @@
<param name="javascripts">javascript/document.js</param>
</action>
+ <action name="displayUpdateDocumentForm" class="org.hisp.dhis.reporting.document.action.GetDocumentAction">
+ <result name="success" type="velocity">/main.vm</result>
+ <param name="page">/dhis-web-reporting/updateDocumentForm.vm</param>
+ <param name="menu">/dhis-web-reporting/menu.vm</param>
+ <param name="javascripts">javascript/document.js</param>
+ <param name="requiredAuthorities">F_DOCUMENT_UPDATE</param>
+ </action>
+
<action name="validateDocument" class="org.hisp.dhis.reporting.document.action.ValidateDocumentAction">
<result name="success" type="velocity-xml">/dhis-web-reporting/responseSuccess.vm</result>
<result name="input" type="velocity-xml">/dhis-web-reporting/responseInput.vm</result>
=== modified file 'dhis-2/dhis-web/dhis-web-reporting/src/main/webapp/dhis-web-reporting/javascript/document.js'
--- dhis-2/dhis-web/dhis-web-reporting/src/main/webapp/dhis-web-reporting/javascript/document.js 2010-02-17 13:38:15 +0000
+++ dhis-2/dhis-web/dhis-web-reporting/src/main/webapp/dhis-web-reporting/javascript/document.js 2010-03-16 07:56:31 +0000
@@ -2,7 +2,17 @@
function saveDocument()
{
var url = "validateDocument.action?name=" + getFieldValue( "name" );
-
+
+ var request = new Request();
+ request.setResponseTypeXML( 'message' );
+ request.setCallbackSuccess( saveDocumentReceived );
+ request.send( url );
+}
+
+function updateDocument()
+{
+ var url = "validateDocument.action?name=" + getFieldValue( "name" ) + "&id=" + getFieldValue('id');
+
var request = new Request();
request.setResponseTypeXML( 'message' );
request.setCallbackSuccess( saveDocumentReceived );
=== added file 'dhis-2/dhis-web/dhis-web-reporting/src/main/webapp/dhis-web-reporting/updateDocumentForm.vm'
--- dhis-2/dhis-web/dhis-web-reporting/src/main/webapp/dhis-web-reporting/updateDocumentForm.vm 1970-01-01 00:00:00 +0000
+++ dhis-2/dhis-web/dhis-web-reporting/src/main/webapp/dhis-web-reporting/updateDocumentForm.vm 2010-03-16 07:56:31 +0000
@@ -0,0 +1,61 @@
+
+<h3>$i18n.getString( 'update_new_static_report' )</h3>
+
+<form id="documentForm" action="updateDocument.action" method="post" enctype="multipart/form-data">
+<input type="hidden" id="id" name="id" value="$document.id">
+<table>
+ <tr>
+ <th colspan="2">$i18n.getString( "details" )</th>
+ </tr>
+ <tr>
+ <td style="width:70px"><label for="name">$i18n.getString( "name" )</label></td>
+ <td><input type="text" id="name" name="name" style="width:20em" value="$document.name"></td>
+ </tr>
+ <tr>
+ <td><label for="external">$i18n.getString( "type" )</label></td>
+ <td>
+ <select id="external" name="external" style="width:20em" onchange="toggleExternal();">
+ <option value="false" #if(!$document.external) selected #end>$i18n.getString( "upload_file" )</option>
+ <option value="true" #if($document.external) selected #end>$i18n.getString( "external_url" )</option>
+ </select>
+ </td>
+ </tr>
+</table>
+
+<div id="fileDiv">
+<table>
+ <tr>
+ <td style="width:70px"><label for="upload">$i18n.getString( "file" )</label></td>
+ <td><input type="file" id="upload" name="upload" size="25"></td>
+ </tr>
+</table>
+</div>
+
+<div id="urlDiv" style="display:none">
+<table>
+ <tr>
+ <td style="width:70px"><label for="url">$i18n.getString( "url" )</label></td>
+ <td><input type="text" id="url" name="url" style="width:20em" #if($document.external) value="$!document.url" #end></td>
+ </tr>
+</table>
+</div>
+
+<table>
+ <tr>
+ <td colspan="2" height="7px"></td>
+ </tr>
+ <tr>
+ <td></td>
+ <td>
+ <input type="button" value="$i18n.getString( 'save' )" style="width:10em" onclick="updateDocument();"><input
+ type="button" value="$i18n.getString( 'cancel' )" style="width:10em" onclick="window.location.href='displayViewDocumentForm.action'">
+ </td>
+ </tr>
+</table>
+
+</form>
+
+<span id="message"#if ( $message ) style="display:block"#end>$!message</span>
+<script>
+ toggleExternal();
+</script>
=== modified file 'dhis-2/dhis-web/dhis-web-reporting/src/main/webapp/dhis-web-reporting/viewDocumentForm.vm'
--- dhis-2/dhis-web/dhis-web-reporting/src/main/webapp/dhis-web-reporting/viewDocumentForm.vm 2010-02-15 18:55:09 +0000
+++ dhis-2/dhis-web/dhis-web-reporting/src/main/webapp/dhis-web-reporting/viewDocumentForm.vm 2010-03-16 07:56:31 +0000
@@ -25,8 +25,9 @@
#foreach ( $document in $documents )
<tr id="tr${document.id}">
<td>$encoder.htmlEncode( $document.name )</td>
- <td style="text-align:center">
- #if ( $document.external )
+ <td style="text-align:center; width: 60px">
+ <a href="displayUpdateDocumentForm.action?id=$document.id" title="$i18n.getString( "edit" )"><img src="../images/edit.png" alt="$i18n.getString( "edit" )"></a>
+ #if ( $document.external )
<a href="$document.url" title="$i18n.getString( 'view_report' )">
#else
<a href="javascript:window.location.href='loadDocument.action?id=$document.id'" title="$i18n.getString( 'view_report' )">