'use strict'; import React from 'react'; import { getCookie } from '../utils/fetch_api_utils'; import AppConstants from '../constants/application_constants'; import Router from 'react-router'; import LicenseActions from '../actions/license_actions'; import LicenseStore from '../stores/license_store'; 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'; import ReactS3FineUploader from './ascribe_uploader/react_s3_fine_uploader'; import DatePicker from 'react-datepicker/dist/react-datepicker'; import { mergeOptions } from '../utils/general_utils'; let RegisterPiece = React.createClass( { mixins: [Router.Navigation], getInitialState(){ return mergeOptions( LicenseStore.getState(), { digitalWorkKey: null, uploadStatus: false, selectedLicense: 0 }); }, componentDidMount() { LicenseActions.fetchLicense(); LicenseStore.listen(this.onChange); }, componentWillUnmount() { LicenseStore.unlisten(this.onChange); }, onChange(state) { this.setState(state); }, handleSuccess(){ let notification = new GlobalNotificationModel('Login successsful', 'success', 10000); GlobalNotificationActions.appendGlobalNotification(notification); this.transitionTo('pieces'); }, getFormData(){ let data = {}; for (let ref in this.refs.form.refs){ data[this.refs.form.refs[ref].props.name] = this.refs.form.refs[ref].state.value; } data.digital_work_key = this.state.digitalWorkKey; return data; }, submitKey(key){ this.setState({ digitalWorkKey: key }); }, setIsUploadReady(isReady) { this.setState({ isUploadReady: isReady }); }, isReadyForFormSubmission(files) { files = files.filter((file) => file.status !== 'deleted' && file.status !== 'canceled'); if (files.length > 0 && files[0].status === 'upload successful') { return true; } else { return false; } }, onLicenseChange(event){ console.log(this.state.licenses[event.target.selectedIndex].url); this.setState({selectedLicense: event.target.selectedIndex}); }, getLicenses() { if (this.state.licenses && this.state.licenses.length > 0) { return ( Learn more about this license }> ); } return null; }, render() { return (

Lock down title

Register your artwork } spinner={ }> {this.getLicenses()}
); } }); let FileUploader = React.createClass({ propTypes: { setIsUploadReady: React.PropTypes.func, submitKey: React.PropTypes.func, isReadyForFormSubmission: React.PropTypes.func }, render() { return ( ); } }); let InputDate = React.createClass({ propTypes: { placeholderText: React.PropTypes.string, onChange: React.PropTypes.func }, getInitialState() { return { value: null, value_formatted: null }; }, handleChange(date) { this.setState({ value: date, value_formatted: date.format('YYYY')}); let event = document.createEvent('HTMLEvents'); event.initEvent('click', false, true); document.dispatchEvent(event); event.target.value = date; this.props.onChange(event); }, render: function () { return ( ); } }); export default RegisterPiece;