← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 20456: Bits and bobs

 

------------------------------------------------------------
revno: 20456
committer: Halvdan Hoem Grelland <halvdanhg@xxxxxxxxx>
branch nick: dhis2
timestamp: Thu 2015-10-01 20:46:36 +0200
message:
  Bits and bobs
modified:
  dhis-2/dhis-web/dhis-web-dataentry/src/main/webapp/dhis-web-dataentry/javascript/entry.fileresource.js
  dhis-2/dhis-web/dhis-web-dataentry/src/main/webapp/dhis-web-dataentry/javascript/form.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-dataentry/src/main/webapp/dhis-web-dataentry/javascript/entry.fileresource.js'
--- dhis-2/dhis-web/dhis-web-dataentry/src/main/webapp/dhis-web-dataentry/javascript/entry.fileresource.js	2015-10-01 13:22:12 +0000
+++ dhis-2/dhis-web/dhis-web-dataentry/src/main/webapp/dhis-web-dataentry/javascript/entry.fileresource.js	2015-10-01 18:46:36 +0000
@@ -1,9 +1,8 @@
 ( function ( $ ) {
-    $.fn.fileResourceEntryField = function() {
+    $.fn.fileEntryField = function() {
 
         // TODO Use i18n
         // TODO Disable field when offline
-        // TODO Re-init on period change
 
         var $container = $( this );
 
@@ -52,6 +51,7 @@
                     $fileinfoSize.text( '' );
                     $fileinfo.hide();
                     $field.css( 'background-color', '' );
+                    $field.data( 'value', '');
                     setButtonUpload();
                 },
                 error: function( data )
@@ -104,6 +104,16 @@
             $button.button( 'enable' );
         };
 
+        var setButtonBlocked = function() {
+            $button.button( {
+                text: false,
+                icons: {
+                    primary: 'fa fa-ban'
+                }
+            } );
+            $button.button( 'disable' );
+        };
+
         var resetAndHideProgress = function() {
             $progressBar.toggleClass( 'upload-progress-bar-complete', true );
             $progressBar.css( 'width', 0 );
@@ -122,17 +132,10 @@
             $button.button( 'enable' );
         };
 
-        // Button setup
-        $button.button( {
-            text: false,
-            icons: {
-                primary: 'fa fa-ban'
-            }
-        } );
-        $button.button( 'disable' );
+        setButtonBlocked();
 
         $( document ).on( dhis2.de.event.dataValuesLoaded, function() {
-            ( typeof( $field.data( 'value' ) ) == 'undefined' ) ? setButtonUpload() : setButtonDelete();
+            ( !$field.data( 'value' ) ) ? setButtonUpload() : setButtonDelete();
         } );
 
         // Initialize file uploader

=== modified file 'dhis-2/dhis-web/dhis-web-dataentry/src/main/webapp/dhis-web-dataentry/javascript/form.js'
--- dhis-2/dhis-web/dhis-web-dataentry/src/main/webapp/dhis-web-dataentry/javascript/form.js	2015-10-01 13:22:12 +0000
+++ dhis-2/dhis-web/dhis-web-dataentry/src/main/webapp/dhis-web-dataentry/javascript/form.js	2015-10-01 18:46:36 +0000
@@ -641,7 +641,7 @@
 
     $( '.entryfileresource-container' ).each( function()
     {
-        $( this ).fileResourceEntryField();
+        $( this ).fileEntryField();
     } );
 }
 
@@ -1536,6 +1536,15 @@
     displayEntryFormCompleted();
 }
 
+function clearFileEntryFields() {
+    var $container = $( '.entryfileresource-container' );
+    $container.find( '.upload-fileinfo-name' ).text( '' );
+    $container.find( '.upload-fileinfo-size' ).text( '' );
+
+    $container.find( '.entryfileresource' ).css( 'background-color', dhis2.de.cst.colorWhite );
+    $container.find( '.entryfileresource' ).data( 'value', '' );
+}
+
 function getAndInsertDataValues()
 {
     var periodId = $( '#selectedPeriodId').val();
@@ -1554,7 +1563,8 @@
     $( '.entrytrueonly' ).css( 'background-color', dhis2.de.cst.colorWhite );
     $( '.entryoptionset' ).css( 'background-color', dhis2.de.cst.colorWhite );
 
-    $( '.entryfileresource' ).css( 'background-color', dhis2.de.cst.colorWhite );
+    clearFileEntryFields();
+
 
     $( '[name="min"]' ).html( '' );
     $( '[name="max"]' ).html( '' );
@@ -1667,8 +1677,9 @@
             }
             else if ( $( fieldId ).attr( 'class' ) == 'entryfileresource' )
             {
+                // TODO Consider pre-fetching with dataset
                 $( fieldId ).data( 'value', value.val );
-                // TODO Consider pre-fetching with dataset
+
                 $.ajax( {
                     url: '../api/fileResources/' + value.val,
                     success: function( data ) {