[Notice] Announcing the End of Demo Server [Read me]
Changsung Kim 2014-06-23
`Agree` buttons on each comment are added.
Cause:
There is a VOC. It needs a function that agrees with comments.

Solution:
`Agree` buttons which like heart shape are added on each comments.

Private-issue: 1035
@75484d64f03ea3fc81204d984cefe4d9b1b71f9e
app/assets/stylesheets/less/_page.less
--- app/assets/stylesheets/less/_page.less
+++ app/assets/stylesheets/less/_page.less
@@ -2754,6 +2754,26 @@
                                 color:@yobi-link;
                                 .opacity(100);
                             }
+
+                            &.vote-heart-disable-hover:hover {
+                              color:initial;
+                              opacity:0.2;
+                              font-size:16px;
+                            }
+                        }
+
+                        .vote-description-people {
+                            color:#3b5998
+                        }
+
+                        .vote-heart-on {
+                            font-size:16px;
+                            color:@yobi-link;
+                            opacity:1.0;
+                        }
+
+                        .vote-heart-off {
+                            font-size:16px;
                         }
                     }
 
app/assets/stylesheets/less/_yobiUI.less
--- app/assets/stylesheets/less/_yobiUI.less
+++ app/assets/stylesheets/less/_yobiUI.less
@@ -1126,6 +1126,14 @@
     outline:none;
 }
 
