diff --git a/src/main/scala/app/IssuesController.scala b/src/main/scala/app/IssuesController.scala index b3b29e3..d7c5141 100644 --- a/src/main/scala/app/IssuesController.scala +++ b/src/main/scala/app/IssuesController.scala @@ -46,7 +46,7 @@ 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 @@ 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 @@ 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") diff --git a/src/main/scala/service/IssuesService.scala b/src/main/scala/service/IssuesService.scala index 5687a1c..b0704b8 100644 --- a/src/main/scala/service/IssuesService.scala +++ b/src/main/scala/service/IssuesService.scala @@ -21,13 +21,18 @@ } 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. * diff --git a/src/main/twirl/issues/edit.scala.html b/src/main/twirl/issues/edit.scala.html new file mode 100644 index 0000000..d78512a --- /dev/null +++ b/src/main/twirl/issues/edit.scala.html @@ -0,0 +1,29 @@ +@(title: Option[String], content: String, key: Int, owner: String, repository: String)(implicit context: app.Context) +@import context._ +@if(title.isDefined){ + +} + + +Cancel + diff --git a/src/main/twirl/issues/issue.scala.html b/src/main/twirl/issues/issue.scala.html index bfb64ae..5ec3b9f 100644 --- a/src/main/twirl/issues/issue.scala.html +++ b/src/main/twirl/issues/issue.scala.html @@ -12,10 +12,11 @@