mirror of
https://github.com/gitbucket/gitbucket.git
synced 2025-11-08 14:35:52 +01:00
Merge branch 'new-issue-ui' of https://github.com/takezoe/gitbucket into new-issue-ui
This commit is contained in:
@@ -21,7 +21,7 @@ trait IssuesControllerBase extends ControllerBase {
|
|||||||
|
|
||||||
case class IssueCreateForm(title: String, content: Option[String],
|
case class IssueCreateForm(title: String, content: Option[String],
|
||||||
assignedUserName: Option[String], milestoneId: Option[Int], labelNames: 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 CommentForm(issueId: Int, content: String)
|
||||||
case class IssueStateForm(issueId: Int, content: Option[String])
|
case class IssueStateForm(issueId: Int, content: Option[String])
|
||||||
|
|
||||||
@@ -33,10 +33,13 @@ trait IssuesControllerBase extends ControllerBase {
|
|||||||
"labelNames" -> trim(optional(text()))
|
"labelNames" -> trim(optional(text()))
|
||||||
)(IssueCreateForm.apply)
|
)(IssueCreateForm.apply)
|
||||||
|
|
||||||
val issueEditForm = mapping(
|
val issueTitleEditForm = mapping(
|
||||||
"title" -> trim(label("Title", text(required))),
|
"title" -> trim(label("Title", text(required)))
|
||||||
"content" -> trim(optional(text()))
|
)(x => x)
|
||||||
)(IssueEditForm.apply)
|
// val issueEditForm = mapping(
|
||||||
|
// "title" -> trim(label("Title", text(required))),
|
||||||
|
// "content" -> trim(optional(text()))
|
||||||
|
// )(IssueEditForm.apply)
|
||||||
|
|
||||||
val commentForm = mapping(
|
val commentForm = mapping(
|
||||||
"issueId" -> label("Issue Id", number()),
|
"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) =>
|
defining(repository.owner, repository.name){ case (owner, name) =>
|
||||||
getIssue(owner, name, params("id")).map { issue =>
|
getIssue(owner, name, params("id")).map { issue =>
|
||||||
if(isEditable(owner, name, issue.openedUserName)){
|
if(isEditable(owner, name, issue.openedUserName)){
|
||||||
// update issue
|
// update issue
|
||||||
updateIssue(owner, name, issue.issueId, form.title, form.content)
|
updateIssueTitle(owner, name, issue.issueId, title)
|
||||||
// extract references and create refer comment
|
// 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}")
|
redirect(s"/${owner}/${name}/issues/_data/${issue.issueId}")
|
||||||
} else Unauthorized
|
} 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) =>
|
post("/:owner/:repository/issue_comments/new", commentForm)(readableUsersOnly { (form, repository) =>
|
||||||
handleComment(form.issueId, Some(form.content), repository)() map { case (issue, id) =>
|
handleComment(form.issueId, Some(form.content), repository)() map { case (issue, id) =>
|
||||||
redirect(s"/${repository.owner}/${repository.name}/${
|
redirect(s"/${repository.owner}/${repository.name}/${
|
||||||
|
|||||||
@@ -225,14 +225,22 @@ trait IssuesService {
|
|||||||
registeredDate = currentDate,
|
registeredDate = currentDate,
|
||||||
updatedDate = currentDate)
|
updatedDate = currentDate)
|
||||||
|
|
||||||
def updateIssue(owner: String, repository: String, issueId: Int,
|
def updateIssueTitle(owner: String, repository: String, issueId: Int, title: String)(implicit s: Session) =
|
||||||
title: String, content: Option[String])(implicit s: Session) =
|
|
||||||
Issues
|
Issues
|
||||||
.filter (_.byPrimaryKey(owner, repository, issueId))
|
.filter (_.byPrimaryKey(owner, repository, issueId))
|
||||||
.map { t =>
|
.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,
|
def updateAssignedUserName(owner: String, repository: String, issueId: Int,
|
||||||
assignedUserName: Option[String])(implicit s: Session) =
|
assignedUserName: Option[String])(implicit s: Session) =
|
||||||
|
|||||||
@@ -12,7 +12,16 @@
|
|||||||
@html.menu("issues", repository){
|
@html.menu("issues", repository){
|
||||||
<ul class="nav nav-tabs pull-left fill-width">
|
<ul class="nav nav-tabs pull-left fill-width">
|
||||||
<li class="pull-left">
|
<li class="pull-left">
|
||||||
<h1>@issue.title <span class="muted">#@issue.issueId</span></h1>
|
<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) {
|
@if(issue.closed) {
|
||||||
<span class="label label-important issue-status">Closed</span>
|
<span class="label label-important issue-status">Closed</span>
|
||||||
} else {
|
} else {
|
||||||
@@ -28,12 +37,15 @@
|
|||||||
<br/><br/>
|
<br/><br/>
|
||||||
</li>
|
</li>
|
||||||
<li class="pull-right">
|
<li class="pull-right">
|
||||||
<div>
|
<div class="show-title">
|
||||||
@if(hasWritePermission || loginAccount.map(_.userName == issue.openedUserName).getOrElse(false)){
|
@if(hasWritePermission || loginAccount.map(_.userName == issue.openedUserName).getOrElse(false)){
|
||||||
<a class="btn btn-small" href="#" id="edit">Edit</a>
|
<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>
|
<a class="btn btn-small btn-success" href="@url(repository)/issues/new">New issue</a>
|
||||||
</div>
|
</div>
|
||||||
|
<div class="edit-title" style="display: none;">
|
||||||
|
<a class="btn" href="#" id="update">Save</a> <a href="#" id="cancel">Cancel</a>
|
||||||
|
</div>
|
||||||
</li>
|
</li>
|
||||||
</ul>
|
</ul>
|
||||||
<div class="row-fluid">
|
<div class="row-fluid">
|
||||||
@@ -43,9 +55,38 @@
|
|||||||
</div>
|
</div>
|
||||||
<div class="span2">
|
<div class="span2">
|
||||||
@issueinfo(issue, comments, issueLabels, collaborators, milestones, labels, hasWritePermission, repository)
|
@issueinfo(issue, comments, issueLabels, collaborators, milestones, labels, hasWritePermission, repository)
|
||||||
<hr/>
|
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
<script>
|
||||||
|
$(function(){
|
||||||
|
$('#edit').click(function(){
|
||||||
|
$('.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