2017-02-02 16:18:33 +01:00
|
|
|
import { Components, registerComponent } from 'meteor/nova:core';
|
2016-03-17 17:48:25 +09:00
|
|
|
import React, { PropTypes, Component } from 'react';
|
2016-02-18 17:53:04 +09:00
|
|
|
|
2016-04-14 10:12:35 +09:00
|
|
|
class CommentsNode extends Component {
|
2016-02-18 17:53:04 +09:00
|
|
|
|
|
|
|
renderComment(comment) {
|
2016-11-26 02:46:55 +08:00
|
|
|
|
2016-02-18 17:53:04 +09:00
|
|
|
return (
|
2016-12-06 18:06:29 +01:00
|
|
|
<Components.CommentsItem comment={comment} key={comment._id} />
|
2016-02-18 17:53:04 +09:00
|
|
|
)
|
2016-03-17 17:48:25 +09:00
|
|
|
}
|
2016-02-18 17:53:04 +09:00
|
|
|
|
2016-11-09 11:55:12 +09:00
|
|
|
renderChildren(children) {
|
|
|
|
return (
|
|
|
|
<div className="comments-children">
|
2016-11-15 18:33:16 +01:00
|
|
|
{children.map(comment => <CommentsNode comment={comment} key={comment._id} />)}
|
2016-11-09 11:55:12 +09:00
|
|
|
</div>
|
|
|
|
)
|
|
|
|
}
|
2016-02-18 17:53:04 +09:00
|
|
|
|
|
|
|
render() {
|
|
|
|
|
|
|
|
const comment = this.props.comment;
|
2016-11-09 11:55:12 +09:00
|
|
|
const children = this.props.comment.childrenResults;
|
2016-11-26 02:46:55 +08:00
|
|
|
|
2016-02-18 17:53:04 +09:00
|
|
|
return (
|
2016-04-19 15:45:36 +09:00
|
|
|
<div className="comments-node">
|
2016-02-18 17:53:04 +09:00
|
|
|
{this.renderComment(comment)}
|
2016-11-09 11:55:12 +09:00
|
|
|
{children ? this.renderChildren(children) : null}
|
2016-02-18 17:53:04 +09:00
|
|
|
</div>
|
|
|
|
)
|
|
|
|
}
|
|
|
|
|
2016-11-26 02:46:55 +08:00
|
|
|
}
|
2016-03-17 17:48:25 +09:00
|
|
|
|
2016-04-14 10:12:35 +09:00
|
|
|
CommentsNode.propTypes = {
|
2016-03-17 17:48:25 +09:00
|
|
|
comment: React.PropTypes.object.isRequired, // the current comment
|
2016-10-14 08:47:18 +02:00
|
|
|
};
|
|
|
|
|
2016-12-08 23:48:16 +01:00
|
|
|
registerComponent('CommentsNode', CommentsNode);
|