1
0
mirror of https://github.com/ascribe/onion.git synced 2024-06-29 00:58:03 +02:00
onion/js/components/register_piece.js

198 lines
6.0 KiB
JavaScript
Raw Normal View History

2015-06-17 17:48:52 +02:00
'use strict';
import React from 'react';
import AppConstants from '../constants/application_constants';
import fineUploader from 'fineUploader';
2015-06-22 10:50:22 +02:00
import Router from 'react-router';
import GlobalNotificationModel from '../models/global_notification_model';
import GlobalNotificationActions from '../actions/global_notification_actions';
import Form from './ascribe_forms/form';
import Property from './ascribe_forms/property';
import apiUrls from '../constants/api_urls';
2015-06-23 10:27:19 +02:00
import ReactS3FineUploader from './ascribe_uploader/react_s3_fine_uploader';
2015-06-22 17:33:25 +02:00
import DatePicker from 'react-datepicker/dist/react-datepicker';
2015-06-17 17:48:52 +02:00
let RegisterPiece = React.createClass( {
render() {
2015-06-20 16:43:18 +02:00
2015-06-17 17:48:52 +02:00
return (
2015-06-22 10:50:22 +02:00
<div className="row ascribe-row">
<div className="col-md-6">
<FileUploader />
2015-06-23 10:27:19 +02:00
<br />
2015-06-22 10:50:22 +02:00
</div>
<div className="col-md-6">
2015-06-22 17:33:25 +02:00
<RegisterPieceForm />
</div>
2015-06-22 10:50:22 +02:00
</div>
2015-06-17 17:48:52 +02:00
);
}
});
2015-06-22 10:50:22 +02:00
let FileUploader = React.createClass( {
render() {
return (
<ReactS3FineUploader
keyRoutine={{
url: AppConstants.serverUrl + 's3/key/',
fileClass: 'digitalwork'
}}
autoUpload={true}
debug={false}
objectProperties={{
acl: 'public-read',
bucket: 'ascribe0'
}}
request={{
endpoint: 'https://ascribe0.s3.amazonaws.com',
accessKey: 'AKIAIVCZJ33WSCBQ3QDA'
}}
signature={{
endpoint: AppConstants.serverUrl + 's3/signature/'
}}
uploadSuccess={{
params: {
isBrowserPreviewCapable: fineUploader.supportedFeatures.imagePreviews
}
}}
cors={{
expected: true
}}
chunking={{
enabled: true
}}
resume={{
enabled: true
}}
retry={{
enableAuto: false
}}
deleteFile={{
enabled: true,
method: 'DELETE',
endpoint: AppConstants.serverUrl + 's3/delete'
}}
validation={{
itemLimit: 100000,
sizeLimit: '25000000000'
}}
session={{
endpoint: null
}}
messages={{
unsupportedBrowser: '<h3>Upload is not functional in IE7 as IE7 has no support for CORS!</h3>'
}}
formatFileName={(name) => {// fix maybe
if (name !== undefined && name.length > 26) {
name = name.slice(0, 15) + '...' + name.slice(-15);
}
return name;
}}
multiple={true}/>
);
}
});
2015-06-22 17:33:25 +02:00
let RegisterPieceForm = React.createClass({
2015-06-22 10:50:22 +02:00
mixins: [Router.Navigation],
handleSuccess(){
let notification = new GlobalNotificationModel('Login successsful', 'success', 10000);
GlobalNotificationActions.appendGlobalNotification(notification);
this.transitionTo('pieces');
},
render() {
return (
<Form
2015-06-23 10:27:19 +02:00
url={apiUrls.pieces_list}
2015-06-22 10:50:22 +02:00
handleSuccess={this.handleSuccess}
buttons={
<button type="submit" className="btn ascribe-btn ascribe-btn-login">
2015-06-23 10:27:19 +02:00
Register your artwork
2015-06-22 10:50:22 +02:00
</button>}
spinner={
<button className="btn ascribe-btn ascribe-btn-login ascribe-btn-login-spinner">
<img src="https://s3-us-west-2.amazonaws.com/ascribe0/media/thumbnails/ascribe_animated_medium.gif" />
</button>
}>
<Property
2015-06-22 17:33:25 +02:00
name='artist_name'
label="Artist Name">
2015-06-22 10:50:22 +02:00
<input
2015-06-22 17:33:25 +02:00
type="text"
placeholder="The name of the creator"
2015-06-22 10:50:22 +02:00
required/>
</Property>
<Property
2015-06-22 17:33:25 +02:00
name='title'
label="Artwork title">
2015-06-22 10:50:22 +02:00
<input
2015-06-22 17:33:25 +02:00
type="text"
placeholder="The title of the artwork"
2015-06-22 10:50:22 +02:00
required/>
</Property>
2015-06-23 10:27:19 +02:00
<Property
name='date_created'
label="Year Created">
<InputDate
placeholderText="Year Created (e.g. 2015)" />
</Property>
<Property
name='num_editions'
label="Number of editions">
<input
type="number"
placeholder="Specify the number of unique editions for this artwork"
min={1}
required/>
</Property>
2015-06-22 10:50:22 +02:00
<hr />
</Form>
);
}
});
2015-06-23 10:27:19 +02:00
let InputDate = React.createClass({
propTypes: {
placeholderText: React.PropTypes.string
},
getInitialState() {
return {
value: null,
value_formatted: null
};
},
handleChange(date) {
this.setState({
value: date,
value_formatted: date.format('YYYY')});
},
render: function () {
return (
<DatePicker
key="example2"
dateFormat="YYYY"
selected={this.state.value}
onChange={this.handleChange}
onBlur={this.props.onBlur}
placeholderText={this.props.placeholderText}/>
);
}
});
export default RegisterPiece;