Implemented the label edit process.

This commit is contained in:
shimamoto
2013-07-03 00:22:50 +09:00
parent f1ea71fbba
commit 00f921d330
3 changed files with 32 additions and 19 deletions

View File

@@ -61,7 +61,7 @@ trait IssuesControllerBase extends ControllerBase {
issues.html.issue( issues.html.issue(
_, _,
getComments(owner, repository, issueId.toInt), getComments(owner, repository, issueId.toInt),
getIssueLabel(owner, repository, issueId.toInt), getIssueLabels(owner, repository, issueId.toInt),
(getCollaborators(owner, repository) :+ owner).sorted, (getCollaborators(owner, repository) :+ owner).sorted,
getMilestones(owner, repository), getMilestones(owner, repository),
getLabels(owner, repository), getLabels(owner, repository),
@@ -115,16 +115,6 @@ trait IssuesControllerBase extends ControllerBase {
redirect("/%s/%s/issues/_data/%d".format(owner, repository, issueId)) redirect("/%s/%s/issues/_data/%d".format(owner, repository, issueId))
} }
// TODO Authenticator
ajaxPost("/:owner/:repository/issues/:id/label/:labelId/new"){
"TODO Insert!"
}
// TODO Authenticator
ajaxPost("/:owner/:repository/issues/:id/label/:labelId/delete"){
"TODO Delete!"
}
// TODO requires users only and readable repository checking // TODO requires users only and readable repository checking
post("/:owner/:repository/issue_comments/new", commentForm)( usersOnly { form => post("/:owner/:repository/issue_comments/new", commentForm)( usersOnly { form =>
val owner = params("owner") val owner = params("owner")
@@ -178,6 +168,28 @@ trait IssuesControllerBase extends ControllerBase {
} getOrElse NotFound } getOrElse NotFound
} }
// TODO Authenticator
ajaxPost("/:owner/:repository/issues/:id/label/new"){
val owner = params("owner")
val repository = params("repository")
val issueId = params("id").toInt
registerIssueLabel(owner, repository, issueId, params("labelId").toInt)
issues.html.labellist(getIssueLabels(owner, repository, issueId))
}
// TODO Authenticator
ajaxPost("/:owner/:repository/issues/:id/label/delete"){
val owner = params("owner")
val repository = params("repository")
val issueId = params("id").toInt
deleteIssueLabel(owner, repository, issueId, params("labelId").toInt)
issues.html.labellist(getIssueLabels(owner, repository, issueId))
}
ajaxPost("/:owner/:repository/issues/assign/:id"){ ajaxPost("/:owner/:repository/issues/assign/:id"){
val owner = params("owner") val owner = params("owner")
val repository = params("repository") val repository = params("repository")

View File

@@ -25,7 +25,7 @@ trait IssuesService {
Query(IssueComments) filter (_.byPrimaryKey(commentId.toInt)) firstOption Query(IssueComments) filter (_.byPrimaryKey(commentId.toInt)) firstOption
else None else None
def getIssueLabel(owner: String, repository: String, issueId: Int) = def getIssueLabels(owner: String, repository: String, issueId: Int) =
IssueLabels IssueLabels
.innerJoin(Labels).on { (t1, t2) => .innerJoin(Labels).on { (t1, t2) =>
t1.byLabel(t2.userName, t2.repositoryName, t2.labelId) t1.byLabel(t2.userName, t2.repositoryName, t2.labelId)

View File

@@ -189,21 +189,22 @@ $(function(){
}); });
$('a.toggle-label').click(function(){ $('a.toggle-label').click(function(){
var url = '@url(repository)/issues/@issue.issueId/label/' + $(this).data('label-id'); var path, icon;
var icon;
var i = $(this).children('i'); var i = $(this).children('i');
if(i.hasClass('icon-ok')){ if(i.hasClass('icon-ok')){
url += '/delete'; path = 'delete';
icon = 'icon-white'; icon = 'icon-white';
} else { } else {
url += '/new'; path = 'new';
icon = 'icon-ok'; icon = 'icon-ok';
} }
$.post(url, $.post('@url(repository)/issues/@issue.issueId/label/' + path,
{
labelId : $(this).data('label-id')
},
function(data){ function(data){
i.removeClass().addClass(icon); i.removeClass().addClass(icon);
// TODO label sort $('ul.label-list').empty().html(data);
alert(data);
}); });
return false; return false;
}); });