2017-01-13 00:45:21 -05:00
|
|
|
import React, { PropTypes, Component } from 'react'
|
2016-04-24 11:50:35 -04:00
|
|
|
|
2017-01-25 14:03:20 -05:00
|
|
|
import Title from './Title'
|
|
|
|
import Links from './Links'
|
2017-01-25 15:49:11 -05:00
|
|
|
import Desc from './Desc'
|
2017-01-25 16:54:28 -05:00
|
|
|
import Attachments from './Attachments'
|
2017-01-25 15:49:11 -05:00
|
|
|
|
2017-01-13 00:45:21 -05:00
|
|
|
class ReactTopicCard extends Component {
|
|
|
|
render = () => {
|
2017-01-25 16:54:28 -05:00
|
|
|
const { topic, ActiveMapper } = this.props
|
2017-01-13 00:45:21 -05:00
|
|
|
var authorizedToEdit = topic.authorizeToEdit(ActiveMapper)
|
2017-01-25 17:03:30 -05:00
|
|
|
const hasAttachment = topic.get('link') && topic.get('link') !== ''
|
|
|
|
const topicId = topic.isNew() ? topic.cid : topic.id // TODO should we be using cid here???
|
2017-01-24 17:25:28 -05:00
|
|
|
|
2017-01-13 00:45:21 -05:00
|
|
|
let classname = 'permission'
|
2017-01-24 17:25:28 -05:00
|
|
|
if (authorizedToEdit) {
|
|
|
|
classname += ' canEdit'
|
|
|
|
} else {
|
|
|
|
classname += ' cannotEdit'
|
|
|
|
}
|
2017-01-13 00:45:21 -05:00
|
|
|
if (topic.authorizePermissionChange(ActiveMapper)) classname += ' yourTopic'
|
|
|
|
|
|
|
|
return (
|
|
|
|
<div className={classname}>
|
2017-01-25 14:03:20 -05:00
|
|
|
<div className={`CardOnGraph ${hasAttachment ? 'hasAttachment' : ''}`} id={`topic_${topicId}`}>
|
2017-01-28 15:52:00 -05:00
|
|
|
<Title name={topic.get('name')}
|
|
|
|
onChange={this.props.updateTopic}
|
|
|
|
authorizedToEdit={topic.authorizeToEdit(ActiveMapper)}
|
|
|
|
/>
|
2017-01-25 17:03:30 -05:00
|
|
|
<Links topic={topic}
|
|
|
|
ActiveMapper={this.props.ActiveMapper}
|
2017-01-26 07:15:24 +00:00
|
|
|
updateTopic={this.props.updateTopic}
|
2017-01-25 17:03:30 -05:00
|
|
|
/>
|
2017-01-25 15:49:11 -05:00
|
|
|
<Desc desc={topic.get('desc')}
|
|
|
|
authorizedToEdit={topic.authorizeToEdit(ActiveMapper)}
|
|
|
|
onChange={this.props.updateTopic}
|
|
|
|
/>
|
2017-01-25 16:54:28 -05:00
|
|
|
<Attachments topic={this.props.topic}
|
|
|
|
ActiveMapper={this.props.ActiveMapper}
|
|
|
|
updateTopic={this.props.updateTopic}
|
|
|
|
/>
|
2017-01-13 00:45:21 -05:00
|
|
|
<div className="clearfloat"></div>
|
|
|
|
</div>
|
2017-01-25 16:54:28 -05:00
|
|
|
</div>
|
|
|
|
)
|
2016-04-24 11:50:35 -04:00
|
|
|
}
|
2016-09-22 15:21:59 +08:00
|
|
|
}
|
|
|
|
|
2017-01-13 00:45:21 -05:00
|
|
|
ReactTopicCard.propTypes = {
|
|
|
|
topic: PropTypes.object,
|
|
|
|
ActiveMapper: PropTypes.object,
|
2017-01-24 18:17:42 -05:00
|
|
|
updateTopic: PropTypes.func
|
2017-01-13 00:45:21 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
export default ReactTopicCard
|