← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 1659: Usability issues with static report web interface.

 

------------------------------------------------------------
revno: 1659
committer: Tran Chau <tran.hispvietnam@xxxxxxxxx>
branch nick: trunk
timestamp: Wed 2010-03-17 18:11:37 +0700
message:
  Usability issues with static report web interface.
modified:
  dhis-2/dhis-web/dhis-web-reporting/src/main/java/org/hisp/dhis/reporting/document/action/SaveDocumentAction.java
  dhis-2/dhis-web/dhis-web-reporting/src/main/webapp/dhis-web-reporting/addDocumentForm.vm
  dhis-2/dhis-web/dhis-web-reporting/src/main/webapp/dhis-web-reporting/javascript/document.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-reporting/src/main/java/org/hisp/dhis/reporting/document/action/SaveDocumentAction.java'
--- dhis-2/dhis-web/dhis-web-reporting/src/main/java/org/hisp/dhis/reporting/document/action/SaveDocumentAction.java	2010-03-17 06:25:32 +0000
+++ dhis-2/dhis-web/dhis-web-reporting/src/main/java/org/hisp/dhis/reporting/document/action/SaveDocumentAction.java	2010-03-17 11:11:37 +0000
@@ -129,43 +129,46 @@
         throws Exception
     {
         Document document = new Document();
-        
+
         if ( id != null )
         {
             document = documentService.getDocument( id );
 
-            document.setName( name );
         }
-        else
+        
+        if ( !external && file != null )
         {
-            if ( !external )
+            log.info( "Uploading file: '" + fileName + "', content-type: '" + contentType + "'" );
+
+            File destination = locationManager.getFileForWriting( fileName, DocumentService.DIR );
+
+            boolean fileMoved = file.renameTo( destination );
+
+            if ( !fileMoved )
             {
-                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" );
-                }
-
-                url = fileName;
+                throw new RuntimeException( "File was not uploaded" );
             }
-            else
+
+            url = fileName;
+            document.setUrl( url );
+        }
+
+        else if ( external )
+        {
+            if ( !(url.startsWith( HTTP_PREFIX ) || url.startsWith( HTTPS_PREFIX )) )
             {
-                if ( !(url.startsWith( HTTP_PREFIX ) || url.startsWith( HTTPS_PREFIX )) )
-                {
-                    url = HTTP_PREFIX + url;
-                }
+                url = HTTP_PREFIX + url;
             }
 
             log.info( "Document name: '" + name + "', url: '" + url + "', external: '" + external + "'" );
 
-            document = new Document( name, url, external );
+            document.setUrl( url );
         }
 
+        document.setExternal( external );
+
+        document.setName( name );
+
         documentService.saveDocument( document );
 
         return SUCCESS;

=== modified file 'dhis-2/dhis-web/dhis-web-reporting/src/main/webapp/dhis-web-reporting/addDocumentForm.vm'
--- dhis-2/dhis-web/dhis-web-reporting/src/main/webapp/dhis-web-reporting/addDocumentForm.vm	2010-03-17 06:25:32 +0000
+++ dhis-2/dhis-web/dhis-web-reporting/src/main/webapp/dhis-web-reporting/addDocumentForm.vm	2010-03-17 11:11:37 +0000
@@ -14,10 +14,16 @@
     <tr>
     	<td><label for="external">$i18n.getString( "type" )</label></td>
     	<td>
-    		<select id="external" name="external" style="width:20em" onchange="toggleExternal()" #if($!document) disabled=false else disabled=true #end>
-    			<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>
+			<select id="external" name="external" style="width:20em" onchange="toggleExternal()">
+				#if( $!document && !$!document.external )
+				<option value="false">$i18n.getString( "upload_file" )</option>
+				#elseif( $!document)
+				<option value="true">$i18n.getString( "external_url" )</option>
+				#else
+				<option value="false">$i18n.getString( "upload_file" )</option>
+				<option value="true">$i18n.getString( "external_url" )</option>
+				#end
+			</select>
 	    </td>
     </tr>
 </table>
@@ -26,7 +32,7 @@
 <table>
     <tr>
         <td style="width:70px"><label for="upload">$i18n.getString( "file" )</label></td>
-        <td><input type="file" id="upload" name="upload" size="25" #if($!document) disabled=true value="$!document.url" #end></td>
+        <td><input type="file" id="upload" name="upload" size="25"></td>
     </tr>
 </table>
 </div>
@@ -35,7 +41,7 @@
 <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) disabled=true value="$!document.url" #else value="http://"; #end></td>
+        <td><input type="text" id="url" name="url" style="width:20em" #if($!document) value="$!document.url" #else value="http://"; #end></td>
     </tr>
 </table>
 </div>
@@ -56,4 +62,6 @@
 </form>
 
 <span id="message"#if ( $message ) style="display:block"#end>$!message</span>
-<script>toggleExternal();</script>
+<script>
+	toggleExternal();
+</script>

=== 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-03-16 07:56:31 +0000
+++ dhis-2/dhis-web/dhis-web-reporting/src/main/webapp/dhis-web-reporting/javascript/document.js	2010-03-17 11:11:37 +0000
@@ -1,17 +1,7 @@
 
 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 url = "validateDocument.action?name=" + getFieldValue( "name" ) + "&id=" + getFieldValue( "id" );
 	
     var request = new Request();
     request.setResponseTypeXML( 'message' );