'use strict'; import React from 'react'; import Router from 'react-router'; import Row from 'react-bootstrap/lib/Row'; import Col from 'react-bootstrap/lib/Col'; import Button from 'react-bootstrap/lib/Button'; import Glyphicon from 'react-bootstrap/lib/Glyphicon'; import UserActions from '../../actions/user_actions'; import UserStore from '../../stores/user_store'; import CoaActions from '../../actions/coa_actions'; import CoaStore from '../../stores/coa_store'; import MediaContainer from './media_container'; import CollapsibleParagraph from './../ascribe_collapsible/collapsible_paragraph'; import Form from './../ascribe_forms/form'; import Property from './../ascribe_forms/property'; import EditionDetailProperty from './detail_property'; import InputTextAreaToggable from './../ascribe_forms/input_textarea_toggable'; import EditionHeader from './header'; import EditionFurtherDetails from './further_details'; //import PieceExtraDataForm from './../ascribe_forms/form_piece_extradata'; import RequestActionForm from './../ascribe_forms/form_request_action'; import EditionActions from '../../actions/edition_actions'; import AclButtonList from './../ascribe_buttons/acl_button_list'; //import ReactS3FineUploader from './../ascribe_uploader/react_s3_fine_uploader'; import GlobalNotificationModel from '../../models/global_notification_model'; import GlobalNotificationActions from '../../actions/global_notification_actions'; 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 Link = Router.Link; /** * This is the component that implements display-specific functionality */ let Edition = React.createClass({ propTypes: { edition: React.PropTypes.object, loadEdition: React.PropTypes.func }, getInitialState() { return UserStore.getState(); }, componentDidMount() { UserStore.listen(this.onChange); UserActions.fetchCurrentUser(); }, componentWillUnmount() { UserStore.unlisten(this.onChange); }, onChange(state) { this.setState(state); }, render() { return ( -1 || this.props.edition.public_note)}> -1 || Object.keys(this.props.edition.extra_data).length > 0 || this.props.edition.other_data !== null}> -1} pieceId={this.props.edition.parent} extraData={this.props.edition.extra_data} otherData={this.props.edition.other_data} handleSuccess={this.props.loadEdition}/> -1}> 0}> 0}> 0}> ); } }); let EditionSummary = React.createClass({ propTypes: { edition: React.PropTypes.object }, getTransferWithdrawData(){ return {'bitcoin_id': this.props.edition.bitcoin_id}; }, handleSuccess(){ EditionActions.fetchOne(this.props.edition.id); }, showNotification(response){ this.handleSuccess(); let notification = new GlobalNotificationModel(response.notification, 'success'); GlobalNotificationActions.appendGlobalNotification(notification); }, getStatus(){ let status = null; if (this.props.edition.status.length > 0){ let statusStr = this.props.edition.status.join().replace(/_/, ' '); status = ; if (this.props.edition.pending_new_owner && this.props.edition.acl.indexOf('withdraw_transfer') > -1){ status = (
); } } return status; }, getActions(){ let actions = null; if (this.props.edition.request_action && this.props.edition.request_action.length > 0){ actions = ( ); } else { actions = ( ); } return actions; }, render() { return (
{this.getStatus()}
{this.getActions()}
); } }); let EditionDetailHistoryIterator = React.createClass({ propTypes: { history: React.PropTypes.array }, render() { return (
{this.props.history.map((historicalEvent, i) => { return (
{ historicalEvent[1] }
); })}
); } }); let EditionPersonalNote = React.createClass({ propTypes: { edition: React.PropTypes.object, currentUser: React.PropTypes.object, handleSuccess: React.PropTypes.func }, showNotification(){ this.props.handleSuccess(); let notification = new GlobalNotificationModel(getLangText('Private note saved'), 'success'); GlobalNotificationActions.appendGlobalNotification(notification); }, render() { if (this.props.currentUser.username && true || false) { return (

); } return null; } }); let EditionPublicEditionNote = React.createClass({ propTypes: { edition: React.PropTypes.object, handleSuccess: React.PropTypes.func }, showNotification(){ this.props.handleSuccess(); let notification = new GlobalNotificationModel(getLangText('Public note saved'), 'success'); GlobalNotificationActions.appendGlobalNotification(notification); }, render() { let isEditable = this.props.edition.acl.indexOf('edit') > -1; if (this.props.edition.acl.indexOf('edit') > -1 || this.props.edition.public_note){ return (

); } return null; } }); let CoaDetails = React.createClass({ propTypes: { edition: React.PropTypes.object }, getInitialState() { return CoaStore.getState(); }, componentDidMount() { CoaStore.listen(this.onChange); if (this.props.edition.coa) { CoaActions.fetchOne(this.props.edition.coa); } else { CoaActions.create(this.props.edition); } }, componentWillUnmount() { CoaStore.unlisten(this.onChange); }, onChange(state) { this.setState(state); }, render() { if (this.state.coa.url_safe) { return (

); } return (
); } }); let SpoolDetails = React.createClass({ propTypes: { edition: React.PropTypes.object }, render() { let bitcoinIdValue = ( {this.props.edition.bitcoin_id} ); let hashOfArtwork = ( {this.props.edition.hash_as_address} ); let ownerAddress = ( {this.props.edition.btc_owner_address_noprefix} ); return (
{bitcoinIdValue}
{hashOfArtwork}
{ownerAddress}

); } }); export default Edition;