dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #40408
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 20488: Use hidden input field for file resource data values instead of data attribute + clean up markup
------------------------------------------------------------
revno: 20488
committer: Halvdan Hoem Grelland <halvdanhg@xxxxxxxxx>
branch nick: dhis2
timestamp: Sat 2015-10-03 01:47:42 +0200
message:
Use hidden input field for file resource data values instead of data attribute + clean up markup
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
dhis-2/dhis-web/dhis-web-dataentry/src/main/webapp/dhis-web-dataentry/sectionForm.vm
dhis-2/dhis-web/dhis-web-dataentry/src/main/webapp/dhis-web-dataentry/style/dhis-web-dataentry.css
--
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-02 22:42:59 +0000
+++ dhis-2/dhis-web/dhis-web-dataentry/src/main/webapp/dhis-web-dataentry/javascript/entry.fileresource.js 2015-10-02 23:47:42 +0000
@@ -3,6 +3,8 @@
var $container = $( this );
var $field = $container.find( '.entryfileresource' );
+ var $displayField = $container.find( '.upload-field' );
+
var $button = $container.find( '.upload-button' );
var $fileInput = $container.find( 'input[type=file]' );
@@ -45,8 +47,8 @@
$fileinfoName.text( '' );
$fileinfoSize.text( '' );
$fileinfo.hide();
- $field.css( 'background-color', '' );
- $field.data( 'value', '');
+ $displayField.css( 'background-color', '' );
+ $field.val( '' );
setButtonUpload();
},
error: function( data )
@@ -120,8 +122,10 @@
$fileinfoName.text( name );
$fileinfoSize.text( size );
+ $fileinfo.show();
$progressBar.toggleClass( 'upload-progress-bar-complete' );
- $fileinfo.show();
+ $displayField.css( 'background-color', dhis2.de.cst.colorGreen );
+
resetAndHideProgress();
setButtonDelete();
$button.button( 'enable' );
@@ -135,16 +139,16 @@
var disableField = function() {
$button.button( 'disable' );
- $field.toggleClass( 'entryfileresource-disabled', true );
+ $displayField.toggleClass( 'upload-field-disabled', true );
};
var enableField = function() {
$button.button( 'enable' );
- $field.toggleClass( 'entryfileresource-disabled', false );
+ $displayField.toggleClass( 'upload-field-disabled', false );
};
$( document ).on( dhis2.de.event.dataValuesLoaded, function() {
- ( !$field.data( 'value' ) ) ? setButtonUpload() : setButtonDelete();
+ ( !$field.val() ) ? setButtonUpload() : setButtonDelete();
} );
$( document ).on( "dhis2.offline", disableField );
@@ -180,6 +184,7 @@
done: function( e, data )
{
var fileResource = data.result.response.fileResource;
+ $field.val( fileResource.id );
saveFileResource( dataElementId, optionComboId, id, fileResource, function() {
onFileDataValueSavedSuccess( fileResource );
=== 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-02 22:42:59 +0000
+++ dhis-2/dhis-web/dhis-web-dataentry/src/main/webapp/dhis-web-dataentry/javascript/form.js 2015-10-02 23:47:42 +0000
@@ -1537,12 +1537,12 @@
}
function clearFileEntryFields() {
- var $container = $( '.entryfileresource-container' );
- $container.find( '.upload-fileinfo-name' ).text( '' );
- $container.find( '.upload-fileinfo-size' ).text( '' );
+ var $containers = $( '.entryfileresource-container' );
+ $containers.find( '.upload-fileinfo-name' ).text( '' );
+ $containers.find( '.upload-fileinfo-size' ).text( '' );
- $container.find( '.entryfileresource' ).css( 'background-color', dhis2.de.cst.colorWhite );
- $container.find( '.entryfileresource' ).data( 'value', '' );
+ $containers.find( '.upload-field' ).css( 'background-color', dhis2.de.cst.colorWhite );
+ $containers.find( '.entryfileresource' ).val( '' );
}
function getAndInsertDataValues()
@@ -1677,12 +1677,13 @@
}
else if ( $( fieldId ).attr( 'class' ) == 'entryfileresource' )
{
- $( fieldId ).data( 'value', value.val );
+ $( fieldId ).val( value.val );
if ( value.fileMeta )
{
- $( fieldId ).find( '.upload-fileinfo-name' ).text( value.fileMeta.name );
- $( fieldId ).find( '.upload-fileinfo-size' ).text( '(' + filesize( value.fileMeta.size ) + ')' );
+ var $container = $( '.entryfileresource-container[name=' + value.id + '-val]' );
+ $container.find( '.upload-fileinfo-name' ).text( value.fileMeta.name );
+ $container.find( '.upload-fileinfo-size' ).text( '(' + filesize( value.fileMeta.size ) + ')' );
}
}
else
@@ -1700,7 +1701,7 @@
else if ( $( fieldId ).length > 0 )
{
$( fieldId ).css( 'border-color', dhis2.de.cst.colorBorderActive )
- }
+ }
}
dataValueMap[value.id] = value.val;
=== modified file 'dhis-2/dhis-web/dhis-web-dataentry/src/main/webapp/dhis-web-dataentry/sectionForm.vm'
--- dhis-2/dhis-web/dhis-web-dataentry/src/main/webapp/dhis-web-dataentry/sectionForm.vm 2015-09-30 18:50:42 +0000
+++ dhis-2/dhis-web/dhis-web-dataentry/src/main/webapp/dhis-web-dataentry/sectionForm.vm 2015-10-02 23:47:42 +0000
@@ -102,8 +102,9 @@
<td><textarea name="entryfield" class="entryfield entryarea" id="${dataEntryId}" tabindex="${tabIndex}" #if( $greyedField || !$hasAccess ) disabled="disabled"#end></textarea></td>
#elseif( "FILE_RESOURCE" == $dataElement.valueType )
<td>
- <div class="entryfileresource-container">
- <div id="${dataEntryId}" class="entryfileresource">
+ <div class="entryfileresource-container" name="${dataEntryId}">
+ <input class="entryfileresource" id="${dataEntryId}" tabindex="${tabIndex}" #if( $greyedField || !$hasAccess ) disabled="disabled"#end>
+ <div class="upload-field">
<div class="upload-fileinfo">
<div class="upload-fileinfo-size"></div>
<div class="upload-fileinfo-name"></div>
=== modified file 'dhis-2/dhis-web/dhis-web-dataentry/src/main/webapp/dhis-web-dataentry/style/dhis-web-dataentry.css'
--- dhis-2/dhis-web/dhis-web-dataentry/src/main/webapp/dhis-web-dataentry/style/dhis-web-dataentry.css 2015-10-02 11:06:55 +0000
+++ dhis-2/dhis-web/dhis-web-dataentry/src/main/webapp/dhis-web-dataentry/style/dhis-web-dataentry.css 2015-10-02 23:47:42 +0000
@@ -259,6 +259,11 @@
.entryfileresource
{
+ display: none; /* Hidden field */
+}
+
+.upload-field
+{
height: 28px;
width: 200px;
border: 1px solid #dadada;
@@ -267,7 +272,7 @@
position: relative;
}
-.entryfileresource-disabled
+.upload-field-disabled
{
background-color: #f3f3f3 !important;
}