Skip to content

Commit

Permalink
fixed: media missing from submissions in offline-capable views
Browse files Browse the repository at this point in the history
  • Loading branch information
MartijnR committed Dec 7, 2015
1 parent 19dce3b commit cf5c3bf
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 7 deletions.
5 changes: 3 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,17 @@
All notable changes to this project will be documented in this file.
This project adheres to [Semantic Versioning](http:https://semver.org/).

[Unreleased]
[1.21.1] - 2015-12-07
---------------------
##### Changed
- Show helpful "Use Safari on iOS" message when unsupported iOS browser is used.
- Updated Dutch and Norwegian translations.
- Updated Slovak, Dutch and Norwegian translations.

##### Fixed
- Empty error dialog when form fails to load.
- Form footer margins incorrect.
- Media & data form resource retrieval does not work with "external authentication".
- Media missing from submission in offline-capable views.

##### Removed
- "Experimental" warning message
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "enketo-express",
"description": "A simplified version of Enketo Smart Paper that requires a constant connection to the server.",
"homepage": "",
"version": "1.21.0",
"version": "1.21.1",
"main": "./app.js",
"repository": {
"type": "git",
Expand Down
6 changes: 3 additions & 3 deletions public/js/src/module/connection.js
Original file line number Diff line number Diff line change
Expand Up @@ -199,8 +199,8 @@ function _prepareFormDataArray( record ) {
console.debug( 'splitting record into ' + batches.length + ' batches to reduce submission size ', batches );

batches.forEach( function( batch ) {
var batchPrepped,
fd = new FormData();
var batchPrepped;
var fd = new FormData();

fd.append( 'xml_submission_file', xmlSubmissionBlob );

Expand All @@ -212,7 +212,7 @@ function _prepareFormDataArray( record ) {

// add any media files to the batch
batch.forEach( function( fileIndex ) {
batchPrepped.formData.append( submissionFiles[ fileIndex ].nodeName, submissionFiles[ fileIndex ].file );
batchPrepped.formData.append( submissionFiles[ fileIndex ].nodeName, submissionFiles[ fileIndex ].file, submissionFiles[ fileIndex ].file.name );
} );

// push the batch to the array
Expand Down
4 changes: 4 additions & 0 deletions public/js/src/module/records-queue.js
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,10 @@ function uploadQueue() {
.then( function( record ) {
// convert record.files to a simple <File> array
record.files = record.files.map( function( object ) {
// do not add name property if already has one (a File will throw exception)
if ( typeof object.item.name === 'undefined' ) {
object.item.name = object.name;
}
return object.item;
} );
uploadProgress.update( record.instanceId, 'ongoing', '', successes.length + fails.length, records.length );
Expand Down
2 changes: 1 addition & 1 deletion public/js/src/module/store.js
Original file line number Diff line number Diff line change
Expand Up @@ -666,7 +666,7 @@ function _getFile( table, id, key ) {
return new Promise( function( resolve, reject ) {
if ( table === 'resources' || table === 'files' ) {
prop = ( table === 'resources' ) ? 'url' : 'name';
server[ table ].get( id + ':' + key )
return server[ table ].get( id + ':' + key )
.then( function( item ) {
file[ prop ] = key;
if ( item instanceof Blob ) {
Expand Down

0 comments on commit cf5c3bf

Please sign in to comment.