2015-07-08 22:54:07 +02:00
|
|
|
'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';
|
|
|
|
|
2015-07-10 20:00:35 +02:00
|
|
|
import DetailProperty from './detail_property';
|
|
|
|
|
2015-07-08 22:54:07 +02:00
|
|
|
import FurtherDetails from './further_details';
|
2015-07-10 20:00:35 +02:00
|
|
|
import UserActions from '../../actions/user_actions';
|
|
|
|
import UserStore from '../../stores/user_store';
|
2015-07-08 22:54:07 +02:00
|
|
|
|
|
|
|
import MediaContainer from './media_container';
|
|
|
|
|
|
|
|
import Header from './header';
|
|
|
|
|
2015-07-10 20:00:35 +02:00
|
|
|
import Form from './../ascribe_forms/form';
|
|
|
|
import Property from './../ascribe_forms/property';
|
|
|
|
|
|
|
|
import RequestActionForm from './../ascribe_forms/form_request_action';
|
|
|
|
import EditionActions from '../../actions/edition_actions';
|
|
|
|
import AclButtonList from './../ascribe_buttons/acl_button_list';
|
|
|
|
|
|
|
|
|
|
|
|
import GlobalNotificationModel from '../../models/global_notification_model';
|
|
|
|
import GlobalNotificationActions from '../../actions/global_notification_actions';
|
|
|
|
|
|
|
|
import apiUrls from '../../constants/api_urls';
|
|
|
|
import { getLangText } from '../../utils/lang_utils';
|
|
|
|
|
2015-07-08 22:54:07 +02:00
|
|
|
/**
|
|
|
|
* This is the component that implements display-specific functionality
|
|
|
|
*/
|
|
|
|
let Piece = React.createClass({
|
|
|
|
propTypes: {
|
|
|
|
piece: React.PropTypes.object,
|
|
|
|
loadPiece: React.PropTypes.func
|
|
|
|
},
|
|
|
|
|
2015-07-10 20:00:35 +02:00
|
|
|
getInitialState() {
|
|
|
|
return UserStore.getState();
|
|
|
|
},
|
|
|
|
|
|
|
|
componentDidMount() {
|
|
|
|
UserStore.listen(this.onChange);
|
|
|
|
UserActions.fetchCurrentUser();
|
|
|
|
},
|
|
|
|
|
|
|
|
componentWillUnmount() {
|
|
|
|
UserStore.unlisten(this.onChange);
|
|
|
|
},
|
|
|
|
|
|
|
|
onChange(state) {
|
|
|
|
this.setState(state);
|
|
|
|
},
|
2015-07-08 22:54:07 +02:00
|
|
|
|
|
|
|
render() {
|
|
|
|
|
|
|
|
return (
|
|
|
|
<Row>
|
|
|
|
<Col md={6}>
|
|
|
|
<MediaContainer
|
|
|
|
content={this.props.piece}/>
|
|
|
|
</Col>
|
|
|
|
<Col md={6} className="ascribe-edition-details">
|
|
|
|
<Header
|
|
|
|
content={this.props.piece}/>
|
2015-07-10 20:00:35 +02:00
|
|
|
<PieceSummary
|
|
|
|
currentUser={this.state.currentUser}
|
|
|
|
piece={this.props.piece} />
|
2015-07-08 22:54:07 +02:00
|
|
|
<CollapsibleParagraph
|
|
|
|
title="Further Details"
|
|
|
|
show={this.props.piece.acl.indexOf('edit') > -1
|
|
|
|
|| Object.keys(this.props.piece.extra_data).length > 0
|
2015-07-10 16:45:49 +02:00
|
|
|
|| this.props.piece.other_data !== null}
|
|
|
|
defaultExpanded={true}>
|
2015-07-08 22:54:07 +02:00
|
|
|
<FurtherDetails
|
2015-07-09 14:37:33 +02:00
|
|
|
editable={this.props.piece.acl.indexOf('edit') > -1}
|
|
|
|
pieceId={this.props.piece.id}
|
|
|
|
extraData={this.props.piece.extra_data}
|
|
|
|
otherData={this.props.piece.other_data}
|
|
|
|
handleSuccess={this.props.loadPiece}/>
|
2015-07-08 22:54:07 +02:00
|
|
|
</CollapsibleParagraph>
|
|
|
|
|
|
|
|
</Col>
|
|
|
|
</Row>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
2015-07-10 20:00:35 +02:00
|
|
|
let PieceSummary = React.createClass({
|
|
|
|
propTypes: {
|
|
|
|
piece: React.PropTypes.object
|
|
|
|
},
|
|
|
|
|
|
|
|
getActions(){
|
|
|
|
//let actions = (
|
|
|
|
// <Row>
|
|
|
|
// <Col md={12}>
|
|
|
|
// <AclButtonList
|
|
|
|
// className="text-center ascribe-button-list"
|
|
|
|
// availableAcls={this.props.piece.acl}
|
|
|
|
// editions={[this.props.piece]}
|
|
|
|
// handleSuccess={this.handleSuccess} />
|
|
|
|
// </Col>
|
|
|
|
// </Row>);
|
|
|
|
//return actions;
|
|
|
|
return null;
|
|
|
|
},
|
|
|
|
render() {
|
|
|
|
return (
|
|
|
|
<div className="ascribe-detail-header">
|
|
|
|
<DetailProperty label={getLangText('REGISTREE')} value={ this.props.piece.user_registered } />
|
|
|
|
<br/>
|
|
|
|
{this.getActions()}
|
|
|
|
<hr/>
|
|
|
|
</div>
|
|
|
|
);
|
|
|
|
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
|
2015-07-08 22:54:07 +02:00
|
|
|
export default Piece;
|