'use strict'; import React from 'react'; import Row from 'react-bootstrap/lib/Row'; import Col from 'react-bootstrap/lib/Col'; import CollapsibleParagraph from './../ascribe_collapsible/collapsible_paragraph'; import DetailProperty from './detail_property'; import FurtherDetails from './further_details'; import UserActions from '../../actions/user_actions'; import UserStore from '../../stores/user_store'; import PieceActions from '../../actions/piece_actions'; import MediaContainer from './media_container'; import EditionDetailProperty from './detail_property'; import AclButtonList from './../ascribe_buttons/acl_button_list'; import CreateEditionsForm from '../ascribe_forms/create_editions_form'; import CreateEditionsButton from '../ascribe_buttons/create_editions_button'; import { getLangText } from '../../utils/lang_utils'; import { mergeOptions } from '../../utils/general_utils'; /** * This is the component that implements display-specific functionality */ let Piece = React.createClass({ propTypes: { piece: React.PropTypes.object, loadPiece: React.PropTypes.func }, getInitialState() { return mergeOptions( UserStore.getState(), { showCreateEditionsDialog: false } ); }, componentDidMount() { UserStore.listen(this.onChange); UserActions.fetchCurrentUser(); }, componentWillUnmount() { UserStore.unlisten(this.onChange); }, onChange(state) { this.setState(state); }, toggleCreateEditionsDialog() { this.setState({ showCreateEditionsDialog: !this.state.showCreateEditionsDialog }); }, handleEditionCreationSuccess() { PieceActions.updateProperty({key: 'num_editions', value: 0}); this.toggleCreateEditionsDialog(); }, getCreateEditionsDialog() { if(this.props.piece.num_editions < 1 && this.state.showCreateEditionsDialog) { return (

); } else { return (
); } }, handlePollingSuccess(pieceId, numEditions) { PieceActions.updateProperty({ key: 'num_editions', value: numEditions }); }, render() { return (
{this.props.piece.title}
} /> {this.props.piece.num_editions > 0 ? : null}
{this.getCreateEditionsDialog()} 0 || this.props.piece.other_data !== null} defaultExpanded={true}>
); } }); export default Piece;