1
0
mirror of https://github.com/ascribe/onion.git synced 2024-06-30 13:41:57 +02:00
onion/js/components/ascribe_uploader/react_s3_fine_uploader_utils.js
2015-09-10 09:54:02 +02:00

35 lines
1.1 KiB
JavaScript

'use strict';
/**
* Filter function for filtering all deleted and canceled files
* @param {object} file A file from filesToUpload that has status as a prop.
* @return {boolean}
*/
export function displayValidFilesFilter(file) {
return file.status !== 'deleted' && file.status !== 'canceled';
}
/**
* Returns a boolean if there has been at least one file uploaded
* successfully without it being deleted or canceled.
* @param {array of files} files provided by react fine uploader
* @return {Boolean}
*/
export function isReadyForFormSubmission(files) {
files = files.filter(displayValidFilesFilter);
if (files.length > 0 && files[0].status === 'upload successful') {
return true;
} else {
return false;
}
}
/**
* Filter function for which files to integrate in the progress process
* @param {object} file A file from filesToUpload, that has a status as a prop.
* @return {boolean}
*/
export function displayValidProgressFilesFilter(file) {
return file.status !== 'deleted' && file.status !== 'canceled' && file.status !== 'online';
}