mirror of
https://github.com/gitbucket/gitbucket.git
synced 2025-11-01 11:06:06 +01:00
Issue label creation is available.
This commit is contained in:
@@ -6,11 +6,11 @@ import service._
|
|||||||
import util.{WritableRepositoryAuthenticator, ReadableRepositoryAuthenticator, UsersOnlyAuthenticator}
|
import util.{WritableRepositoryAuthenticator, ReadableRepositoryAuthenticator, UsersOnlyAuthenticator}
|
||||||
|
|
||||||
class IssuesController extends IssuesControllerBase
|
class IssuesController extends IssuesControllerBase
|
||||||
with IssuesService with RepositoryService with AccountService
|
with IssuesService with RepositoryService with AccountService with LabelsService
|
||||||
with UsersOnlyAuthenticator with ReadableRepositoryAuthenticator with WritableRepositoryAuthenticator
|
with UsersOnlyAuthenticator with ReadableRepositoryAuthenticator with WritableRepositoryAuthenticator
|
||||||
|
|
||||||
trait IssuesControllerBase extends ControllerBase {
|
trait IssuesControllerBase extends ControllerBase {
|
||||||
self: IssuesService with RepositoryService
|
self: IssuesService with RepositoryService with LabelsService
|
||||||
with UsersOnlyAuthenticator with ReadableRepositoryAuthenticator with WritableRepositoryAuthenticator =>
|
with UsersOnlyAuthenticator with ReadableRepositoryAuthenticator with WritableRepositoryAuthenticator =>
|
||||||
|
|
||||||
case class IssueForm(title: String, content: Option[String])
|
case class IssueForm(title: String, content: Option[String])
|
||||||
@@ -37,8 +37,8 @@ trait IssuesControllerBase extends ControllerBase {
|
|||||||
case "closed" => true
|
case "closed" => true
|
||||||
} getOrElse false
|
} getOrElse false
|
||||||
|
|
||||||
issues.html.issues(searchIssue(owner, repository, closed),
|
issues.html.issues(searchIssue(owner, repository, closed), getLabels(owner, repository),
|
||||||
getRepository(params("owner"), params("repository"), baseUrl).get)
|
getRepository(owner, repository, baseUrl).get)
|
||||||
}
|
}
|
||||||
|
|
||||||
get("/:owner/:repository/issues/:id"){
|
get("/:owner/:repository/issues/:id"){
|
||||||
|
|||||||
@@ -1,7 +1,29 @@
|
|||||||
package app
|
package app
|
||||||
|
|
||||||
|
import jp.sf.amateras.scalatra.forms._
|
||||||
|
import service._
|
||||||
|
import util.WritableRepositoryAuthenticator
|
||||||
|
|
||||||
class LabelsController extends LabelsControllerBase
|
class LabelsController extends LabelsControllerBase
|
||||||
|
with LabelsService with RepositoryService with AccountService with WritableRepositoryAuthenticator
|
||||||
|
|
||||||
trait LabelsControllerBase extends ControllerBase {
|
trait LabelsControllerBase extends ControllerBase {
|
||||||
|
self: LabelsService with WritableRepositoryAuthenticator =>
|
||||||
|
|
||||||
|
case class LabelForm(labelName: String, color: String)
|
||||||
|
|
||||||
|
val labelForm = mapping(
|
||||||
|
"labelName" -> trim(label("Label name", text(required, maxlength(100)))),
|
||||||
|
"color" -> trim(label("Color", text(required, maxlength(7))))
|
||||||
|
)(LabelForm.apply)
|
||||||
|
|
||||||
|
post("/:owner/:repository/issues/label/new", labelForm)(writableRepository { form =>
|
||||||
|
val owner = params("owner")
|
||||||
|
val repository = params("repository")
|
||||||
|
|
||||||
|
createLabel(owner, repository, form.labelName, form.color.substring(1))
|
||||||
|
|
||||||
|
redirect("/%s/%s/issues".format(owner, repository))
|
||||||
|
})
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -16,4 +16,7 @@ trait LabelsService {
|
|||||||
.sortBy(_.labelName asc)
|
.sortBy(_.labelName asc)
|
||||||
.list
|
.list
|
||||||
|
|
||||||
|
def createLabel(owner: String, repository: String, labelName: String, color: String): Unit =
|
||||||
|
Labels.ins insert (owner, repository, labelName, color)
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
@(issues: List[model.Issue], repository: service.RepositoryService.RepositoryInfo)(implicit context: app.Context)
|
@(issues: List[model.Issue], labels: List[model.Label], repository: service.RepositoryService.RepositoryInfo)(implicit context: app.Context)
|
||||||
@import context._
|
@import context._
|
||||||
@import view.helpers._
|
@import view.helpers._
|
||||||
@html.main("Issues - " + repository.owner + "/" + repository.name){
|
@html.main("Issues - " + repository.owner + "/" + repository.name){
|
||||||
@@ -15,11 +15,27 @@
|
|||||||
No milestone selected
|
No milestone selected
|
||||||
<hr/>
|
<hr/>
|
||||||
<strong>Labels</strong>
|
<strong>Labels</strong>
|
||||||
|
<ul class="label-list">
|
||||||
|
@labels.map { label =>
|
||||||
|
<li>
|
||||||
|
<span style="float: right; font-weight: bold;">0</span>
|
||||||
|
<span style="background-color: #@label.color;" class="label-color"> </span>
|
||||||
|
@label.labelName
|
||||||
|
</li>
|
||||||
|
}
|
||||||
|
</ul>
|
||||||
<hr/>
|
<hr/>
|
||||||
<a class="btn btn-block" href="#">Manage Labels</a>
|
<a class="btn btn-block" href="#">Manage Labels</a>
|
||||||
<br/>
|
<br/>
|
||||||
<strong>New label</strong>
|
<strong>New label</strong>
|
||||||
<input type="text" name="labelName" value="" placeholder="New label name"/>
|
<form method="POST" action="@path/@repository.owner/@repository.name/issues/label/new" validate="true">
|
||||||
|
<input type="text" name="labelName" value="" placeholder="New label name"/>
|
||||||
|
<div class="input-append color bscp" data-color="#ff0000" data-color-format="hex" id="cp3">
|
||||||
|
<input type="text" class="span3" name="color" value="" readonly style="width: 100%;">
|
||||||
|
<span class="add-on"><i style="background-color: #ff0000;"></i></span>
|
||||||
|
</div>
|
||||||
|
<input type="submit" class="btn" value="Create"/>
|
||||||
|
</form>
|
||||||
</div>
|
</div>
|
||||||
<div class="span9">
|
<div class="span9">
|
||||||
<div class="pagination pull-right">
|
<div class="pagination pull-right">
|
||||||
@@ -64,4 +80,28 @@
|
|||||||
</table>
|
</table>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
}
|
}
|
||||||
|
<script>
|
||||||
|
$(function(){
|
||||||
|
$('#cp3').colorpicker();
|
||||||
|
});
|
||||||
|
</script>
|
||||||
|
<style type="text/css">
|
||||||
|
ul.label-list {
|
||||||
|
list-style-type: none;
|
||||||
|
padding-left: 0px;
|
||||||
|
margin-left: 0px;
|
||||||
|
font-size: 90%;
|
||||||
|
color: #444;
|
||||||
|
}
|
||||||
|
|
||||||
|
ul.label-list li {
|
||||||
|
margin-bottom: 4px;
|
||||||
|
}
|
||||||
|
|
||||||
|
span.label-color {
|
||||||
|
border-radius: 2px;
|
||||||
|
-webkit-border-radius: 2px;
|
||||||
|
-moz-border-radius: 2px;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
@@ -14,12 +14,14 @@
|
|||||||
<script src="@path/assets/bootstrap/js/html5shiv.js"></script>
|
<script src="@path/assets/bootstrap/js/html5shiv.js"></script>
|
||||||
<![endif]-->
|
<![endif]-->
|
||||||
<link href="@path/assets/datepicker/css/datepicker.css" rel="stylesheet">
|
<link href="@path/assets/datepicker/css/datepicker.css" rel="stylesheet">
|
||||||
|
<link href="@path/assets/colorpicker/css/bootstrap-colorpicker.css" rel="stylesheet">
|
||||||
<link href="@path/assets/common/css/gitbucket.css" rel="stylesheet">
|
<link href="@path/assets/common/css/gitbucket.css" rel="stylesheet">
|
||||||
<script src="@path/assets/common/js/jquery-1.9.1.js"></script>
|
<script src="@path/assets/common/js/jquery-1.9.1.js"></script>
|
||||||
<script src="@path/assets/common/js/validation.js"></script>
|
<script src="@path/assets/common/js/validation.js"></script>
|
||||||
<script src="@path/assets/common/js/gitbucket.js"></script>
|
<script src="@path/assets/common/js/gitbucket.js"></script>
|
||||||
<script src="@path/assets/bootstrap/js/bootstrap.js"></script>
|
<script src="@path/assets/bootstrap/js/bootstrap.js"></script>
|
||||||
<script src="@path/assets/datepicker/js/bootstrap-datepicker.js"></script>
|
<script src="@path/assets/datepicker/js/bootstrap-datepicker.js"></script>
|
||||||
|
<script src="@path/assets/colorpicker/js/bootstrap-colorpicker.js"></script>
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
<div class="navbar navbar-inverse">
|
<div class="navbar navbar-inverse">
|
||||||
|
|||||||
Reference in New Issue
Block a user