mirror of
https://github.com/gitbucket/gitbucket.git
synced 2025-11-03 12:05:59 +01:00
(refs #488) Fixed the action for issue title change.
This commit is contained in:
@@ -21,7 +21,7 @@ trait IssuesControllerBase extends ControllerBase {
|
||||
|
||||
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 @@ trait IssuesControllerBase extends ControllerBase {
|
||||
"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 @@ trait IssuesControllerBase extends ControllerBase {
|
||||
}
|
||||
})
|
||||
|
||||
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 @@ trait IssuesControllerBase extends ControllerBase {
|
||||
}
|
||||
})
|
||||
|
||||
// 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}/${
|
||||
|
||||
@@ -225,14 +225,22 @@ trait IssuesService {
|
||||
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) =
|
||||
|
||||
@@ -12,8 +12,16 @@
|
||||
@html.menu("issues", repository){
|
||||
<ul class="nav nav-tabs pull-left fill-width">
|
||||
<li class="pull-left">
|
||||
<h1 id="show-title">@issue.title <span class="muted">#@issue.issueId</span></h1>
|
||||
<input type="text" style="width: 635px; display: none" id="edit-title" value="@issue.title"/>
|
||||
<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="span9" id="edit-title" value="@issue.title"/>
|
||||
</span>
|
||||
</h1>
|
||||
@if(issue.closed) {
|
||||
<span class="label label-important issue-status">Closed</span>
|
||||
} else {
|
||||
@@ -29,12 +37,15 @@
|
||||
<br/><br/>
|
||||
</li>
|
||||
<li class="pull-right">
|
||||
<div>
|
||||
<div class="show-title">
|
||||
@if(hasWritePermission || loginAccount.map(_.userName == issue.openedUserName).getOrElse(false)){
|
||||
<a class="btn btn-small" href="#" id="edit">Edit</a>
|
||||
}
|
||||
<a class="btn btn-small btn-success" href="@url(repository)/issues/new">New issue</a>
|
||||
</div>
|
||||
<div class="edit-title" style="display: none;">
|
||||
<a class="btn" href="#" id="update">Save</a> <a href="#" id="cancel">Cancel</a>
|
||||
</div>
|
||||
</li>
|
||||
</ul>
|
||||
<div class="row-fluid">
|
||||
@@ -44,8 +55,6 @@
|
||||
</div>
|
||||
<div class="span2">
|
||||
@issueinfo(issue, comments, issueLabels, collaborators, milestones, labels, hasWritePermission, repository)
|
||||
<hr/>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
}
|
||||
@@ -53,8 +62,31 @@
|
||||
<script>
|
||||
$(function(){
|
||||
$('#edit').click(function(){
|
||||
$('#edit-title').show();
|
||||
$('#show-title').hide();
|
||||
$('.edit-title').show();
|
||||
$('.show-title').hide();
|
||||
});
|
||||
|
||||
$('#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);
|
||||
});
|
||||
});
|
||||
|
||||
$('#cancel').click(function(){
|
||||
$('.edit-title').hide();
|
||||
$('.show-title').show();
|
||||
});
|
||||
});
|
||||
</script>
|
||||
Reference in New Issue
Block a user