blob: afe97849558a91ca69386fff6c68e1906195fa2e (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
|
// Copyright (c) 2015 Spinpunch, Inc. All Rights Reserved.
// See License.txt for license information.
var PostHeader = require('./post_header.jsx');
var PostBody = require('./post_body.jsx');
var PostInfo = require('./post_info.jsx');
var AppDispatcher = require('../dispatcher/app_dispatcher.jsx');
var Constants = require('../utils/constants.jsx');
var ActionTypes = Constants.ActionTypes;
module.exports = React.createClass({
componentDidMount: function() {
$('.edit-modal').on('show.bs.modal', function () {
$('.edit-modal .edit-modal-body').css('overflow-y', 'auto');
$('.edit-modal .edit-modal-body').css('max-height', $(window).height() * 0.7);
});
},
handleCommentClick: function(e) {
e.preventDefault();
data = {};
data.order = [this.props.post.id];
data.posts = this.props.posts;
AppDispatcher.handleServerAction({
type: ActionTypes.RECIEVED_POST_SELECTED,
post_list: data
});
AppDispatcher.handleServerAction({
type: ActionTypes.RECIEVED_SEARCH,
results: null
});
},
getInitialState: function() {
return { };
},
render: function() {
var post = this.props.post;
var parentPost = this.props.parentPost;
var posts = this.props.posts;
var type = "Post"
if (post.root_id.length > 0) {
type = "Comment"
}
var commentCount = 0;
var commentRootId = parentPost ? post.root_id : post.id;
var rootUser = "";
for (var postId in posts) {
if (posts[postId].root_id == commentRootId) {
commentCount += 1;
}
}
var error = this.state.error ? <div className='form-group has-error'><label className='control-label'>{ this.state.error }</label></div> : null;
if(this.props.sameRoot){
rootUser = "same--root";
}
else {
rootUser = "other--root";
}
var postType = "";
if(type != "Post"){
postType = "post--comment";
}
return (
<div>
<div id={post.id} className={"post " + this.props.sameUser + " " + rootUser + " " + postType}>
{ !this.props.hideProfilePic ?
<div className="post-profile-img__container">
<img className="post-profile-img" src={"/api/v1/users/" + post.user_id + "/image"} height="36" width="36" />
</div>
: "" }
<div className="post__content">
<PostHeader post={post} sameRoot={this.props.sameRoot} commentCount={commentCount} handleCommentClick={this.handleCommentClick} isLastComment={this.props.isLastComment} />
<PostBody post={post} sameRoot={this.props.sameRoot} parentPost={parentPost} posts={posts} handleCommentClick={this.handleCommentClick} />
<PostInfo post={post} sameRoot={this.props.sameRoot} commentCount={commentCount} handleCommentClick={this.handleCommentClick} allowReply="true" />
</div>
</div>
</div>
);
}
});
|