able edit issue labels/milestone/assignee

This commit is contained in:
Unknwon 2015-08-15 00:42:43 +08:00
parent d07c081920
commit cec38f2a8c
12 changed files with 279 additions and 217 deletions

File diff suppressed because one or more lines are too long

View file

@ -26,13 +26,30 @@ function initCommentForm() {
// Labels
var $list = $('.ui.labels.list');
var $no_select = $list.find('.no-select');
$('.select-label .menu .item:not(.no-select)').click(function () {
var $label_menu = $('.select-label .menu');
var has_label_update_action = $label_menu.data('action') == 'update';
function updateIssueMeta(url, action, id) {
$.post(url, {
"_csrf": csrf,
"action": action,
"id": id
});
}
$label_menu.find('.item:not(.no-select)').click(function () {
if ($(this).hasClass('checked')) {
$(this).removeClass('checked')
$(this).find('.octicon').removeClass('octicon-check')
if (has_label_update_action) {
updateIssueMeta($label_menu.data('update-url'), "detach", $(this).data('id'));
}
} else {
$(this).addClass('checked')
$(this).find('.octicon').addClass('octicon-check')
if (has_label_update_action) {
updateIssueMeta($label_menu.data('update-url'), "attach", $(this).data('id'));
}
}
var label_ids = "";
@ -52,7 +69,11 @@ function initCommentForm() {
$($(this).parent().data('id')).val(label_ids);
return false;
});
$('.select-label .menu .no-select.item').click(function () {
$label_menu.find('.no-select.item').click(function () {
if (has_label_update_action) {
updateIssueMeta($label_menu.data('update-url'), "clear", '');
}
$(this).parent().find('.item').each(function () {
$(this).removeClass('checked');
$(this).find('.octicon').removeClass('octicon-check');
@ -68,12 +89,17 @@ function initCommentForm() {
function selectItem(select_id, input_id) {
var $menu = $(select_id + ' .menu');
var $list = $('.ui' + select_id + '.list')
var has_update_action = $menu.data('action') == 'update';
$menu.find('.item:not(.no-select)').click(function () {
$(this).parent().find('.item').each(function () {
$(this).removeClass('selected active')
});
$(this).addClass('selected active');
if (has_update_action) {
updateIssueMeta($menu.data('update-url'), '', $(this).data('id'));
}
switch (input_id) {
case '#milestone_id':
$list.find('.selected').html('<a class="item" href=' + $(this).data('href') + '>' +
@ -92,6 +118,11 @@ function initCommentForm() {
$(this).removeClass('selected active')
});
if (has_update_action) {
updateIssueMeta($menu.data('update-url'), '', '');
}
$list.find('.selected').html('');
$list.find('.no-select').removeClass('hide');
$(input_id).val('');
@ -235,6 +266,14 @@ function initRepository() {
$(document).ready(function () {
csrf = $('meta[name=_csrf]').attr("content");
// Show exact time
$('.time-since').each(function () {
$(this).addClass('poping up').
attr('data-content', $(this).attr('title')).
attr('data-variation', 'inverted tiny').
attr('title', '');
});
// Semantic UI modules.
$('.dropdown').dropdown();
$('.jump.dropdown').dropdown({

View file

@ -99,6 +99,10 @@ img {
padding-left: 0.75rem;
vertical-align: middle;
}
.avatar.image {
border-radius: 3px;
}
}
footer {

View file

@ -38,9 +38,6 @@
overflow-x: auto;
}
.ui.list {
.ui.avatar.image {
border-radius: 0;
}
.hide {
display: none!important;
}
@ -116,7 +113,7 @@
}
}
.assignee {
margin-top: -10px;
margin-top: -5px;
margin-right: 5px;
}
}