mirror of
https://github.com/ascribe/onion.git
synced 2024-12-23 01:39:36 +01:00
49421e1fa1
Conflicts: js/components/ascribe_detail/further_details_fileuploader.js js/components/ascribe_forms/form.js js/components/ascribe_forms/form_loan.js js/components/ascribe_forms/form_register_piece.js js/components/ascribe_forms/input_fineuploader.js js/components/ascribe_forms/property.js js/components/ascribe_forms/property_collapsible.js js/components/ascribe_uploader/ascribe_file_drag_and_drop/file_drag_and_drop.js js/components/ascribe_uploader/react_s3_fine_uploader.js js/components/whitelabel/wallet/components/cyland/cyland_forms/cyland_additional_data_form.js js/components/whitelabel/wallet/components/ikonotv/ikonotv_forms/ikonotv_artist_details_form.js js/components/whitelabel/wallet/components/ikonotv/ikonotv_forms/ikonotv_artwork_details_form.js sass/ascribe-fonts/ascribe-fonts.scss sass/whitelabel/wallet/cyland/cyland_custom_style.scss
101 lines
3.9 KiB
JavaScript
101 lines
3.9 KiB
JavaScript
'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';
|
|
|
|
|
|
let FurtherDetailsFileuploader = React.createClass({
|
|
propTypes: {
|
|
label: React.PropTypes.string,
|
|
pieceId: React.PropTypes.number,
|
|
otherData: React.PropTypes.arrayOf(React.PropTypes.object),
|
|
setIsUploadReady: React.PropTypes.func,
|
|
submitFile: React.PropTypes.func,
|
|
isReadyForFormSubmission: React.PropTypes.func,
|
|
editable: React.PropTypes.bool,
|
|
multiple: React.PropTypes.bool
|
|
},
|
|
|
|
getDefaultProps() {
|
|
return {
|
|
label: getLangText('Additional files'),
|
|
multiple: false
|
|
};
|
|
},
|
|
|
|
render() {
|
|
// 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 (!this.props.editable && (!this.props.otherData || this.props.otherData.length === 0)) {
|
|
return null;
|
|
}
|
|
|
|
let otherDataIds = this.props.otherData ? this.props.otherData.map((data) => data.id).join() : null;
|
|
|
|
return (
|
|
<Property
|
|
name="other_data_key"
|
|
label={this.props.label}>
|
|
<ReactS3FineUploader
|
|
keyRoutine={{
|
|
url: AppConstants.serverUrl + 's3/key/',
|
|
fileClass: 'otherdata',
|
|
pieceId: this.props.pieceId
|
|
}}
|
|
createBlobRoutine={{
|
|
url: ApiUrls.blob_otherdatas,
|
|
pieceId: this.props.pieceId
|
|
}}
|
|
validation={AppConstants.fineUploader.validation.additionalData}
|
|
submitFile={this.props.submitFile}
|
|
setIsUploadReady={this.props.setIsUploadReady}
|
|
isReadyForFormSubmission={this.props.isReadyForFormSubmission}
|
|
session={{
|
|
endpoint: AppConstants.serverUrl + 'api/blob/otherdatas/fineuploader_session/',
|
|
customHeaders: {
|
|
'X-CSRFToken': getCookie(AppConstants.csrftoken)
|
|
},
|
|
params: {
|
|
'pk': otherDataIds
|
|
},
|
|
cors: {
|
|
expected: true,
|
|
sendCredentials: true
|
|
}
|
|
}}
|
|
signature={{
|
|
endpoint: AppConstants.serverUrl + 's3/signature/',
|
|
customHeaders: {
|
|
'X-CSRFToken': getCookie(AppConstants.csrftoken)
|
|
}
|
|
}}
|
|
deleteFile={{
|
|
enabled: true,
|
|
method: 'DELETE',
|
|
endpoint: AppConstants.serverUrl + 's3/delete',
|
|
customHeaders: {
|
|
'X-CSRFToken': getCookie(AppConstants.csrftoken)
|
|
}
|
|
}}
|
|
areAssetsDownloadable={true}
|
|
areAssetsEditable={this.props.editable}
|
|
multiple={this.props.multiple} />
|
|
</Property>
|
|
);
|
|
}
|
|
});
|
|
|
|
export default FurtherDetailsFileuploader;
|