+.btn-transparent-with-fontsize-lineheight {
+    background:transparent;
+    border:0;
+    outline:none;
+    font-size:0px;
+    line-height:normal;
+}
+
 .numberic {
     display:inline-block;
     margin-left:5px;
app/controllers/VoteApp.java
--- app/controllers/VoteApp.java
+++ app/controllers/VoteApp.java
@@ -20,8 +20,13 @@
  */
 package controllers;
 
+import controllers.annotation.IsAllowed;
 import models.Issue;
+import models.IssueComment;
 import models.User;
+import models.enumeration.Operation;
+import org.codehaus.jackson.node.ObjectNode;
+import play.libs.Json;
 import play.mvc.Call;
 import play.mvc.With;
 import models.Project;
@@ -31,6 +36,8 @@
 import actions.AnonymousCheckAction;
 import models.enumeration.ResourceType;
 import controllers.annotation.IsCreatable;
+import utils.Constants;
+import utils.RouteUtil;
 
 import java.util.ArrayList;
 import java.util.List;
@@ -52,7 +59,8 @@
      * @return
      */
     @Transactional
-    @IsCreatable(ResourceType.ISSUE_COMMENT)
+    @With(AnonymousCheckAction.class)
+    @IsAllowed(Operation.READ)
     public static Result vote(String ownerName, String projectName, Long issueNumber) {
 
         Project project = Project.findByOwnerAndProjectName(ownerName, projectName);
@@ -76,7 +84,8 @@
      * @return
      */
     @Transactional
-    @IsCreatable(ResourceType.ISSUE_COMMENT)
+    @With(AnonymousCheckAction.class)
+    @IsAllowed(Operation.READ)
     public static Result unvote(String ownerName, String projectName, Long issueNumber) {
         Project project = Project.findByOwnerAndProjectName(ownerName, projectName);
         Issue issue = Issue.findByNumber(project, issueNumber);
@@ -88,6 +97,38 @@
         return redirect(call);
     }
 
+    @Transactional
+    @With(AnonymousCheckAction.class)
+    @IsAllowed(Operation.READ)
+    public static Result voteComment(String user, String project, Long number, Long commentId) {
+        IssueComment issueComment = IssueComment.find.byId(commentId);
+        if (issueComment == null) {
+            return notFound("issue.comment.error.vote");
+        }
+
+        issueComment.addVoter(UserApp.currentUser());
+
+        return redirect(RouteUtil.getUrl(issueComment));
+    }
+
+    @Transactional
+    @With(AnonymousCheckAction.class)
+    @IsAllowed(Operation.READ)
+    public static Result unvoteComment(String user, String project, Long number, Long commentId) {
+        IssueComment issueComment = IssueComment.find.byId(commentId);
+        if (issueComment == null) {
+            return notFound("issue.comment.error.unvote");
+        }
+
+        if (!issueComment.voters.contains(UserApp.currentUser())) {
+            return notFound("issue.comment.error.have.not.voted");
+        }
+
+        issueComment.removeVoter(UserApp.currentUser());
+
+        return redirect(RouteUtil.getUrl(issueComment));
+    }
+
     public static List<User> getVotersForAvatar(List<User> voters, int size){
         return getSubList(voters, 0, size);
     }
app/models/IssueComment.java
--- app/models/IssueComment.java
+++ app/models/IssueComment.java
@@ -22,10 +22,9 @@
 
 import models.enumeration.ResourceType;
 import models.resource.Resource;
-import org.apache.commons.lang3.builder.EqualsBuilder;
-import org.apache.commons.lang3.builder.HashCodeBuilder;
 
 import javax.persistence.*;
+import java.util.List;
 
 @Entity
 public class IssueComment extends Comment {
@@ -34,6 +33,14 @@
 
     @ManyToOne
     public Issue issue;
+
+    @ManyToMany(cascade = CascadeType.ALL)
+    @JoinTable(
+            name = "issue_comment_voter",
+            joinColumns = @JoinColumn(name = "issue_comment_id"),
+            inverseJoinColumns = @JoinColumn(name = "user_id")
+    )
+    public List<User> voters;
 
     /**
      * @see Comment#getParent()
@@ -69,4 +76,18 @@
             }
         };
     }
+
+    public void addVoter(User user) {
+        if (!this.voters.contains(user)) {
+            this.voters.add(user);
+            this.update();
+        }
+    }
+
+    public void removeVoter(User user) {
+        if (this.voters.contains(user)) {
+            this.voters.remove(user);
+            this.update();
+        }
+    }
 }
app/views/issue/partial_comments.scala.html
--- app/views/issue/partial_comments.scala.html
+++ app/views/issue/partial_comments.scala.html
@@ -63,6 +63,8 @@
     <strong>@Messages("code.commits") <a href="@routes.CodeHistoryApp.show(project.owner, project.name, commitId)" class="link">@{"@"}@commitId</a></strong>
 }
 
+@VOTER_AVATAR_SHOW_LIMIT = @{ 5 }
+
 <div class="comment-header"><i class="yobicon-comments"></i> <strong>@Messages("common.comment")</strong> <strong class="num">@issue.comments.size</strong></div>
 <hr class="nm">
 
@@ -86,12 +88,54 @@
                 </span>
                 <a href="#comment-@comment.id" class="ago" title="@JodaDateUtil.getDateString(comment.createdDate)">@utils.TemplateHelper.agoOrDateString(comment.createdDate)</a>
                 <span class="act-row pull-right">
+                    @if(isAllowed(UserApp.currentUser(), comment.asResource(), Operation.READ) && comment.isInstanceOf[IssueComment]) {
+                        @defining(comment.asInstanceOf[IssueComment]) { issueComment =>
+                            @if(issueComment.voters.size > VOTER_AVATAR_SHOW_LIMIT) {
+                                <span style="margin-right:2px;" data-toggle="tooltip" data-html="true" title="
+                                    @for(voter <- VoteApp.getVotersForName(issueComment.voters, 0, 5)) {
+                                        @voter.name<br>
+                                    }
+                                    &hellip;">
+                                    <a class="vote-description-people" href="#voters-@issueComment.id" data-toggle="modal">
+                                        @if(issueComment.voters.size == 1) {
+                                            @Messages("common.comment.vote.agreement", issueComment.voters.size)
+                                        } else {
+                                            @Messages("common.comment.vote.agreements", issueComment.voters.size)
+                                        }
+                                    </a>
+                                </span>
+
+                                @partial_voter_list("voters-" + issueComment.id, issueComment.voters)
+                            } else {
+                                @for(voter <- issueComment.voters){
+                                    <a href="@routes.UserApp.userInfo(voter.loginId)" class="avatar-wrap smaller" data-toggle="tooltip" data-placement="top" title="@voter.name" style="margin-right:3px;">
+                                        <img src="@User.findByLoginId(voter.loginId).avatarUrl">
+                                    </a>
+                                }
+                            }
+
+                            @if(issueComment.voters.contains(UserApp.currentUser())) {
+                                <button type="button" class="btn-transparent-with-fontsize-lineheight" title="@Messages("common.comment.vote")" data-request-type="comment-vote" data-request-uri="@routes.VoteApp.unvoteComment(project.owner, project.name, issue.getNumber, comment.id)">
+                                <i class="yobicon-hearts vote-heart-on"></i>
+                                </button>
+                            } else {
+                                @if(UserApp.currentUser().isAnonymous()) {
+                                    <i class="yobicon-hearts vote-heart-off vote-heart-disable-hover"></i>
+                                } else {
+                                    <button type="button" class="btn-transparent-with-fontsize-lineheight" title="@Messages("common.comment.vote")" data-request-type="comment-vote" data-request-uri="@routes.VoteApp.voteComment(project.owner, project.name, issue.getNumber, comment.id)">
+                                    <i class="yobicon-hearts vote-heart-off"></i>
+                                    </button>
+                                }
+                            }
+                        }
+                    }
+
                     @if(isAllowed(UserApp.currentUser(), comment.asResource(), Operation.UPDATE)) {
-                        <button type="button" class="btn-transparent mr10" data-toggle="comment-edit" data-comment-id="@comment.id" title="@Messages("common.comment.edit")"><i class="yobicon-edit-2"></i></button>
+                        <button type="button" class="btn-transparent-with-fontsize-lineheight ml10" data-toggle="comment-edit" data-comment-id="@comment.id" title="@Messages("common.comment.edit")"><i class="yobicon-edit-2"></i></button>
                     }
 
                     @if(isAllowed(UserApp.currentUser(), comment.asResource(), Operation.DELETE)) {
-                        <button type="button" class="btn-transparent" data-toggle="comment-delete" data-request-uri="@routes.IssueApp.deleteComment(project.owner, project.name, issue.getNumber, comment.id)" title="@Messages("common.comment.delete")"><i class="yobicon-trash"></i></button>
+                        <button type="button" class="btn-transparent-with-fontsize-lineheight ml10" data-toggle="comment-delete" data-request-uri="@routes.IssueApp.deleteComment(project.owner, project.name, issue.getNumber, comment.id)" title="@Messages("common.comment.delete")"><i class="yobicon-trash"></i></button>
                     }
                 </span>
             </div>
 
app/views/issue/partial_voter_list.scala.html (added)
+++ app/views/issue/partial_voter_list.scala.html
@@ -0,0 +1,47 @@
+@**
+* Yobi, Project Hosting SW
+*
+* Copyright 2014 NAVER Corp.
+* http://yobi.io
+*
+* @Author Changsung Kim
+*
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+*   http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+**@
+
+@(id:String, voters:Collection[User])
+
+<div id="@id" class="modal hide voters-dialog">
+    <div class="modal-header">
+        <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
+        <h5 class="nm">@Messages("issue.voters")</h5>
+    </div>
+    <div class="modal-body">
+        <ul class="unstyled">
+            @for(voter <- voters){
+            <li>
+                <a href="@routes.UserApp.userInfo(voter.loginId)" class="usf-group" target="_blank">
+                    <span class="avatar-wrap mlarge">
+                        <img src="@voter.avatarUrl" width="40" height="40">
+                    </span>
+                    <strong class="name">@voter.name</strong>
+                    <span class="loginid"> <strong>@{"@"}</strong>@voter.loginId</span>
+                </a>
+            </li>
+            }
+        </ul>
+    </div>
+    <div class="modal-footer">
+        <button class="ybtn ybtn-info ybtn-small" data-dismiss="modal" aria-hidden="true">@Messages("button.close")</button>
+    </div>
+</div>
 
conf/evolutions/default/89.sql (added)
+++ conf/evolutions/default/89.sql
@@ -0,0 +1,15 @@
+# --- !Ups
+
+CREATE TABLE issue_comment_voter (
+  issue_comment_id               BIGINT NOT NULL,
+  user_id                        BIGINT NOT NULL,
+  CONSTRAINT pk_issue_comment_voter PRIMARY KEY (issue_comment_id, user_id))
+;
+
+ALTER TABLE issue_comment_voter ADD CONSTRAINT fk_issue_comment_voter_issue FOREIGN KEY (issue_comment_id) REFERENCES issue_comment (id) ON DELETE RESTRICT ON UPDATE RESTRICT;
+ALTER TABLE issue_comment_voter ADD CONSTRAINT fk_issue_comment_voter_n4user FOREIGN KEY (user_id) REFERENCES n4user (id) ON DELETE RESTRICT ON UPDATE RESTRICT;
+
+
+# --- !Downs
+
+DROP TABLE IF EXISTS issue_comment_voter;
conf/messages
--- conf/messages
+++ conf/messages
@@ -41,6 +41,7 @@
 button.back = Back
 button.cancel = Cancel
 button.cancel.enrollment = Cancel sign-up request.
+button.close = Close
 button.comment.new = Add comments.
 button.comment.open = Open comment window
 button.commentAndNextState.closed = Comment & Close issue
@@ -140,6 +141,9 @@
 common.comment.delete = Delete comment
 common.comment.delete.confirm = Once you delete this comment, you won''t be able to recover it. Are you sure you want to delete this comment?
 common.comment.edit = Edit comment
+common.comment.vote = Agree
+common.comment.vote.agreement = {0} Agreement
+common.comment.vote.agreements = {0} Agreements
 common.editor.edit = Edit
 common.editor.preview = Preview
 common.experimental = Experimental function
@@ -221,6 +225,9 @@
 issue.can.not.be.deleted = Failed to delete because of other users'' comments
 issue.comment.delete.confirm = Once you delete this comment, you won''t be able to recover this again. Do you still want to delete it?
 issue.comment.delete.window = Delete issue comment
+issue.comment.error.vote = Failed to agree with the comment because server error has occurred.
+issue.comment.error.unvote = Failed to disagree with the comment because server error has occurred.
+issue.comment.error.have.not.voted = Failed to disagree with the comment because you have not voted this.
 issue.createdDate = Created date
 issue.delete = Delete issue
 issue.downloadAsExcel = Download as Excel file
@@ -256,7 +263,7 @@
 issue.state.closed = Closed
 issue.state.enrolled = Status entered
 issue.state.open = In progress
-issue.unvote.description = Click here if you no longer sympathize with this issue.
+issue.unvote.description = Click here if you no longer agree with this issue.
 issue.unwatch.start = You will no longer get notifications about this issue
 issue.update.assignee.id = Update assignee
 issue.update.attachLabel = Attach label
@@ -266,8 +273,8 @@
 issue.update.milestone.id = Update milestone
 issue.update.state = Update status
 issue.vote = Agree
-issue.vote.description = Click here if you sympathize with this issue.
-issue.voters = People who feels sympathies with this
+issue.vote.description = Click here if you agree with this issue.
+issue.voters = People who agree with this
 issue.voters.more = and {0} others
 issue.watch.start =Now you will get notifications about this issue
 label = Label
conf/messages.ko
--- conf/messages.ko
+++ conf/messages.ko
@@ -41,6 +41,7 @@
 button.back = λŒμ•„κ°€κΈ°
 button.cancel = μ·¨μ†Œ
 button.cancel.enrollment = 멀버 등둝 μš”μ²­ μ·¨μ†Œν•˜κΈ°
+button.close = λ‹«κΈ°
 button.comment.new = λŒ“κΈ€ μž…λ ₯
 button.comment.open = λŒ“κΈ€ μž…λ ₯ μ°½ μ—΄κΈ°
 button.commentAndNextState.closed = λŒ“κΈ€ μž…λ ₯ν•˜κ³  이슈 λ‹«κΈ°
@@ -140,6 +141,9 @@
 common.comment.delete = λŒ“κΈ€ μ‚­μ œ
 common.comment.delete.confirm = ν•΄λ‹Ή λŒ“κΈ€μ΄ μ‚­μ œλ˜λ©΄ μ˜μ›νžˆ 볡ꡬ할 수 μ—†μŠ΅λ‹ˆλ‹€. κ·Έλž˜λ„ μ‚­μ œν•˜μ‹œκ² μŠ΅λ‹ˆκΉŒ?
 common.comment.edit = λŒ“κΈ€ μˆ˜μ •
+common.comment.vote = 곡감
+common.comment.vote.agreement = {0} 곡감
+common.comment.vote.agreements = {0} 곡감
 common.editor.edit = νŽΈμ§‘
 common.editor.preview = 미리보기
 common.experimental = μ‹€ν—˜μ μΈ κΈ°λŠ₯
@@ -222,6 +226,9 @@
 issue.can.not.be.deleted = λ‹€λ₯Έ μ‚¬μš©μžμ˜ λŒ“κΈ€μ΄ μžˆμ–΄ μ‚­μ œν•  수 μ—†μŠ΅λ‹ˆλ‹€.
 issue.comment.delete.confirm = ν•΄λ‹Ή 이슈의 λŒ“κΈ€μ„ μ‚­μ œν•˜μ‹œκ² μŠ΅λ‹ˆκΉŒ?
 issue.comment.delete.window = 이슈 λŒ“κΈ€ μ‚­μ œ
+issue.comment.error.vote = μ„œλ²„ 였λ₯˜κ°€ λ°œμƒν•˜μ—¬ λŒ“κΈ€μ— 곡감을 ν•  수 μ—†μŠ΅λ‹ˆλ‹€.
+issue.comment.error.unvote = μ„œλ²„ 였λ₯˜κ°€ λ°œμƒν•˜μ—¬ λŒ“κΈ€μ— 곡감 μ·¨μ†Œλ₯Ό ν•  수 μ—†μŠ΅λ‹ˆλ‹€.
+issue.comment.error.have.not.voted = 이 λŒ“κΈ€μ— κ³΅κ°ν•˜μ§€ μ•Šμ•„μ„œ 곡감 μ·¨μ†Œλ₯Ό ν•  수 μ—†μŠ΅λ‹ˆλ‹€.
 issue.createdDate = μž‘μ„±μΌ
 issue.delete = 이슈 μ‚­μ œ
 issue.downloadAsExcel = μ—‘μ…€νŒŒμΌλ‘œ λ‹€μš΄λ°›κΈ°
conf/routes
--- conf/routes
+++ conf/routes
@@ -281,6 +281,8 @@
 # Vote
 POST           /:user/:project/issue/:number/vote                                     controllers.VoteApp.vote(user, project, number: Long)
 POST           /:user/:project/issue/:number/unvote                                   controllers.VoteApp.unvote(user, project, number: Long)
+POST           /:user/:project/issue/:number/comment/:commentId/vote                  controllers.VoteApp.voteComment(user, project, number: Long, commentId: Long)
+POST           /:user/:project/issue/:number/comment/:commentId/unvote                controllers.VoteApp.unvoteComment(user, project, number: Long, commentId: Long)
 
 # Comment Thread
 POST           /threads/:id/open                                                      controllers.CommentThreadApp.open(id: Long)
docs/ko/technical/access-control.md
--- docs/ko/technical/access-control.md
+++ docs/ko/technical/access-control.md
@@ -18,7 +18,14 @@
 * 멀버: μ €μž₯μ†Œ μ‚­μ œ(이 κΈ°λŠ₯은 아직 μ—†λ‹€)λ₯Ό μ œμ™Έν•œ λͺ¨λ“  κΆŒν•œ
 * κ·Έ μ™Έμ˜ λͺ¨λ“  μ‚¬μš©μž: λͺ¨λ“  읽기 κΆŒν•œ
 
-이슈, κ²Œμ‹œνŒ
+이슈
+---
+
+* 멀버: λͺ¨λ“  κΆŒν•œ
+* 둜그인 μ‚¬μš©μž: λͺ¨λ“  읽기 κΆŒν•œ, κ²Œμ‹œλ¬Ό/λŒ“κΈ€ 등둝, κ²Œμ‹œλ¬Ό/λŒ“κΈ€ 곡감
+* λΉ„λ‘œκ·ΈμΈ μ‚¬μš©μž: λͺ¨λ“  읽기 κΆŒν•œ
+
+κ²Œμ‹œνŒ
 ------------
 
 * 멀버: λͺ¨λ“  κΆŒν•œ
public/javascripts/service/yobi.issue.View.js
--- public/javascripts/service/yobi.issue.View.js
+++ public/javascripts/service/yobi.issue.View.js
@@ -50,7 +50,7 @@
          *
          * @private
          */
-        function _initElement(){
+        function _initElement(options){
             elements.uploader = $("#upload");
             elements.textarea = $('textarea[data-editor-mode="comment-body"]');
 
@@ -61,6 +61,8 @@
             elements.timelineList = elements.timelineWrap.find(".timeline-list");
 
             elements.dueDate = $("#issueDueDate");
+
+            elements.btnVoteComment = $(options.btnVoteComment || '[data-request-type="comment-vote"]');
         }
 
         /**
@@ -94,6 +96,9 @@
             // Watch button
             elements.btnWatch.on("click", _onClickBtnWatch);
 
+            // Vote button on comment
+            elements.btnVoteComment.on("click", _onClickCommentVote);
+
             // Update issue info
             elements.issueInfoWrap.on("change", "[data-toggle=select2]", _onChangeIssueInfo);
             elements.issueInfoWrap.on("change", "[data-toggle=calendar]", _onChangeIssueInfo);
@@ -105,6 +110,18 @@
             });
         }
 
+        function _onClickCommentVote(){
+            $.ajax($(this).data("requestUri"), {
+                "method"  : "post",
+                "success" : function(){
+                    location.reload();
+                },
+                "error" : function(res){
+                    $yobi.notify(Messages(res.responseText), 3000);
+                }
+            });
+        }
+
         /**
          * "change" event handler of issue info select2 fields.
          *
Add a comment
List