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-28 16:39:17 -05:00
|
|
|
const 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')}
|
2017-01-28 16:39:17 -05:00
|
|
|
authorizedToEdit={authorizedToEdit}
|
2017-01-28 15:52:00 -05:00
|
|
|
onChange={this.props.updateTopic}
|
|
|
|
/>
|
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-28 17:27:01 -05:00
|
|
|
metacodeSets={this.props.metacodeSets}
|
2017-01-25 17:03:30 -05:00
|
|
|
/>
|
2017-01-25 15:49:11 -05:00
|
|
|
<Desc desc={topic.get('desc')}
|
2017-01-28 16:39:17 -05:00
|
|
|
authorizedToEdit={authorizedToEdit}
|
2017-01-25 15:49:11 -05:00
|
|
|
onChange={this.props.updateTopic}
|
|
|
|
/>
|
2017-02-23 21:28:15 -08:00
|
|
|
<Attachments link={this.props.topic.get('link')}
|
|
|
|
authorizedToEdit={authorizedToEdit}
|
2017-01-25 16:54:28 -05:00
|
|
|
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-28 17:27:01 -05:00
|
|
|
updateTopic: PropTypes.func,
|
|
|
|
metacodeSets: PropTypes.arrayOf(PropTypes.shape({
|
|
|
|
name: PropTypes.string,
|
|
|
|
metacodes: PropTypes.arrayOf(PropTypes.shape({
|
|
|
|
id: PropTypes.number,
|
|
|
|
icon_path: PropTypes.string, // url
|
|
|
|
name: PropTypes.string
|
|
|
|
}))
|
|
|
|
}))
|
2017-01-13 00:45:21 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
export default ReactTopicCard
|