mirror of
https://github.com/gitbucket/gitbucket.git
synced 2025-11-01 11:06:06 +01:00
Implementing label editing form.
This commit is contained in:
@@ -32,6 +32,13 @@ trait LabelsControllerBase extends ControllerBase {
|
|||||||
redirect("/%s/%s/issues".format(owner, repository))
|
redirect("/%s/%s/issues".format(owner, repository))
|
||||||
})
|
})
|
||||||
|
|
||||||
|
get("/:owner/:repository/issues/label/edit")(writableRepository {
|
||||||
|
val owner = params("owner")
|
||||||
|
val repository = params("repository")
|
||||||
|
|
||||||
|
issues.html.labellist(getLabels(owner, repository), getRepository(owner, repository, baseUrl).get)
|
||||||
|
})
|
||||||
|
|
||||||
get("/:owner/:repository/issues/label/:labelId/edit")(writableRepository {
|
get("/:owner/:repository/issues/label/:labelId/edit")(writableRepository {
|
||||||
val owner = params("owner")
|
val owner = params("owner")
|
||||||
val repository = params("repository")
|
val repository = params("repository")
|
||||||
@@ -50,7 +57,7 @@ trait LabelsControllerBase extends ControllerBase {
|
|||||||
|
|
||||||
// createLabel(owner, repository, form.labelName, form.color.substring(1))
|
// createLabel(owner, repository, form.labelName, form.color.substring(1))
|
||||||
//
|
//
|
||||||
Ok("label updated.")
|
issues.html.labellist(getLabels(owner, repository), getRepository(owner, repository, baseUrl).get)
|
||||||
})
|
})
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -15,41 +15,21 @@
|
|||||||
No milestone selected
|
No milestone selected
|
||||||
<hr/>
|
<hr/>
|
||||||
<strong>Labels</strong>
|
<strong>Labels</strong>
|
||||||
<ul id="label-list" class="label-list nav nav-pills nav-stacked">
|
<div>
|
||||||
@labels.map { label =>
|
<div id="label-list">
|
||||||
<li>
|
<ul class="label-list nav nav-pills nav-stacked">
|
||||||
<a href="#">
|
@labels.map { label =>
|
||||||
<span class="count-right">0</span>
|
<li>
|
||||||
<span style="background-color: #@label.color;" class="label-color"> </span>
|
<a href="#">
|
||||||
@label.labelName
|
<span class="count-right">0</span>
|
||||||
</a>
|
<span style="background-color: #@label.color;" class="label-color"> </span>
|
||||||
</li>
|
@label.labelName
|
||||||
}
|
</a>
|
||||||
</ul>
|
</li>
|
||||||
<ul id="label-edit" class="label-list nav nav-pills nav-stacked" style="display: none;">
|
}
|
||||||
@labels.map { label =>
|
</ul>
|
||||||
<li style="border: 1px solid white;">
|
</div>
|
||||||
<a href="javascript:void(0);" class="label-edit-link" labelId="@label.labelId" labelName="@label.labelName" color="#@label.color">
|
</div>
|
||||||
<span class="count-right"><i class="icon-remove-circle" onclick="alert('delete!');"></i></span>
|
|
||||||
<span style="background-color: #@label.color;" class="label-color"> </span>
|
|
||||||
@label.labelName
|
|
||||||
</a>
|
|
||||||
</li>
|
|
||||||
}
|
|
||||||
@*
|
|
||||||
<form id="editLabelForm" style="display: none; margin-bottom: 8px;">
|
|
||||||
<span id="error-editLabelName" class="error"></span>
|
|
||||||
<input type="text" name="editLabelName" id="editLabelName" value="" style="width: 180px; margin-left: 8px; margin-bottom: 0px;"/>
|
|
||||||
<span id="error-editColor" class="error"></span>
|
|
||||||
<div class="input-append color bscp" data-color="#888888" data-color-format="hex" id="editColor" style="width: 180px; margin-bottom: 0px;">
|
|
||||||
<input type="text" class="span3" name="editColor" value="" readonly style="width: 168px; margin-left: 8px;"/>
|
|
||||||
<span class="add-on"><i style="background-color: #888888;"></i></span>
|
|
||||||
</div>
|
|
||||||
<input type="hidden" name="editLabelId"/>
|
|
||||||
<input type="submit" class="btn label-submit" value="Save" style="margin-left: 8px; margin-bottom: 0px;"/>
|
|
||||||
</form>
|
|
||||||
*@
|
|
||||||
</ul>
|
|
||||||
<hr/>
|
<hr/>
|
||||||
<input type="button" class="btn btn-block" id="manageLabel" data-toggle="button" value="Manage Labels"/>
|
<input type="button" class="btn btn-block" id="manageLabel" data-toggle="button" value="Manage Labels"/>
|
||||||
<br/>
|
<br/>
|
||||||
@@ -102,50 +82,18 @@
|
|||||||
}
|
}
|
||||||
<script>
|
<script>
|
||||||
$(function(){
|
$(function(){
|
||||||
$('#editColor').colorpicker();
|
|
||||||
|
|
||||||
$('#manageLabel').click(function(){
|
$('#manageLabel').click(function(){
|
||||||
if($(this).data('toggle-state')){
|
if($(this).data('toggle-state')){
|
||||||
location.href = '@path/@repository.owner/@repository.name/issues';
|
location.href = '@path/@repository.owner/@repository.name/issues';
|
||||||
} else {
|
} else {
|
||||||
$(this).data('toggle-state', 'on');
|
$(this).data('toggle-state', 'on');
|
||||||
$('#label-list').hide();
|
$.get('@path/@repository.owner/@repository.name/issues/label/edit', function(data){
|
||||||
$('#label-edit').show();
|
var parent = $('#label-list').parent();
|
||||||
|
$('#label-list').remove();
|
||||||
|
parent.append(data);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
$('a.label-edit-link').click(function(e){
|
|
||||||
e.stopPropagation();
|
|
||||||
if($('input[name=editLabelId]').val() != $(this).attr('labelId')){
|
|
||||||
showEditLabelForm(this);
|
|
||||||
} else {
|
|
||||||
hideEditLabelForm();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
$('body').click(function(){
|
|
||||||
hideEditLabelForm();
|
|
||||||
});
|
|
||||||
|
|
||||||
function showEditLabelForm(element){
|
|
||||||
$('#editLabelForm').remove();
|
|
||||||
|
|
||||||
$.ajax({
|
|
||||||
method: 'GET',
|
|
||||||
url: '@path/@repository.owner/@repository.name/issues/label/' + $(element).attr('labelId') + '/edit',
|
|
||||||
dataType: 'html',
|
|
||||||
success: function(data){
|
|
||||||
$(element).parent().append(data);
|
|
||||||
$('ul#label-edit li').css('border', '1px solid white');
|
|
||||||
$(element).parent().css('border', '1px solid #eee');
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
function hideEditLabelForm(){
|
|
||||||
$('#editLabelForm').remove();
|
|
||||||
$('ul#label-edit li').css('border', '1px solid white');
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
<style type="text/css">
|
<style type="text/css">
|
||||||
@@ -156,7 +104,7 @@ ul.label-list {
|
|||||||
font-size: 90%;
|
font-size: 90%;
|
||||||
}
|
}
|
||||||
|
|
||||||
ul.label-list li a {
|
ul.label-list a {
|
||||||
padding-left: 6px;
|
padding-left: 6px;
|
||||||
padding-top: 4px;
|
padding-top: 4px;
|
||||||
padding-bottom: 4px;
|
padding-bottom: 4px;
|
||||||
|
|||||||
@@ -1,8 +1,8 @@
|
|||||||
@(label: Option[model.Label], repository: service.RepositoryService.RepositoryInfo)(implicit context: app.Context)
|
@(label: Option[model.Label], repository: service.RepositoryService.RepositoryInfo)(implicit context: app.Context)
|
||||||
@import context._
|
@import context._
|
||||||
@defining((if(label.isEmpty) ("new", 190, 4) else ("edit", 180, 8))){ case (mode, width, margin) =>
|
@defining((if(label.isEmpty) ("new", 190, 4) else ("edit", 180, 8))){ case (mode, width, margin) =>
|
||||||
<div id="@(mode)LabelForm">
|
<div id="@(mode)LabelArea">
|
||||||
<form method="POST"
|
<form method="POST" id="edit-label-form"
|
||||||
action="@path/@repository.owner/@repository.name/issues/label/@{if(mode == "new") "new" else label.get.labelId + "/edit"}"
|
action="@path/@repository.owner/@repository.name/issues/label/@{if(mode == "new") "new" else label.get.labelId + "/edit"}"
|
||||||
validate="true" @if(mode == "edit"){ style="margin-bottom: 8px;"}>
|
validate="true" @if(mode == "edit"){ style="margin-bottom: 8px;"}>
|
||||||
<span id="error-@(mode)LabelName" class="error"></span>
|
<span id="error-@(mode)LabelName" class="error"></span>
|
||||||
@@ -25,12 +25,25 @@
|
|||||||
} else {
|
} else {
|
||||||
$('#editColor').colorpicker();
|
$('#editColor').colorpicker();
|
||||||
|
|
||||||
$('#editLabelForm').click(function(e){
|
$('#edit-label-form').submit(function(e){
|
||||||
e.stopPropagation();
|
var form = $(e.target);
|
||||||
});
|
$.post(form.attr('action') + '/validate', $(form).serialize(), function(data){
|
||||||
|
// clear all error messages
|
||||||
|
$('.error').text('');
|
||||||
|
|
||||||
$.each($('form[validate=true]'), function(i, form){
|
if($.isEmptyObject(data)){
|
||||||
$(form).submit(validate);
|
$.post(form.attr('action'), $(form).serialize(), function(data){
|
||||||
|
var parent = $('#label-edit').parent();
|
||||||
|
$('#label-edit').remove();
|
||||||
|
parent.append(data);
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
$.each(data, function(key, value){
|
||||||
|
$('#error-' + key).text(value);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}, 'json');
|
||||||
|
return false;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|||||||
39
src/main/twirl/issues/labellist.scala.html
Normal file
39
src/main/twirl/issues/labellist.scala.html
Normal file
@@ -0,0 +1,39 @@
|
|||||||
|
@(labels: List[model.Label], repository: service.RepositoryService.RepositoryInfo)(implicit context: app.Context)
|
||||||
|
@import context._
|
||||||
|
<div id="label-edit">
|
||||||
|
<ul class="label-list nav nav-pills nav-stacked">
|
||||||
|
@labels.map { label =>
|
||||||
|
<li style="border: 1px solid white;">
|
||||||
|
<a href="javascript:void(0);" class="label-edit-link" labelId="@label.labelId" labelName="@label.labelName" color="#@label.color">
|
||||||
|
<span class="count-right"><i class="icon-remove-circle" labelId="@label.labelId"></i></span>
|
||||||
|
<span style="background-color: #@label.color;" class="label-color"> </span>
|
||||||
|
@label.labelName
|
||||||
|
</a>
|
||||||
|
</li>
|
||||||
|
}
|
||||||
|
</ul>
|
||||||
|
<script>
|
||||||
|
$('i.icon-remove-circle').click(function(e){
|
||||||
|
e.stopPropagation();
|
||||||
|
// TODO Delete label
|
||||||
|
alert('Delete this label. Are you Sure?');
|
||||||
|
});
|
||||||
|
|
||||||
|
$('a.label-edit-link').click(function(e){
|
||||||
|
if($('input[name=editLabelId]').val() != $(this).attr('labelId')){
|
||||||
|
$('#editLabelArea').remove();
|
||||||
|
var element = this;
|
||||||
|
$.get('@path/@repository.owner/@repository.name/issues/label/' + $(this).attr('labelId') + '/edit',
|
||||||
|
function(data){
|
||||||
|
$(element).parent().append(data);
|
||||||
|
$('div#label-edit li').css('border', '1px solid white');
|
||||||
|
$(element).parent().css('border', '1px solid #eee');
|
||||||
|
}
|
||||||
|
);
|
||||||
|
} else {
|
||||||
|
$('#editLabelArea').remove();
|
||||||
|
$('div#label-edit li').css('border', '1px solid white');
|
||||||
|
}
|
||||||
|
});
|
||||||
|
</script>
|
||||||
|
</div>
|
||||||
Reference in New Issue
Block a user