'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 Glyphicon from 'react-bootstrap/lib/Glyphicon'; import Button from 'react-bootstrap/lib/Button'; 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 PieceListActions from '../../actions/piece_list_actions'; import PieceListStore from '../../stores/piece_list_store'; import EditionListActions from '../../actions/edition_list_actions'; 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 EditionFurtherDetails from './further_details'; import RequestActionForm from './../ascribe_forms/form_request_action'; import AclButtonList from './../ascribe_buttons/acl_button_list'; import UnConsignRequestButton from './../ascribe_buttons/unconsign_request_button'; import DeleteButton from '../ascribe_buttons/delete_button'; 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 { getLangText } from '../../utils/lang_utils'; import { mergeOptions } from '../../utils/general_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 }, mixins: [Router.Navigation], getInitialState() { return mergeOptions( UserStore.getState(), PieceListStore.getState() ); }, componentDidMount() { UserStore.listen(this.onChange); PieceListStore.listen(this.onChange); UserActions.fetchCurrentUser(); }, componentWillUnmount() { UserStore.unlisten(this.onChange); PieceListStore.unlisten(this.onChange); }, onChange(state) { this.setState(state); }, handleDeleteSuccess(response) { PieceListActions.fetchPieceList(this.state.page, this.state.pageSize, this.state.search, this.state.orderBy, this.state.orderAsc); EditionListActions.refreshEditionList(this.props.edition.parent); EditionListActions.closeAllEditionLists(); EditionListActions.clearAllEditionSelections(); let notification = new GlobalNotificationModel(response.notification, 'success'); GlobalNotificationActions.appendGlobalNotification(notification); this.transitionTo('pieces'); }, render() { return (
{this.props.edition.title}
} />
0}> 0}> 0}> 0 || this.props.edition.other_data !== null}>
); } }); let EditionSummary = React.createClass({ propTypes: { edition: React.PropTypes.object, handleSuccess: React.PropTypes.func, currentUser: React.PropTypes.object, handleDeleteSuccess: React.PropTypes.func }, getTransferWithdrawData(){ return {'bitcoin_id': this.props.edition.bitcoin_id}; }, showNotification(response){ this.props.handleSuccess(); if (response){ 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.acl_withdraw_transfer){ status = ( ); } } return status; }, getActions(){ let actions = null; if (this.props.edition.request_action && this.props.edition.request_action.length > 0){ actions = ( ); } else { let withdrawButton = null; if (this.props.edition.status.length > 0 && this.props.edition.pending_new_owner && this.props.edition.acl.acl_withdraw_transfer) { withdrawButton = (
); } let unconsignRequestButton = null; if (this.props.edition.acl.acl_request_unconsign) { unconsignRequestButton = ( ); } actions = ( {withdrawButton} {unconsignRequestButton} ); } 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.acl_edit; if (isEditable || 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 && this.state.coa.url_safe) { return (

); } else if (typeof this.state.coa === 'string'){ return (
{this.state.coa}
); } 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;