[Notice] Announcing the End of Demo Server [Read me]

Review: show comment form directly on thread
@bdf9ef6f8f7ba736846d518613474607c833aa9a
--- app/utils/TemplateHelper.scala
+++ app/utils/TemplateHelper.scala
... | ... | @@ -438,6 +438,32 @@ |
438 | 438 |
case _ => "" |
439 | 439 |
} |
440 | 440 |
} |
441 |
+ |
|
442 |
+ def urlToPostNewComment(thread: CommentThread) = { |
|
443 |
+ if(thread.isOnPullRequest){ |
|
444 |
+ routes.PullRequestApp.newComment(thread.project.owner, thread.project.name, thread.pullRequest.id, _getCommitId(thread)) |
|
445 |
+ } else { |
|
446 |
+ routes.CodeHistoryApp.newComment(thread.project.owner, thread.project.name, _getCommitId(thread)) |
|
447 |
+ } |
|
448 |
+ } |
|
449 |
+ |
|
450 |
+ def _getCommitId(thread: CommentThread) = { |
|
451 |
+ thread match { |
|
452 |
+ case (t: CodeCommentThread) => |
|
453 |
+ t.commitId |
|
454 |
+ case (t: models.NonRangedCodeCommentThread) => |
|
455 |
+ t.commitId |
|
456 |
+ case _ => "" |
|
457 |
+ } |
|
458 |
+ } |
|
459 |
+ |
|
460 |
+ def getResourceType(thread: CommentThread) = { |
|
461 |
+ if(thread.isOnPullRequest){ |
|
462 |
+ models.enumeration.ResourceType.REVIEW_COMMENT |
|
463 |
+ } else { |
|
464 |
+ models.enumeration.ResourceType.COMMIT_COMMENT |
|
465 |
+ } |
|
466 |
+ } |
|
441 | 467 |
} |
442 | 468 |
|
443 | 469 |
object CodeBrowser { |
+++ app/views/partial_comment_form_on_thread.scala.html
... | ... | @@ -0,0 +1,72 @@ |
1 | +@** | |
2 | +* Yobi, Project Hosting SW | |
3 | +* | |
4 | +* Copyright 2014 NAVER Corp. | |
5 | +* http://yobi.io | |
6 | +* | |
7 | +* @Author Jihan Kim | |
8 | +* | |
9 | +* Licensed under the Apache License, Version 2.0 (the "License"); | |
10 | +* you may not use this file except in compliance with the License. | |
11 | +* You may obtain a copy of the License at | |
12 | +* | |
13 | +* http://www.apache.org/licenses/LICENSE-2.0 | |
14 | +* | |
15 | +* Unless required by applicable law or agreed to in writing, software | |
16 | +* distributed under the License is distributed on an "AS IS" BASIS, | |
17 | +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |
18 | +* See the License for the specific language governing permissions and | |
19 | +* limitations under the License. | |
20 | +**@ | |
21 | +@(thread: CommentThread) | |
22 | + | |
23 | +@import utils.TemplateHelper._ | |
24 | +@import utils.TemplateHelper.DiffRenderer._ | |
25 | + | |
26 | +@changeThreadStateButton = { | |
27 | + @if(utils.AccessControl.isAllowed(UserApp.currentUser(), thread.asResource(), Operation.UPDATE)){ | |
28 | + @if(thread.state == CommentThread.ThreadState.OPEN) { | |
29 | + <button type="button" data-request-method="post" data-request-uri="@routes.CommentThreadApp.close(thread.id)" class="ybtn ybtn-default ybtn-small">@Messages("commentThread.close")</button> | |
30 | + } else { | |
31 | + <button type="button" data-request-method="post" data-request-uri="@routes.CommentThreadApp.open(thread.id)" class="ybtn ybtn-default ybtn-small">@Messages("commentThread.open")</button> | |
32 | + } | |
33 | + } | |
34 | +} | |
35 | + | |
36 | +@defining(getResourceType(thread)) { resourceType => | |
37 | + @if(utils.AccessControl.isProjectResourceCreatable(UserApp.currentUser(), thread.project, resourceType)){ | |
38 | + <div class="write-comment-form"> | |
39 | + <form action="@urlToPostNewComment(thread)" method="post" enctype="multipart/form-data" class="review-form" style="display:block;"> | |
40 | + <input type="hidden" name="thread.id" value="@thread.id"> | |
41 | + <div class="author-info-wrap pull-left"> | |
42 | + <div class="author-info"> | |
43 | + <a href="@routes.UserApp.userInfo(UserApp.currentUser().loginId)" class="avatar-wrap medium" | |
44 | + title="@UserApp.currentUser().name" data-toggle="tooltip" data-placement="top"> | |
45 | + <img src="@UserApp.currentUser().avatarUrl" width="32" height="32"> | |
46 | + </a> | |
47 | + </div> | |
48 | + </div> | |
49 | + <div class="write-comment-box"> | |
50 | + <div class="write-comment-wrap"> | |
51 | + @common.editor("contents", "" , "style=height:100px", "code-review-body") | |
52 | + | |
53 | + @** fileUploader **@ | |
54 | + @if(!UserApp.currentUser.isAnonymous){ | |
55 | + @common.uploadForm(resourceType) | |
56 | + } | |
57 | + @** end of fileUploader **@ | |
58 | + | |
59 | + <div class="right-txt"> | |
60 | + @changeThreadStateButton | |
61 | + <button type="submit" class="ybtn ybtn-success ybtn-small">@Messages("button.comment.new")</button> | |
62 | + </div> | |
63 | + </div> | |
64 | + </div> | |
65 | + </form> | |
66 | + </div> | |
67 | + } else { | |
68 | + <p class="thread-actrow"> | |
69 | + @changeThreadStateButton | |
70 | + </p> | |
71 | + } | |
72 | +} |
--- app/views/partial_comment_thread.scala.html
+++ app/views/partial_comment_thread.scala.html
... | ... | @@ -21,8 +21,6 @@ |
21 | 21 |
@(thread: CommentThread) |
22 | 22 |
|
23 | 23 |
@import utils.JodaDateUtil |
24 |
-@import utils.TemplateHelper._ |
|
25 |
-@import utils.TemplateHelper.DiffRenderer._ |
|
26 | 24 |
|
27 | 25 |
<div id="thread-@thread.id" data-state="@thread.state.toString().toLowerCase()" |
28 | 26 |
class="comment-thread-wrap @thread.state.toString().toLowerCase() |
... | ... | @@ -79,19 +77,5 @@ |
79 | 77 |
} |
80 | 78 |
</ul> |
81 | 79 |
|
82 |
- <div class="write-comment-form"></div> |
|
83 |
- |
|
84 |
- <p class="thread-actrow"> |
|
85 |
- @if(utils.AccessControl.isAllowed(UserApp.currentUser(), thread.asResource(), Operation.UPDATE)){ |
|
86 |
- @if(thread.state == CommentThread.ThreadState.OPEN) { |
|
87 |
- <button type="button" data-request-method="post" data-request-uri="@routes.CommentThreadApp.close(thread.id)" class="ybtn ybtn-default ybtn-small">@Messages("commentThread.close")</button> |
|
88 |
- } else { |
|
89 |
- <button type="button" data-request-method="post" data-request-uri="@routes.CommentThreadApp.open(thread.id)" class="ybtn ybtn-default ybtn-small">@Messages("commentThread.open")</button> |
|
90 |
- } |
|
91 |
- } |
|
92 |
- |
|
93 |
- @if(utils.AccessControl.isProjectResourceCreatable(UserApp.currentUser(), thread.project, ResourceType.REVIEW_COMMENT)){ |
|
94 |
- <button type="button" class="ybtn ybtn-info ybtn-small btn-thread" data-thread-id="@thread.id">@Messages("button.comment.open")</button> |
|
95 |
- } |
|
96 |
- </p> |
|
80 |
+ @partial_comment_form_on_thread(thread) |
|
97 | 81 |
</div> |
--- public/javascripts/service/yobi.code.Diff.js
+++ public/javascripts/service/yobi.code.Diff.js
... | ... | @@ -293,6 +293,23 @@ |
293 | 293 |
"sUploaderId" : oUploader.attr("data-namespace") |
294 | 294 |
})); |
295 | 295 |
} |
296 |
+ |
|
297 |
+ $("form.review-form").each(function(i, el){ |
|
298 |
+ var form = $(el); |
|
299 |
+ var container = form.find(".upload-wrap"); |
|
300 |
+ var textarea = form.find("textarea"); |
|
301 |
+ var uploader = yobi.Files.getUploader(container, textarea); |
|
302 |
+ |
|
303 |
+ if(uploader){ |
|
304 |
+ (new yobi.Attachments({ |
|
305 |
+ "elTextarea" : textarea, |
|
306 |
+ "elContainer" : container, |
|
307 |
+ "sTplFileItem" : htVar.sTplFileItem, |
|
308 |
+ "sUploaderId" : uploader.attr("data-namespace") |
|
309 |
+ })); |
|
310 |
+ |
|
311 |
+ } |
|
312 |
+ }); |
|
296 | 313 |
} |
297 | 314 |
|
298 | 315 |
/** |
Add a comment
Delete comment
Once you delete this comment, you won't be able to recover it. Are you sure you want to delete this comment?