From 342baf1ddaa9beb6d856c8f9725093cbbe5d80ac Mon Sep 17 00:00:00 2001 From: FuXiaoHei Date: Mon, 19 May 2014 21:55:25 +0800 Subject: [PATCH] add label edit and manage ui --- public/css/gogs.css | 8 +++++++- public/js/app.js | 38 ++++++++++++++++++++++++++++++++++++++ templates/issue/list.tmpl | 31 +++++++++++++++++++++++++++---- 3 files changed, 72 insertions(+), 5 deletions(-) diff --git a/public/css/gogs.css b/public/css/gogs.css index a8311188d60..bfca9d83eec 100755 --- a/public/css/gogs.css +++ b/public/css/gogs.css @@ -1297,7 +1297,7 @@ html, body { display: block; } -#issue .label-filter a:hover { +#issue .label-filter li.label-item:hover { background-color: #FFF; } @@ -1316,6 +1316,12 @@ html, body { margin-top: 6px; } +#issue .label-filter .del { + margin-top: -24px; + color: #888; + display: none; +} + #issue .label-filter .label-button { margin-top: 16px; } diff --git a/public/js/app.js b/public/js/app.js index d7514f795df..53948578b92 100644 --- a/public/js/app.js +++ b/public/js/app.js @@ -612,6 +612,44 @@ function initIssue() { $('#milestone').text($('#milestone').data("no-milestone")); } }); + + // labels + $('#label-manage-btn').on("click", function () { + var $list = $('#label-list'); + if ($list.hasClass("managing")) { + var ids = []; + $list.find('li').each(function (i, item) { + var id = $(item).data("id"); + if (id > 0) { + ids.push(id); + } + }); + $.post($list.data("ajax"), {"ids": ids.join(",")}, function (json) { + if (json.ok) { + window.location.reload(); + } + }) + } else { + $list.addClass("managing"); + $list.find(".count").hide(); + $list.find(".del").show(); + $(this).text("Save Labels"); + $list.on('click', 'li.label-item', function () { + var $this = $(this); + $this.after($('.label-change-li').detach().show()); + $('#label-name-change-ipt').val($this.find('.name').text()); + var color = $this.find('.color').data("color"); + $('.label-change-color-picker').colorpicker("setValue", color); + $('#label-color-change-ipt').val(color); + $('#label-change-id-ipt').val($this.data("id")); + return false; + }); + } + }); + $("#label-list").on('click', '.del', function () { + $(this).parent().remove(); + return false; + }); } function initRelease() { diff --git a/templates/issue/list.tmpl b/templates/issue/list.tmpl index 480e047b850..edf855932d5 100644 --- a/templates/issue/list.tmpl +++ b/templates/issue/list.tmpl @@ -15,19 +15,39 @@

Label

-