mirror of
https://github.com/gitbucket/gitbucket.git
synced 2026-07-10 19:12:36 +02:00
Default priority feature implemented.
This commit is contained in:
@@ -114,6 +114,7 @@ trait IssuesControllerBase extends ControllerBase {
|
||||
getAssignableUserNames(owner, name),
|
||||
getMilestones(owner, name),
|
||||
getPriorities(owner, name),
|
||||
getDefaultPriority(owner, name),
|
||||
getLabels(owner, name),
|
||||
isIssueManageable(repository),
|
||||
getContentTemplate(repository, "ISSUE_TEMPLATE"),
|
||||
|
||||
@@ -71,6 +71,11 @@ trait PrioritiesControllerBase extends ControllerBase {
|
||||
Ok()
|
||||
})
|
||||
|
||||
ajaxPost("/:owner/:repository/issues/priorities/default")(writableUsersOnly { (repository) =>
|
||||
setDefaultPriority(repository.owner, repository.name, params("priorityId").toInt)
|
||||
Ok()
|
||||
})
|
||||
|
||||
ajaxPost("/:owner/:repository/issues/priorities/:priorityId/delete")(writableUsersOnly { repository =>
|
||||
deletePriority(repository.owner, repository.name, params("priorityId").toInt)
|
||||
Ok()
|
||||
|
||||
@@ -10,8 +10,9 @@ trait PriorityComponent extends TemplateComponent { self: Profile =>
|
||||
override val priorityName = column[String]("PRIORITY_NAME")
|
||||
val description = column[String]("DESCRIPTION")
|
||||
val ordering = column[Int]("ORDERING")
|
||||
val isDefault = column[Boolean]("IS_DEFAULT")
|
||||
val color = column[String]("COLOR")
|
||||
def * = (userName, repositoryName, priorityId, priorityName, description, ordering, color) <> (Priority.tupled, Priority.unapply)
|
||||
def * = (userName, repositoryName, priorityId, priorityName, description, isDefault, ordering, color) <> (Priority.tupled, Priority.unapply)
|
||||
|
||||
def byPrimaryKey(owner: String, repository: String, priorityId: Int) = byPriority(owner, repository, priorityId)
|
||||
def byPrimaryKey(userName: Rep[String], repositoryName: Rep[String], priorityId: Rep[Int]) = byPriority(userName, repositoryName, priorityId)
|
||||
@@ -24,6 +25,7 @@ case class Priority (
|
||||
priorityId: Int = 0,
|
||||
priorityName: String,
|
||||
description: String,
|
||||
isDefault: Boolean,
|
||||
ordering: Int = 0,
|
||||
color: String){
|
||||
|
||||
|
||||
@@ -23,11 +23,14 @@ trait PrioritiesService {
|
||||
.map(m => m + 1)
|
||||
.getOrElse(0)
|
||||
|
||||
val isDefault = getDefaultPriority(owner, repository).isEmpty
|
||||
|
||||
Priorities returning Priorities.map(_.priorityId) insert Priority(
|
||||
userName = owner,
|
||||
repositoryName = repository,
|
||||
priorityName = priorityName,
|
||||
description = description,
|
||||
isDefault = isDefault,
|
||||
ordering = ordering,
|
||||
color = color
|
||||
)
|
||||
@@ -58,4 +61,25 @@ trait PrioritiesService {
|
||||
|
||||
Priorities.filter(_.byPrimaryKey(owner, repository, priorityId)).delete
|
||||
}
|
||||
|
||||
def getDefaultPriority(owner: String, repository: String)(implicit s: Session): Option[Priority] = {
|
||||
Priorities
|
||||
.filter(_.byRepository(owner, repository))
|
||||
.filter(_.isDefault)
|
||||
.list
|
||||
.headOption
|
||||
}
|
||||
|
||||
def setDefaultPriority(owner: String, repository: String, priorityId: Int)(implicit s: Session): Unit = {
|
||||
Priorities
|
||||
.filter(_.byRepository(owner, repository))
|
||||
.filter(_.isDefault)
|
||||
.map(_.isDefault)
|
||||
.update(false)
|
||||
|
||||
Priorities
|
||||
.filter(_.byPrimaryKey(owner, repository, priorityId))
|
||||
.map(_.isDefault)
|
||||
.update(true)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -83,5 +83,7 @@ trait RepositoryCreationService {
|
||||
createPriority(userName, repositoryName, "high", "Issues should be addressed before a final product is delivered. If the issue cannot be resolved before delivery, it should be prioritized for the next release.", "fc9629")
|
||||
createPriority(userName, repositoryName, "important", "Issues can be shipped with a final product, but should be reviewed before the next release.", "fccd29")
|
||||
createPriority(userName, repositoryName, "default", "Default.", "acacac")
|
||||
|
||||
setDefaultPriority(userName, repositoryName, getPriority(userName, repositoryName, "default").get.priorityId)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
@(collaborators: List[String],
|
||||
milestones: List[gitbucket.core.model.Milestone],
|
||||
priorities: List[gitbucket.core.model.Priority],
|
||||
defaultPriority: Option[gitbucket.core.model.Priority],
|
||||
labels: List[gitbucket.core.model.Label],
|
||||
isManageable: Boolean,
|
||||
content: String,
|
||||
@@ -30,7 +31,7 @@
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-md-3">
|
||||
@gitbucket.core.issues.html.issueinfo(None, Nil, Nil, collaborators, milestones.map(x => (x, 0, 0)), priorities, labels, isManageable, repository)
|
||||
@gitbucket.core.issues.html.issueinfo(None, Nil, Nil, collaborators, milestones.map(x => (x, 0, 0)), priorities, defaultPriority, labels, isManageable, repository)
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
|
||||
@@ -55,7 +55,7 @@
|
||||
@gitbucket.core.issues.html.commentform(issue, true, isEditable, isManageable, repository)
|
||||
</div>
|
||||
<div class="col-md-3">
|
||||
@gitbucket.core.issues.html.issueinfo(Some(issue), comments, issueLabels, collaborators, milestones, priorities, labels, isManageable, repository)
|
||||
@gitbucket.core.issues.html.issueinfo(Some(issue), comments, issueLabels, collaborators, milestones, priorities, None, labels, isManageable, repository)
|
||||
</div>
|
||||
</div>
|
||||
}
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
collaborators: List[String],
|
||||
milestones: List[(gitbucket.core.model.Milestone, Int, Int)],
|
||||
priorities: List[gitbucket.core.model.Priority],
|
||||
defaultPriority: Option[gitbucket.core.model.Priority],
|
||||
labels: List[gitbucket.core.model.Label],
|
||||
isManageable: Boolean,
|
||||
repository: gitbucket.core.service.RepositoryService.RepositoryInfo)(implicit context: gitbucket.core.controller.Context)
|
||||
@@ -43,7 +44,7 @@
|
||||
@priorities.map { priority =>
|
||||
<li>
|
||||
<a href="javascript:void(0);" class="priority" data-id="@priority.priorityId" data-name="@priority.priorityName" data-color="#@priority.color" data-font-color="#@priority.fontColor" title="@priority.description">
|
||||
@gitbucket.core.helper.html.checkicon(issue.flatMap(is => is.priorityId).map(id => id == priority.priorityId).getOrElse(false))
|
||||
@gitbucket.core.helper.html.checkicon(issue.flatMap(_.priorityId).orElse(defaultPriority.map(_.priorityId)).map(id => id == priority.priorityId).getOrElse(false))
|
||||
<span class="label" style="background-color: #@priority.color;"> </span>
|
||||
@priority.priorityName
|
||||
</a>
|
||||
@@ -54,7 +55,7 @@
|
||||
}
|
||||
</div>
|
||||
<span id="label-priority">
|
||||
@issue.flatMap(_.priorityId).map { priorityId =>
|
||||
@issue.flatMap(_.priorityId).orElse(defaultPriority.map(_.priorityId)).map { priorityId =>
|
||||
@priorities.collect { case priority if(priority.priorityId == priorityId) =>
|
||||
<a class="issue-priority" style="background-color: #@priority.color; color: #@priority.fontColor;" href="@helpers.url(repository)/issues?priority=@helpers.urlEncode(priority.priorityName)&state=open" title="@priority.description">@priority.priorityName</a>
|
||||
}
|
||||
@@ -63,7 +64,7 @@
|
||||
}
|
||||
</span>
|
||||
@if(issue.isEmpty){
|
||||
<input type="hidden" name="priorityId" value=""/>
|
||||
<input type="hidden" name="priorityId" value="@defaultPriority.map(_.priorityId).map(_.toString).getOrElse("")"/>
|
||||
}
|
||||
<hr/>
|
||||
|
||||
|
||||
@@ -101,4 +101,14 @@ function updatePriorityCount() {
|
||||
var $counter = $('#priority-row-header span');
|
||||
$counter.text($counter.text().replace(/\d+/, $('tr.priority-row').size()));
|
||||
}
|
||||
|
||||
function setDefaultPriority(priorityId){
|
||||
$.post('@helpers.url(repository)/issues/priorities/default',
|
||||
{ priorityId: priorityId },
|
||||
function(){
|
||||
$('.priority-default').removeClass('priority-default-selected');
|
||||
$('a[data-id="' + priorityId + '"] .priority-default').addClass('priority-default-selected');
|
||||
}
|
||||
);
|
||||
}
|
||||
</script>
|
||||
|
||||
@@ -18,10 +18,19 @@
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-md-6">
|
||||
<div class="@if(hasWritePermission){col-md-6} else {col-md-8}">
|
||||
<span>@priority.description</span>
|
||||
</div>
|
||||
<div class="@if(hasWritePermission){col-md-2} else {col-md-4}">
|
||||
<div class="col-md-1">
|
||||
<div class="pull-right">
|
||||
@if(hasWritePermission){
|
||||
<a href="javascript:void(0);" onclick="setDefaultPriority(@priority.priorityId)" data-id="@priority.priorityId"><i class="octicon octicon-star priority-default@if(priority.isDefault){ priority-default-selected}" title="@if(priority.isDefault){Default} else {Set as default}"></i></a>
|
||||
} else if(priority.isDefault) {
|
||||
<i class="octicon octicon-star priority-default priority-default-selected" title="Default"></i>
|
||||
}
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-md-1">
|
||||
<div class="pull-right">
|
||||
<span class="muted">@counts.get(priority.priorityName).getOrElse(0) open issues</span>
|
||||
</div>
|
||||
|
||||
@@ -82,7 +82,7 @@
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-md-3">
|
||||
@gitbucket.core.issues.html.issueinfo(None, Nil, Nil, collaborators, milestones.map((_, 0, 0)), priorities, labels, hasOriginWritePermission, repository)
|
||||
@gitbucket.core.issues.html.issueinfo(None, Nil, Nil, collaborators, milestones.map((_, 0, 0)), priorities, None, labels, hasOriginWritePermission, repository)
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
|
||||
@@ -46,7 +46,7 @@
|
||||
}
|
||||
</div>
|
||||
<div class="col-md-3">
|
||||
@gitbucket.core.issues.html.issueinfo(Some(issue), comments, issueLabels, collaborators, milestones, priorities, labels, isManageable, repository)
|
||||
@gitbucket.core.issues.html.issueinfo(Some(issue), comments, issueLabels, collaborators, milestones, priorities, None, labels, isManageable, repository)
|
||||
</div>
|
||||
<script>
|
||||
$(function(){
|
||||
|
||||
@@ -964,6 +964,15 @@ pre.reset.discussion-item-content-text{
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
.priority-default {
|
||||
font-size: 1.5em;
|
||||
color: #ccc;
|
||||
}
|
||||
|
||||
.priority-default-selected {
|
||||
color: #3c8dbc;
|
||||
}
|
||||
|
||||
/****************************************************************************/
|
||||
/* Pull request */
|
||||
/****************************************************************************/
|
||||
|
||||
Reference in New Issue
Block a user