mirror of
https://github.com/gitbucket/gitbucket.git
synced 2025-11-18 11:20:38 +01:00
Having a default priority is now optional.
This commit is contained in:
@@ -72,7 +72,7 @@ trait PrioritiesControllerBase extends ControllerBase {
|
|||||||
})
|
})
|
||||||
|
|
||||||
ajaxPost("/:owner/:repository/issues/priorities/default")(writableUsersOnly { (repository) =>
|
ajaxPost("/:owner/:repository/issues/priorities/default")(writableUsersOnly { (repository) =>
|
||||||
setDefaultPriority(repository.owner, repository.name, params("priorityId").toInt)
|
setDefaultPriority(repository.owner, repository.name, priorityId("priorityId"))
|
||||||
Ok()
|
Ok()
|
||||||
})
|
})
|
||||||
|
|
||||||
@@ -81,6 +81,8 @@ trait PrioritiesControllerBase extends ControllerBase {
|
|||||||
Ok()
|
Ok()
|
||||||
})
|
})
|
||||||
|
|
||||||
|
val priorityId: String => Option[Int] = (key: String) => params.get(key).flatMap(_.toIntOpt)
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constraint for the identifier such as user name, repository name or page name.
|
* Constraint for the identifier such as user name, repository name or page name.
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -24,14 +24,12 @@ trait PrioritiesService {
|
|||||||
.map(m => m + 1)
|
.map(m => m + 1)
|
||||||
.getOrElse(0)
|
.getOrElse(0)
|
||||||
|
|
||||||
val isDefault = getDefaultPriority(owner, repository).isEmpty
|
|
||||||
|
|
||||||
Priorities returning Priorities.map(_.priorityId) insert Priority(
|
Priorities returning Priorities.map(_.priorityId) insert Priority(
|
||||||
userName = owner,
|
userName = owner,
|
||||||
repositoryName = repository,
|
repositoryName = repository,
|
||||||
priorityName = priorityName,
|
priorityName = priorityName,
|
||||||
description = StringUtil.emptyToNone(description),
|
description = StringUtil.emptyToNone(description),
|
||||||
isDefault = isDefault,
|
isDefault = false,
|
||||||
ordering = ordering,
|
ordering = ordering,
|
||||||
color = color
|
color = color
|
||||||
)
|
)
|
||||||
@@ -71,16 +69,16 @@ trait PrioritiesService {
|
|||||||
.headOption
|
.headOption
|
||||||
}
|
}
|
||||||
|
|
||||||
def setDefaultPriority(owner: String, repository: String, priorityId: Int)(implicit s: Session): Unit = {
|
def setDefaultPriority(owner: String, repository: String, priorityId: Option[Int])(implicit s: Session): Unit = {
|
||||||
Priorities
|
Priorities
|
||||||
.filter(_.byRepository(owner, repository))
|
.filter(_.byRepository(owner, repository))
|
||||||
.filter(_.isDefault)
|
.filter(_.isDefault)
|
||||||
.map(_.isDefault)
|
.map(_.isDefault)
|
||||||
.update(false)
|
.update(false)
|
||||||
|
|
||||||
Priorities
|
priorityId.foreach(id => Priorities
|
||||||
.filter(_.byPrimaryKey(owner, repository, priorityId))
|
.filter(_.byPrimaryKey(owner, repository, id))
|
||||||
.map(_.isDefault)
|
.map(_.isDefault)
|
||||||
.update(true)
|
.update(true))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -84,6 +84,6 @@ trait RepositoryCreationService {
|
|||||||
createPriority(userName, repositoryName, "important", "Issues can be shipped with a final product, but should be reviewed before the next release.", "fccd29")
|
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")
|
createPriority(userName, repositoryName, "default", "Default.", "acacac")
|
||||||
|
|
||||||
setDefaultPriority(userName, repositoryName, getPriority(userName, repositoryName, "default").get.priorityId)
|
setDefaultPriority(userName, repositoryName, getPriority(userName, repositoryName, "default").map(_.priorityId))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -103,11 +103,21 @@ function updatePriorityCount() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function setDefaultPriority(priorityId){
|
function setDefaultPriority(priorityId){
|
||||||
|
var $a = $('a[data-id="' + priorityId + '"].priority-default');
|
||||||
|
var isDefault = $a.data('default');
|
||||||
$.post('@helpers.url(repository)/issues/priorities/default',
|
$.post('@helpers.url(repository)/issues/priorities/default',
|
||||||
{ priorityId: priorityId },
|
{ priorityId: isDefault ? '' : priorityId },
|
||||||
function(){
|
function(){
|
||||||
$('.priority-default').removeClass('priority-default-selected');
|
$('.priority-default')
|
||||||
$('a[data-id="' + priorityId + '"] .priority-default').addClass('priority-default-selected');
|
.removeClass('priority-default-selected')
|
||||||
|
.data('default', false)
|
||||||
|
.attr('title', 'Set as default');
|
||||||
|
if (!isDefault) {
|
||||||
|
$a
|
||||||
|
.addClass('priority-default-selected')
|
||||||
|
.data('default', true)
|
||||||
|
.attr('title', 'Unset as default');
|
||||||
|
}
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -24,7 +24,7 @@
|
|||||||
<div class="col-md-1">
|
<div class="col-md-1">
|
||||||
<div class="pull-right">
|
<div class="pull-right">
|
||||||
@if(hasWritePermission){
|
@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>
|
<a href="javascript:void(0);" onclick="setDefaultPriority(@priority.priorityId)" data-id="@priority.priorityId" data-default="@priority.isDefault" class="priority-default@if(priority.isDefault){ priority-default-selected}" title="@if(priority.isDefault){Unset as default} else {Set as default}"><i class="octicon octicon-star"></i></a>
|
||||||
} else if(priority.isDefault) {
|
} else if(priority.isDefault) {
|
||||||
<i class="octicon octicon-star priority-default priority-default-selected" title="Default"></i>
|
<i class="octicon octicon-star priority-default priority-default-selected" title="Default"></i>
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -965,12 +965,12 @@ pre.reset.discussion-item-content-text{
|
|||||||
font-size: 2em;
|
font-size: 2em;
|
||||||
}
|
}
|
||||||
|
|
||||||
.priority-default {
|
.priority-default .octicon {
|
||||||
font-size: 1.5em;
|
font-size: 1.5em;
|
||||||
color: #ccc;
|
color: #ccc;
|
||||||
}
|
}
|
||||||
|
|
||||||
.priority-default-selected {
|
.priority-default-selected .octicon {
|
||||||
color: #3c8dbc;
|
color: #3c8dbc;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user