2024-02-25 12:15:55 -05:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2020-03-26 05:06:54 -04:00
|
|
|
module CommentsHelper
|
2022-05-16 08:42:44 -04:00
|
|
|
def comment_vote_block(comment, vote)
|
|
|
|
return if comment.is_sticky
|
|
|
|
|
2020-03-26 05:06:54 -04:00
|
|
|
voted = !vote.nil?
|
|
|
|
vote_score = voted ? vote.score : 0
|
2024-02-25 10:41:35 -05:00
|
|
|
score_tag = tag.li(comment.score, class: "comment-score #{score_class(comment.score)}", id: "comment-score-#{comment.id}")
|
2020-03-26 05:06:54 -04:00
|
|
|
|
|
|
|
if CurrentUser.is_member?
|
2023-08-06 12:07:15 -04:00
|
|
|
up_tag = tag.li(
|
|
|
|
tag.a("▲", class: "comment-vote-up-link", data: { id: comment.id }),
|
|
|
|
class: confirm_score_class(vote_score, 1, false),
|
|
|
|
id: "comment-vote-up-#{comment.id}",
|
|
|
|
)
|
|
|
|
down_tag = tag.li(
|
|
|
|
tag.a("▼", class: "comment-vote-down-link", data: { id: comment.id }),
|
|
|
|
class: confirm_score_class(vote_score, -1, false),
|
|
|
|
id: "comment-vote-down-#{comment.id}",
|
|
|
|
)
|
2024-02-25 10:41:35 -05:00
|
|
|
up_tag + score_tag + down_tag
|
2020-03-26 05:06:54 -04:00
|
|
|
else
|
2024-02-25 10:41:35 -05:00
|
|
|
score_tag
|
2020-03-26 05:06:54 -04:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|