diff --git a/src/main/scala/app/IssuesController.scala b/src/main/scala/app/IssuesController.scala index 503ae60..bd4a900 100644 --- a/src/main/scala/app/IssuesController.scala +++ b/src/main/scala/app/IssuesController.scala @@ -21,7 +21,7 @@ case class IssueCreateForm(title: String, content: Option[String], assignedUserName: Option[String], milestoneId: Option[Int], labelNames: Option[String]) - case class IssueEditForm(title: String, content: Option[String]) +// case class IssueEditForm(title: String, content: Option[String]) case class CommentForm(issueId: Int, content: String) case class IssueStateForm(issueId: Int, content: Option[String]) @@ -33,10 +33,13 @@ "labelNames" -> trim(optional(text())) )(IssueCreateForm.apply) - val issueEditForm = mapping( - "title" -> trim(label("Title", text(required))), - "content" -> trim(optional(text())) - )(IssueEditForm.apply) + val issueTitleEditForm = mapping( + "title" -> trim(label("Title", text(required))) + )(x => x) +// val issueEditForm = mapping( +// "title" -> trim(label("Title", text(required))), +// "content" -> trim(optional(text())) +// )(IssueEditForm.apply) val commentForm = mapping( "issueId" -> label("Issue Id", number()), @@ -118,14 +121,15 @@ } }) - ajaxPost("/:owner/:repository/issues/edit/:id", issueEditForm)(readableUsersOnly { (form, repository) => + ajaxPost("/:owner/:repository/issues/edit_title/:id", issueTitleEditForm)(readableUsersOnly { (title, repository) => defining(repository.owner, repository.name){ case (owner, name) => getIssue(owner, name, params("id")).map { issue => if(isEditable(owner, name, issue.openedUserName)){ // update issue - updateIssue(owner, name, issue.issueId, form.title, form.content) + updateIssueTitle(owner, name, issue.issueId, title) // extract references and create refer comment - createReferComment(owner, name, issue, form.title + " " + form.content.getOrElse("")) + // TODO Confirmation(about "issue" parameter) + createReferComment(owner, name, issue, title) redirect(s"/${owner}/${name}/issues/_data/${issue.issueId}") } else Unauthorized @@ -133,6 +137,21 @@ } }) +// ajaxPost("/:owner/:repository/issues/edit/:id", issueEditForm)(readableUsersOnly { (form, repository) => +// defining(repository.owner, repository.name){ case (owner, name) => +// getIssue(owner, name, params("id")).map { issue => +// if(isEditable(owner, name, issue.openedUserName)){ +// // update issue +// updateIssue(owner, name, issue.issueId, form.title, form.content) +// // extract references and create refer comment +// createReferComment(owner, name, issue, form.title + " " + form.content.getOrElse("")) +// +// redirect(s"/${owner}/${name}/issues/_data/${issue.issueId}") +// } else Unauthorized +// } getOrElse NotFound +// } +// }) + post("/:owner/:repository/issue_comments/new", commentForm)(readableUsersOnly { (form, repository) => handleComment(form.issueId, Some(form.content), repository)() map { case (issue, id) => redirect(s"/${repository.owner}/${repository.name}/${ diff --git a/src/main/scala/service/IssuesService.scala b/src/main/scala/service/IssuesService.scala index 9e7bfa6..2e834df 100644 --- a/src/main/scala/service/IssuesService.scala +++ b/src/main/scala/service/IssuesService.scala @@ -225,14 +225,22 @@ registeredDate = currentDate, updatedDate = currentDate) - def updateIssue(owner: String, repository: String, issueId: Int, - title: String, content: Option[String])(implicit s: Session) = + def updateIssueTitle(owner: String, repository: String, issueId: Int, title: String)(implicit s: Session) = Issues .filter (_.byPrimaryKey(owner, repository, issueId)) .map { t => - (t.title, t.content.?, t.updatedDate) + (t.title, t.updatedDate) } - .update (title, content, currentDate) + .update (title, currentDate) + +// def updateIssue(owner: String, repository: String, issueId: Int, +// title: String, content: Option[String])(implicit s: Session) = +// Issues +// .filter (_.byPrimaryKey(owner, repository, issueId)) +// .map { t => +// (t.title, t.content.?, t.updatedDate) +// } +// .update (title, content, currentDate) def updateAssignedUserName(owner: String, repository: String, issueId: Int, assignedUserName: Option[String])(implicit s: Session) = diff --git a/src/main/twirl/issues/issue.scala.html b/src/main/twirl/issues/issue.scala.html index 70dfdde..8345bbc 100644 --- a/src/main/twirl/issues/issue.scala.html +++ b/src/main/twirl/issues/issue.scala.html @@ -12,8 +12,16 @@ @html.menu("issues", repository){
@@ -44,8 +55,6 @@
@issueinfo(issue, comments, issueLabels, collaborators, milestones, labels, hasWritePermission, repository) -
-
} @@ -53,8 +62,31 @@ \ No newline at end of file