Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/lia 210 #217

Open
wants to merge 8 commits into
base: staging
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,4 @@ docker-compose.dev.yml
*.rdb
generated-files/*
.vscode
session.vim
43 changes: 41 additions & 2 deletions imports/ui2/components/Comment.jsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React, { Component } from "react";
import React, { Component, useCallback } from "react";
import {
injectIntl,
intlShape,
Expand Down Expand Up @@ -217,6 +217,13 @@ export const getFBCommentUrl = (comment) => {
};

class Comment extends Component {
constructor(props) {
super(props);
this.state = {
selectedComment: false,
};
}

static Count = CountIntl;
action = () => {
const { comment } = this.props;
Expand Down Expand Up @@ -295,11 +302,43 @@ class Comment extends Component {
return ["fab", "facebook-square"];
}
};

_handleModifySelectedComment = (comments) => {
const { handleSelectedComments } = this.props;
console.log(comments)
handleSelectedComments(comments);
};

_handleChecked = (selectedComments, comment) => {
this.setState({ selectedComment: selectedComments.has(comment) });
};

//componentDidUpdate(prevProps, prevState) {
//console.log(prevProps);
//console.log(prevState);
//console.log("did update");
//}

render() {
const { intl, comment, actions } = this.props;
const { intl, comment, actions, selectedComments, selectedComment } = this.props;

//console.log("selected comment: ", selectedComment());

if (comment) {
return (
<Container>
<div>
{FlowRouter.getQueryParam("entry") ? (
<input
type="checkbox"
checked={selectedComment}
onChange={() =>
this._handleChecked(selectedComments, comment)
}
onClick={() => this._handleModifySelectedComment(comment)}
/>
) : null}
</div>
<header>
<h3>
<span className={`icon ${comment.source}`}>
Expand Down
152 changes: 85 additions & 67 deletions imports/ui2/components/CommentList.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -284,82 +284,100 @@ class CommentList extends Component {
}
};
render() {
const { intl, comments } = this.props;
const { intl, comments, selectedComments, handleSelectedComments } =
this.props;

if (!comments || !comments.length) return null;
return (
<div className="comments">
{comments.map((comment, i) => (
<CommentContainer key={comment._id}>
<div className="comment-content">
<Comment comment={comment} actions={true} />
</div>
{userCan("categorize", "comments") ? (
<>
<div className="comment-actions">
<p className="action-label">
<FormattedMessage
id="app.comment.actions_title"
defaultMessage="Actions"
/>
</p>
<div className="action-icons">
<a
href="javascript:void(0);"
data-tip={intl.formatMessage(messages.tagQuestion)}
className={
this.hasCategory(comment, "question") ? "active" : ""
}
onClick={this._handleCategoryClick(comment, "question")}
>
<FontAwesomeIcon icon="question" />
</a>
<a
href="javascript:void(0);"
data-tip={intl.formatMessage(messages.tagVote)}
className={
this.hasCategory(comment, "vote") ? "active" : ""
}
onClick={this._handleCategoryClick(comment, "vote")}
>
<FontAwesomeIcon icon="thumbs-up" />
</a>
{comments.map((comment, i) => {
//const fn = () => {
//console.log(selectedComments.has(comment));
//return selectedComments.has(comment);
//};

console.log(selectedComments.has(comment))
let selected_comment = selectedComments.has(comment);

return (
<CommentContainer key={comment._id}>
<div className="comment-content">
<Comment
comment={comment}
actions={true}
selectedComments={selectedComments}
handleSelectedComments={handleSelectedComments}
selectedComment={selected_comment}
/>
</div>
{userCan("categorize", "comments") ? (
<>
<div className="comment-actions">
<p className="action-label">
<FormattedMessage
id="app.comment.actions_title"
defaultMessage="Actions"
/>
</p>
<div className="action-icons">
<a
href="javascript:void(0);"
data-tip={intl.formatMessage(messages.tagQuestion)}
className={
this.hasCategory(comment, "question") ? "active" : ""
}
onClick={this._handleCategoryClick(comment, "question")}
>
<FontAwesomeIcon icon="question" />
</a>
<a
href="javascript:void(0);"
data-tip={intl.formatMessage(messages.tagVote)}
className={
this.hasCategory(comment, "vote") ? "active" : ""
}
onClick={this._handleCategoryClick(comment, "vote")}
>
<FontAwesomeIcon icon="thumbs-up" />
</a>
<a
href="javascript:void(0);"
data-tip={intl.formatMessage(messages.tagTroll)}
className={
this.isTroll(comment) ? "active troll" : "troll"
}
onClick={this._handleTrollClick(comment)}
>
<FontAwesomeIcon icon="ban" />
</a>
</div>
</div>
<div
className={
"comment-resolve " + (comment.resolved ? "resolved" : "")
}
>
<a
href="javascript:void(0);"
data-tip={intl.formatMessage(messages.tagTroll)}
className={
this.isTroll(comment) ? "active troll" : "troll"
data-tip={
intl.formatMessage(messages.tagAs) +
" " +
(comment.resolved
? intl.formatMessage(messages.commentUnresolved)
: intl.formatMessage(messages.commentResolved))
}
onClick={this._handleTrollClick(comment)}
onClick={this._handleResolveClick(comment)}
>
<FontAwesomeIcon icon="ban" />
<FontAwesomeIcon
icon={comment.resolved ? "undo-alt" : "check"}
/>
</a>
</div>
</div>
<div
className={
"comment-resolve " + (comment.resolved ? "resolved" : "")
}
>
<a
href="javascript:void(0);"
data-tip={
intl.formatMessage(messages.tagAs) +
" " +
(comment.resolved
? intl.formatMessage(messages.commentUnresolved)
: intl.formatMessage(messages.commentResolved))
}
onClick={this._handleResolveClick(comment)}
>
<FontAwesomeIcon
icon={comment.resolved ? "undo-alt" : "check"}
/>
</a>
</div>
</>
) : null}
</CommentContainer>
))}
</>
) : null}
</CommentContainer>
);
})}
<ReactTooltip effect="solid" />
</div>
);
Expand Down
Loading