'use strict'; import React from 'react'; import Property from './../ascribe_forms/property'; import ReactS3FineUploader from './../ascribe_uploader/react_s3_fine_uploader'; import ApiUrls from '../../constants/api_urls'; import AppConstants from '../../constants/application_constants'; import { getCookie } from '../../utils/fetch_api_utils'; import { getLangText } from '../../utils/lang_utils'; const { func, bool, number, object, string, arrayOf } = React.PropTypes; let FurtherDetailsFileuploader = React.createClass({ propTypes: { label: string, pieceId: number, otherData: arrayOf(object), editable: bool, // Props for ReactS3FineUploader multiple: bool, showErrorPrompt: bool, submitFile: func, // TODO: rename to onSubmitFile setIsUploadReady: func, //TODO: rename to setIsUploaderValidated isReadyForFormSubmission: func }, getDefaultProps() { return { label: getLangText('Additional files'), multiple: false }; }, render() { const { editable, isReadyForFormSubmission, multiple, otherData, pieceId, setIsUploadReady, showErrorPrompt, submitFile } = this.props; // Essentially there a three cases important to the fileuploader // // 1. there is no other_data => do not show the fileuploader at all (where otherData is now an array) // 2. there is other_data, but user has no edit rights => show fileuploader but without action buttons // 3. both other_data and editable are defined or true => show fileuploader with all action buttons if (!editable && (!otherData || otherData.length === 0)) { return null; } let otherDataIds = otherData ? otherData.map((data) => data.id).join() : null; return ( ); } }); export default FurtherDetailsFileuploader;