Newer
Older
GitBucket / src / main / twirl / gitbucket / core / issues / issue.scala.html
@Naoki Takezoe Naoki Takezoe on 29 Nov 2015 3 KB Fix styles of issues and pull requests
@(issue: gitbucket.core.model.Issue,
  comments: List[gitbucket.core.model.IssueComment],
  issueLabels: List[gitbucket.core.model.Label],
  collaborators: List[String],
  milestones: List[(gitbucket.core.model.Milestone, Int, Int)],
  labels: List[gitbucket.core.model.Label],
  hasWritePermission: Boolean,
  repository: gitbucket.core.service.RepositoryService.RepositoryInfo)(implicit context: gitbucket.core.controller.Context)
@import context._
@import gitbucket.core.view.helpers._
@html.main(s"${issue.title} - Issue #${issue.issueId} - ${repository.owner}/${repository.name}", Some(repository)){
  @html.menu("issues", repository){
    <div>
      <div class="show-title pull-right">
        @if(hasWritePermission || loginAccount.map(_.userName == issue.openedUserName).getOrElse(false)){
          <a class="btn btn-default" href="#" id="edit">Edit</a>
        }
        <a class="btn btn-success" href="@url(repository)/issues/new">New issue</a>
      </div>
      <div class="edit-title pull-right" style="display: none;">
        <a class="btn btn-default" href="#" id="update">Save</a>  <a href="#" id="cancel">Cancel</a>
      </div>
      <h1>
        <span class="show-title">
          <span id="show-title">@issue.title</span>
          <span class="muted">#@issue.issueId</span>
        </span>
        <span class="edit-title" style="display: none;">
          <span id="error-edit-title" class="error"></span>
          <input type="text" class="form-control" style="width: 700px;" id="edit-title" value="@issue.title"/>
        </span>
      </h1>
    </div>
    <div style="margin-bottom: 15px">
      @if(issue.closed) {
        <span class="label label-important issue-status">Closed</span>
      } else {
        <span class="label label-success issue-status">Open</span>
      }
      <span class="muted">
        @user(issue.openedUserName, styleClass="username strong") opened this issue @helper.html.datetimeago(issue.registeredDate) - @defining(
          comments.count( _.action.contains("comment") )
        ){ count =>
          @count @plural(count, "comment")
        }
      </span>
    </div>
    <hr>
    <div class="row" style="margin-top: 15px;">
      <div class="col-md-10">
        @commentlist(Some(issue), comments, hasWritePermission, repository)
        @commentform(issue, true, hasWritePermission, repository)
      </div>
      <div class="col-md-2">
        @issueinfo(Some(issue), comments, issueLabels, collaborators, milestones, labels, hasWritePermission, repository)
      </div>
    </div>
  }
}
<script>
$(function(){
  $('#edit').click(function(){
    $('.edit-title').show();
    $('.show-title').hide();
    return false;
  });

  $('#update').click(function(){
    $(this).attr('disabled', 'disabled');
    $.ajax({
      url: '@url(repository)/issues/edit_title/@issue.issueId',
      type: 'POST',
      data: {
        title   : $('#edit-title').val()
      }
    }).done(function(data){
      $('#show-title').empty().text(data.title);
      $('#cancel').click();
      $(this).removeAttr('disabled');
    }).fail(function(req){
      $(this).removeAttr('disabled');
      $('#error-edit-title').text($.parseJSON(req.responseText).title);
    });
    return false;
  });

  $('#cancel').click(function(){
    $('.edit-title').hide();
    $('.show-title').show();
    return false;
  });
});
</script>