mirror of
https://github.com/gitbucket/gitbucket.git
synced 2025-11-04 20:45:58 +01:00
Label editing is available!
This commit is contained in:
@@ -36,7 +36,10 @@ trait LabelsControllerBase extends ControllerBase {
|
||||
val owner = params("owner")
|
||||
val repository = params("repository")
|
||||
|
||||
issues.html.labellist(getLabels(owner, repository), getRepository(owner, repository, baseUrl).get)
|
||||
getRepository(owner, repository, baseUrl) match {
|
||||
case None => NotFound()
|
||||
case Some(r) => issues.html.labellist(getLabels(owner, repository), r)
|
||||
}
|
||||
})
|
||||
|
||||
get("/:owner/:repository/issues/label/:labelId/edit")(writableRepository {
|
||||
@@ -44,9 +47,12 @@ trait LabelsControllerBase extends ControllerBase {
|
||||
val repository = params("repository")
|
||||
val labelId = params("labelId").toInt
|
||||
|
||||
getLabel(owner, repository, labelId) match {
|
||||
getRepository(owner, repository, baseUrl) match {
|
||||
case None => NotFound()
|
||||
case Some(l) => issues.html.labeledit(Some(l), getRepository(owner, repository, baseUrl).get)
|
||||
case Some(r) => getLabel(owner, repository, labelId) match {
|
||||
case None => NotFound()
|
||||
case Some(l) => issues.html.labeledit(Some(l), r)
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
@@ -55,9 +61,27 @@ trait LabelsControllerBase extends ControllerBase {
|
||||
val repository = params("repository")
|
||||
val labelId = params("labelId").toInt
|
||||
|
||||
// createLabel(owner, repository, form.labelName, form.color.substring(1))
|
||||
//
|
||||
issues.html.labellist(getLabels(owner, repository), getRepository(owner, repository, baseUrl).get)
|
||||
getRepository(owner, repository, baseUrl) match {
|
||||
case None => NotFound()
|
||||
case Some(r) => {
|
||||
updateLabel(owner, repository, labelId, form.labelName, form.color.substring(1))
|
||||
issues.html.labellist(getLabels(owner, repository), r)
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
get("/:owner/:repository/issues/label/:labelId/delete")(writableRepository {
|
||||
val owner = params("owner")
|
||||
val repository = params("repository")
|
||||
val labelId = params("labelId").toInt
|
||||
|
||||
getRepository(owner, repository, baseUrl) match {
|
||||
case None => NotFound()
|
||||
case Some(r) => {
|
||||
deleteLabel(owner, repository, labelId)
|
||||
issues.html.labellist(getLabels(owner, repository), r)
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
}
|
||||
@@ -24,4 +24,22 @@ trait LabelsService {
|
||||
def createLabel(owner: String, repository: String, labelName: String, color: String): Unit =
|
||||
Labels.ins insert (owner, repository, labelName, color)
|
||||
|
||||
def updateLabel(owner: String, repository: String, labelId: Int, labelName: String, color: String): Unit =
|
||||
Query(Labels)
|
||||
.filter { l => (l.userName is owner.bind) && (l.repositoryName is repository.bind) && (l.labelId is labelId.bind)}
|
||||
.map { l => l.labelName ~ l.color }
|
||||
.update (labelName, color)
|
||||
|
||||
def deleteLabel(owner: String, repository: String, labelId: Int): Unit = {
|
||||
// TODO delete ISSUE_LABEL
|
||||
// Query(Issues)
|
||||
// .filter { i => (i.userName is owner.bind) && (i.repositoryName is repository.bind) && (i.milestoneId is milestoneId.bind)}
|
||||
// .map { i => i.milestoneId.? }
|
||||
// .update(None)
|
||||
|
||||
Query(Labels)
|
||||
.filter { i => (i.userName is owner.bind) && (i.repositoryName is repository.bind) && (i.labelId is labelId.bind)}
|
||||
.delete
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -15,8 +15,15 @@
|
||||
<script>
|
||||
$('i.icon-remove-circle').click(function(e){
|
||||
e.stopPropagation();
|
||||
// TODO Delete label
|
||||
alert('Delete this label. Are you Sure?');
|
||||
if(confirm('Delete this label. Are you Sure?')){
|
||||
$.get('@path/@repository.owner/@repository.name/issues/label/' + $(this).attr('labelId') + '/delete',
|
||||
function(data){
|
||||
var parent = $('#label-edit').parent();
|
||||
$('#label-edit').remove();
|
||||
parent.append(data);
|
||||
}
|
||||
);
|
||||
}
|
||||
});
|
||||
|
||||
$('a.label-edit-link').click(function(e){
|
||||
|
||||
Reference in New Issue
Block a user