Newer
Older
gitbucket_jkp / src / main / twirl / issues / issue.scala.html
@shimamoto shimamoto on 17 Jul 2013 9 KB (refs #11) Fix comments to display.
  1. @(issue: model.Issue,
  2. comments: List[model.IssueComment],
  3. issueLabels: List[model.Label],
  4. collaborators: List[String],
  5. milestones: List[model.Milestone],
  6. labels: List[model.Label],
  7. hasWritePermission: Boolean,
  8. repository: service.RepositoryService.RepositoryInfo)(implicit context: app.Context)
  9. @import context._
  10. @import view.helpers._
  11. @html.main("%s - Issue #%d - %s/%s".format(issue.title, issue.issueId, repository.owner, repository.name)){
  12. @html.header("issues", repository)
  13. @tab("issues", repository)
  14. <ul class="nav nav-tabs">
  15. <li class="pull-left"><a href="@url(repository)/issues"><i class="icon-arrow-left"></i> Back to issue list</a></li>
  16. <li class="pull-right">Issue #@issue.issueId</li>
  17. </ul>
  18. <div class="row-fluid">
  19. <div class="span10">
  20. <div class="issue-avatar-image">@avatar(issue.openedUserName, 48)</div>
  21. <div class="box issue-box">
  22. <div class="box-content" style="padding: 0px;">
  23. <div class="issue-header">
  24. @if(hasWritePermission || loginAccount.map(_.userName == issue.openedUserName).getOrElse(false)){
  25. <span class="pull-right"><a class="btn btn-small" href="#" id="edit">Edit</a></span>
  26. }
  27. <div class="small muted">
  28. <a href="@url(issue.openedUserName)" class="username">@issue.openedUserName</a> opened this issue @datetime(issue.registeredDate)
  29. </div>
  30. <h4 id="issueTitle">@issue.title</h4>
  31. </div>
  32. <div class="issue-info">
  33. <span id="label-assigned">
  34. @issue.assignedUserName.map { userName =>
  35. @avatar(userName, 20) <a href="@url(userName)" class="username strong">@userName</a> is assigned
  36. }.getOrElse("No one is assigned")
  37. </span>
  38. @if(hasWritePermission){
  39. @helper.html.dropdown() {
  40. <li><a href="javascript:void(0);" class="assign" data-name=""><i class="icon-remove-circle"></i> Clear assignee</a></li>
  41. <li class="divider"></li>
  42. @collaborators.map { collaborator =>
  43. <li><a href="javascript:void(0);" class="assign" data-name="@collaborator"><i class="icon-white"></i>@avatar(collaborator, 20) @collaborator</a></li>
  44. }
  45. }
  46. }
  47. <div class="pull-right">
  48. <span id="label-milestone">
  49. @issue.milestoneId.map { milestoneId =>
  50. @milestones.find(_.milestoneId == milestoneId).map { milestone =>
  51. Milestone: <strong>@milestone.title</strong>
  52. }
  53. }.getOrElse("No milestone")
  54. </span>
  55. @if(hasWritePermission){
  56. @helper.html.dropdown() {
  57. <li><a href="javascript:void(0);" class="milestone" data-id=""><i class="icon-remove-circle"></i> No milestone</a></li>
  58. <li class="divider"></li>
  59. @milestones.map { milestone =>
  60. <li><a href="javascript:void(0);" class="milestone" data-id="@milestone.milestoneId"><i class="icon-white"></i> @milestone.title</a></li>
  61. }
  62. }
  63. }
  64. </div>
  65. </div>
  66. <div class="issue-content" id="issueContent">
  67. @markdown(issue.content getOrElse "No description given.", repository, false, true)
  68. </div>
  69. </div>
  70. </div>
  71. @comments.map { comment =>
  72. @if(comment.action != "close" && comment.action != "reopen"){
  73. <div class="issue-avatar-image">@avatar(comment.commentedUserName, 48)</div>
  74. <div class="box issue-comment-box" id="comment-@comment.commentId">
  75. <div class="box-header-small">
  76. <i class="icon-comment"></i>
  77. <a href="@url(comment.commentedUserName)" class="username strong">@comment.commentedUserName</a> commented
  78. <span class="pull-right">
  79. @datetime(comment.registeredDate)
  80. @if(comment.action != "commit" && (hasWritePermission || loginAccount.map(_.userName == comment.commentedUserName).getOrElse(false))){
  81. <a href="#" data-comment-id="@comment.commentId"><i class="icon-pencil"></i></a>
  82. }
  83. </span>
  84. </div>
  85. <div class="box-content"class="issue-content" id="commentContent-@comment.commentId">
  86. @markdown(comment.content, repository, false, true)
  87. </div>
  88. </div>
  89. }
  90. @if(comment.action == "close" || comment.action == "close_comment"){
  91. <div class="small issue-comment-action">
  92. <span class="label label-important">Closed</span>
  93. <a href="@url(comment.commentedUserName)" class="username strong">@comment.commentedUserName</a> closed the issue @datetime(comment.registeredDate)
  94. </div>
  95. }
  96. @if(comment.action == "reopen" || comment.action == "reopen_comment"){
  97. <div class="small issue-comment-action">
  98. <span class="label label-success">Reopened</span>
  99. <a href="@url(comment.commentedUserName)" class="username strong">@comment.commentedUserName</a> reopened the issue @datetime(comment.registeredDate)
  100. </div>
  101. }
  102. }
  103. @if(loginAccount.isDefined){
  104. <form method="POST" validate="true">
  105. <div class="issue-avatar-image">@avatar(loginAccount.get.userName, 48)</div>
  106. <div class="box issue-comment-box">
  107. <div class="box-content">
  108. @helper.html.preview(repository, "", false, true, "width: 680px; height: 100px;")
  109. </div>
  110. </div>
  111. <div class="pull-right">
  112. <input type="hidden" name="issueId" value="@issue.issueId"/>
  113. <input type="submit" class="btn btn-success" formaction="@url(repository)/issue_comments/new" value="Comment"/>
  114. @if(hasWritePermission || issue.openedUserName == loginAccount.get.userName){
  115. <input type="submit" class="btn" formaction="@url(repository)/issue_comments/state" value="@{if(issue.closed) "Reopen" else "Close"}" id="action"/>
  116. }
  117. </div>
  118. </form>
  119. }
  120. </div>
  121. <div class="span2">
  122. @if(issue.closed) {
  123. <span class="label label-important issue-status">Closed</span>
  124. } else {
  125. <span class="label label-success issue-status">Open</span>
  126. }
  127. <div class="small" style="text-align: center;">
  128. @defining(comments.filter( _.action.contains("comment") ).size){ count =>
  129. <strong>@count</strong> @plural(count, "comment")
  130. }
  131. </div>
  132. <hr/>
  133. <div style="margin-bottom: 8px;">
  134. <strong>Labels</strong>
  135. @if(hasWritePermission){
  136. <div class="pull-right">
  137. @helper.html.dropdown() {
  138. @labels.map { label =>
  139. <li>
  140. <a href="#" class="toggle-label" data-label-id="@label.labelId">
  141. <i class="@{if(issueLabels.exists(_.labelId == label.labelId)) "icon-ok" else "icon-white"}"></i>
  142. <span class="label" style="background-color: #@label.color;">&nbsp;</span>
  143. @label.labelName
  144. </a>
  145. </li>
  146. }
  147. }
  148. </div>
  149. }
  150. </div>
  151. <ul class="label-list nav nav-pills nav-stacked">
  152. @labellist(issueLabels)
  153. </ul>
  154. </div>
  155. </div>
  156. }
  157. <script>
  158. $(function(){
  159. @if(issue.assignedUserName.isDefined){
  160. $('a.assign[data-name=@issue.assignedUserName] i').attr('class', 'icon-ok');
  161. }
  162. @if(issue.milestoneId.isDefined){
  163. $('a.milestone[data-id=@issue.milestoneId] i').attr('class', 'icon-ok');
  164. }
  165.  
  166. $('#edit').click(function(){
  167. $.get('@url(repository)/issues/_data/@issue.issueId',
  168. {
  169. dataType : 'html'
  170. },
  171. function(data){
  172. $('#issueContent').empty().html(data);
  173. });
  174. return false;
  175. });
  176.  
  177. $('a.assign').click(function(){
  178. var userName = $(this).data('name');
  179. $.post('@url(repository)/issues/@issue.issueId/assign',
  180. {
  181. assignedUserName: userName
  182. },
  183. function(){
  184. $('a.assign i.icon-ok').attr('class', 'icon-white');
  185. if(userName == ''){
  186. $('#label-assigned').text('No one is assigned');
  187. } else {
  188. $('#label-assigned').html($('<span>')
  189. .append($('<a class="username strong">').attr('href', '@path/' + userName).text(userName))
  190. .append(' is assigned'));
  191. $('a.assign[data-name=' + userName + '] i').attr('class', 'icon-ok');
  192. }
  193. });
  194. });
  195.  
  196. $('a.milestone').click(function(){
  197. var title = $(this).text();
  198. var milestoneId = $(this).data('id');
  199. $.post('@url(repository)/issues/@issue.issueId/milestone',
  200. {
  201. milestoneId: milestoneId
  202. },
  203. function(){
  204. $('a.milestone i.icon-ok').attr('class', 'icon-white');
  205. if(milestoneId == ''){
  206. $('#label-milestone').text('No milestone');
  207. } else {
  208. $('#label-milestone').html($('<span>').append('Milestone: ').append($('<strong>').text(title)));
  209. $('a.milestone[data-id=' + milestoneId + '] i').attr('class', 'icon-ok');
  210. }
  211. });
  212. });
  213.  
  214. $('i.icon-pencil').click(function(){
  215. var id = $(this).closest('a').data('comment-id');
  216. $.get('@url(repository)/issue_comments/_data/' + id,
  217. {
  218. dataType : 'html'
  219. },
  220. function(data){
  221. $('#commentContent-' + id).empty().html(data);
  222. });
  223. return false;
  224. });
  225.  
  226. $('#action').click(function(){
  227. $('<input type="hidden">').attr('name', 'action').val($(this).val().toLowerCase()).appendTo('form');
  228. });
  229.  
  230. $('a.toggle-label').click(function(){
  231. var path, icon;
  232. var i = $(this).children('i');
  233. if(i.hasClass('icon-ok')){
  234. path = 'delete';
  235. icon = 'icon-white';
  236. } else {
  237. path = 'new';
  238. icon = 'icon-ok';
  239. }
  240. $.post('@url(repository)/issues/@issue.issueId/label/' + path,
  241. {
  242. labelId : $(this).data('label-id')
  243. },
  244. function(data){
  245. i.removeClass().addClass(icon);
  246. $('ul.label-list').empty().html(data);
  247. });
  248. return false;
  249. });
  250. });
  251. </script>