Implemented the issue label display.

This commit is contained in:
shimamoto
2013-07-02 13:02:25 +09:00
parent 46aa327ded
commit 3c17aa3da2
3 changed files with 15 additions and 4 deletions

View File

@@ -60,6 +60,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),
getRepository(owner, repository, baseUrl).get) getRepository(owner, repository, baseUrl).get)
} getOrElse NotFound } getOrElse NotFound
} }

View File

@@ -25,6 +25,15 @@ 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) =
IssueLabels
.innerJoin(Labels).on { (t1, t2) =>
t1.byLabel(t2.userName, t2.repositoryName, t2.labelId)
}
.filter ( _._1.byIssue(owner, repository, issueId) )
.map ( _._2 )
.list
/** /**
* Returns the count of the search result against issues. * Returns the count of the search result against issues.
* *
@@ -171,7 +180,7 @@ trait IssuesService {
} get } get
def registerIssueLabel(owner: String, repository: String, issueId: Int, labelId: Int): Unit = def registerIssueLabel(owner: String, repository: String, issueId: Int, labelId: Int): Unit =
IssueLabels.* insert (IssueLabel(owner, repository, issueId, labelId)) IssueLabels insert (IssueLabel(owner, repository, issueId, labelId))
def createComment(owner: String, repository: String, loginUser: String, def createComment(owner: String, repository: String, loginUser: String,
issueId: Int, content: String, action: Option[String]) = issueId: Int, content: String, action: Option[String]) =

View File

@@ -1,4 +1,4 @@
@(issue: model.Issue, comments: List[model.IssueComment], repository: service.RepositoryService.RepositoryInfo)(implicit context: app.Context) @(issue: model.Issue, comments: List[model.IssueComment], issueLabels: List[model.Label], repository: service.RepositoryService.RepositoryInfo)(implicit context: app.Context)
@import context._ @import context._
@import view.helpers._ @import view.helpers._
@html.main("%s - Issue #%d - %s/%s".format(issue.title, issue.issueId, repository.owner, repository.name)){ @html.main("%s - Issue #%d - %s/%s".format(issue.title, issue.issueId, repository.owner, repository.name)){
@@ -77,8 +77,9 @@
</div> </div>
</div> </div>
<ul class="label-list"> <ul class="label-list">
<li><span class="label" style="background-color: #f89406;">improvement</span></li> @issueLabels.map { label =>
<li><span class="label" style="background-color: #3a87ad;">not bug</span></li> <li><span class="label" style="background-color: #@label.color;">@label.labelName</span></li>
}
</ul> </ul>
</div> </div>
</div> </div>