1
0
mirror of https://github.com/ascribe/onion.git synced 2024-12-23 01:39:36 +01:00
onion/js/components/ascribe_detail/further_details.js

108 lines
3.4 KiB
JavaScript
Raw Normal View History

2015-07-08 22:54:07 +02:00
'use strict';
import React from 'react';
import Row from 'react-bootstrap/lib/Row';
import Col from 'react-bootstrap/lib/Col';
import GlobalNotificationModel from '../../models/global_notification_model';
import GlobalNotificationActions from '../../actions/global_notification_actions';
2015-08-12 13:34:41 +02:00
import FurtherDetailsFileuploader from './further_details_fileuploader';
2015-07-08 22:54:07 +02:00
import Form from './../ascribe_forms/form';
import PieceExtraDataForm from './../ascribe_forms/form_piece_extradata';
import { formSubmissionValidation } from '../ascribe_uploader/react_s3_fine_uploader_utils';
2016-01-18 13:29:08 +01:00
import { getLangText } from '../../utils/lang_utils';
2015-07-08 22:54:07 +02:00
let FurtherDetails = React.createClass({
propTypes: {
pieceId: React.PropTypes.number.isRequired,
editable: React.PropTypes.bool,
extraData: React.PropTypes.object,
handleSuccess: React.PropTypes.func,
otherData: React.PropTypes.arrayOf(React.PropTypes.object),
2015-07-08 22:54:07 +02:00
},
getInitialState() {
return {
loading: false
};
},
showNotification() {
2016-01-18 13:29:08 +01:00
const { handleSuccess } = this.props;
if (typeof handleSucess === 'function') {
handleSuccess();
}
2016-01-18 13:29:08 +01:00
const notification = new GlobalNotificationModel(getLangText('Details updated'), 'success');
2015-07-08 22:54:07 +02:00
GlobalNotificationActions.appendGlobalNotification(notification);
},
submitFile(file) {
2015-07-08 22:54:07 +02:00
this.setState({
otherDataKey: file.key
2015-07-08 22:54:07 +02:00
});
},
setIsUploadReady(isReady) {
this.setState({
isUploadReady: isReady
});
},
render() {
const { editable, extraData, otherData, pieceId } = this.props;
return (
<Row>
<Col md={12} className="ascribe-edition-personal-note">
<PieceExtraDataForm
name='artist_contact_info'
title='Artist Contact Info'
2016-01-19 19:36:30 +01:00
convertLinks
editable={editable}
extraData={extraData}
2016-01-20 12:31:02 +01:00
handleSuccess={this.showNotification}
2016-01-19 19:36:30 +01:00
pieceId={pieceId} />
<PieceExtraDataForm
name='display_instructions'
title='Display Instructions'
editable={editable}
2016-01-20 12:31:02 +01:00
extraData={extraData}
handleSuccess={this.showNotification}
pieceId={pieceId} />
<PieceExtraDataForm
name='technology_details'
title='Technology Details'
editable={editable}
2016-01-20 12:31:02 +01:00
extraData={extraData}
handleSuccess={this.showNotification}
pieceId={pieceId} />
2015-08-12 13:34:41 +02:00
<Form>
<FurtherDetailsFileuploader
submitFile={this.submitFile}
2015-08-12 13:34:41 +02:00
setIsUploadReady={this.setIsUploadReady}
isReadyForFormSubmission={formSubmissionValidation.atLeastOneUploadedFile}
editable={editable}
overrideForm={true}
pieceId={pieceId}
otherData={otherData}
multiple={true} />
2015-08-12 13:34:41 +02:00
</Form>
</Col>
</Row>
);
2015-07-08 22:54:07 +02:00
}
});
export default FurtherDetails;