mirror of
				https://github.com/gitbucket/gitbucket.git
				synced 2025-11-03 20:15:59 +01:00 
			
		
		
		
	Add issue update in stub.
This commit is contained in:
		@@ -46,7 +46,7 @@ trait IssuesControllerBase extends ControllerBase {
 | 
			
		||||
    getIssue(owner, repository, issueId) map {
 | 
			
		||||
      issues.html.issue(
 | 
			
		||||
          _,
 | 
			
		||||
          getComment(owner, repository, issueId.toInt),
 | 
			
		||||
          getComments(owner, repository, issueId.toInt),
 | 
			
		||||
          getRepository(owner, repository, baseUrl).get)
 | 
			
		||||
    } getOrElse NotFound
 | 
			
		||||
  }
 | 
			
		||||
@@ -65,6 +65,16 @@ trait IssuesControllerBase extends ControllerBase {
 | 
			
		||||
        saveIssue(owner, repository, context.loginAccount.get.userName, form.title, form.content)))
 | 
			
		||||
  })
 | 
			
		||||
 | 
			
		||||
  // TODO Authenticator
 | 
			
		||||
  post("/:owner/:repository/issues/:id"){
 | 
			
		||||
    // TODO update issue
 | 
			
		||||
    contentType = formats("json")
 | 
			
		||||
 | 
			
		||||
    org.json4s.jackson.Serialization.write(Map(
 | 
			
		||||
        "title" -> "test title 2",
 | 
			
		||||
        "content" -> view.Markdown.toHtml("* hoge", getRepository("root", "test", baseUrl).get, false, true, true)))
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  // TODO requires users only and readable repository checking
 | 
			
		||||
  post("/:owner/:repository/issue_comments", commentForm)( usersOnly { form =>
 | 
			
		||||
    val owner = params("owner")
 | 
			
		||||
@@ -74,6 +84,23 @@ trait IssuesControllerBase extends ControllerBase {
 | 
			
		||||
        saveComment(owner, repository, context.loginAccount.get.userName, form.issueId, form.content)))
 | 
			
		||||
  })
 | 
			
		||||
 | 
			
		||||
  // TODO Authenticator
 | 
			
		||||
  post("/:owner/:repository/issue_comments/:id"){
 | 
			
		||||
    // TODO update issue memo
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  // TODO Authenticator
 | 
			
		||||
  get("/:owner/:repository/issues/_data/:id"){
 | 
			
		||||
    getIssue(params("owner"), params("repository"), params("id")) map { x =>
 | 
			
		||||
      issues.html.edit(Some(x.title), x.content.getOrElse(""), x.issueId, x.userName, x.repositoryName)
 | 
			
		||||
    } getOrElse NotFound
 | 
			
		||||
  }
 | 
			
		||||
  get("/:owner/:repository/issue_comments/_data/:id"){
 | 
			
		||||
    getComment(params("id")) map { x =>
 | 
			
		||||
      issues.html.edit(None, x.content, x.commentId, x.userName, x.repositoryName)
 | 
			
		||||
    } getOrElse NotFound
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  private def searchIssues(filter: String) = {
 | 
			
		||||
    val owner      = params("owner")
 | 
			
		||||
    val repository = params("repository")
 | 
			
		||||
 
 | 
			
		||||
@@ -21,13 +21,18 @@ trait IssuesService {
 | 
			
		||||
      } firstOption
 | 
			
		||||
    else None
 | 
			
		||||
 | 
			
		||||
  def getComment(owner: String, repository: String, issueId: Int) =
 | 
			
		||||
  def getComments(owner: String, repository: String, issueId: Int) =
 | 
			
		||||
    Query(IssueComments) filter { t =>
 | 
			
		||||
      (t.userName is owner.bind) &&
 | 
			
		||||
      (t.repositoryName is repository.bind) &&
 | 
			
		||||
      (t.issueId is issueId.bind)
 | 
			
		||||
    } list
 | 
			
		||||
 | 
			
		||||
  def getComment(commentId: String) =
 | 
			
		||||
    if (commentId forall (_.isDigit))
 | 
			
		||||
      Query(IssueComments) filter (_.commentId is commentId.toInt.bind) firstOption
 | 
			
		||||
    else None
 | 
			
		||||
 | 
			
		||||
  /**
 | 
			
		||||
   * Returns the count of the search result against  issues.
 | 
			
		||||
   *
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										29
									
								
								src/main/twirl/issues/edit.scala.html
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										29
									
								
								src/main/twirl/issues/edit.scala.html
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,29 @@
 | 
			
		||||
@(title: Option[String], content: String, key: Int, owner: String, repository: String)(implicit context: app.Context)
 | 
			
		||||
@import context._
 | 
			
		||||
@if(title.isDefined){
 | 
			
		||||
<input type="text" style="width: 730px;" id="title" value="@title.get"/>
 | 
			
		||||
}
 | 
			
		||||
<textarea style="width: 730px; height: 100px;" id="content-@key">@content</textarea>
 | 
			
		||||
<input type="button" class="btn btn-small" value="Update @{if(title.isDefined) "Issue" else "Comment"}" id="update-@key"/>
 | 
			
		||||
<span class="pull-right"><a class="btn btn-small btn-danger" href="#" id="cancel-@key">Cancel</a></span>
 | 
			
		||||
<script>
 | 
			
		||||
$(function(){
 | 
			
		||||
  $('#update-@key').click(function(){
 | 
			
		||||
    $.post('@path/@owner/@repository/@{if(title.isDefined) "issues" else "issue_comments"}/@key',
 | 
			
		||||
    {
 | 
			
		||||
      @if(title.isDefined){ title : $('#title').val(), }
 | 
			
		||||
      content : $('#content-@key').val()
 | 
			
		||||
    },
 | 
			
		||||
    function(data){
 | 
			
		||||
      @if(title.isDefined){
 | 
			
		||||
        $('#issueTitle').empty().text(data.title);
 | 
			
		||||
      }
 | 
			
		||||
      $('#issueContent').empty().html(data.content);
 | 
			
		||||
    });
 | 
			
		||||
  });
 | 
			
		||||
 | 
			
		||||
  $('#cancel-@key').click(function(){
 | 
			
		||||
 | 
			
		||||
  });
 | 
			
		||||
});
 | 
			
		||||
</script>
 | 
			
		||||
@@ -12,10 +12,11 @@
 | 
			
		||||
    <div class="span10">
 | 
			
		||||
      <div class="box">
 | 
			
		||||
        <div class="box-content">
 | 
			
		||||
          <div class="small"><a href="#">@issue.openedUserName</a> opened this issue @datetime(issue.registeredDate)</div>
 | 
			
		||||
          <h4>@issue.title</h4>
 | 
			
		||||
          <span class="pull-right"><a class="btn btn-small" href="#" id="editIssue">Edit</a></span>
 | 
			
		||||
          <div class="small"><a href="@path/@issue.openedUserName">@issue.openedUserName</a> opened this issue @datetime(issue.registeredDate)</div>
 | 
			
		||||
          <h4 id="issueTitle">@issue.title</h4>
 | 
			
		||||
        </div>
 | 
			
		||||
        <div class="box-content" style="background-color: #f5f5f5;">
 | 
			
		||||
        <div class="box-content" style="background-color: #f5f5f5;" id="issueContent">
 | 
			
		||||
          @markdown(issue.content getOrElse "No description given.", repository, false, true, true)
 | 
			
		||||
        </div>
 | 
			
		||||
      </div>
 | 
			
		||||
@@ -52,3 +53,15 @@
 | 
			
		||||
    </div>
 | 
			
		||||
  </div>
 | 
			
		||||
}
 | 
			
		||||
<script>
 | 
			
		||||
$(function(){
 | 
			
		||||
  $('#editIssue').click(function(){
 | 
			
		||||
    $.get('@path/@repository.owner/@repository.name/issues/_data/@issue.issueId',
 | 
			
		||||
    function(data){
 | 
			
		||||
      $('#issueContent').empty().html(data);
 | 
			
		||||
    });
 | 
			
		||||
    return false;
 | 
			
		||||
  });
 | 
			
		||||
 | 
			
		||||
});
 | 
			
		||||
</script>
 | 
			
		||||
		Reference in New Issue
	
	Block a user