diff options
author | Ethan Koenig <etk39@cornell.edu> | 2017-03-14 21:10:35 -0400 |
---|---|---|
committer | Kim "BKC" Carlbäcker <kim.carlbacker@gmail.com> | 2017-03-15 02:10:35 +0100 |
commit | 09fe4a2ae9dfa8b3bc8a5039d0feab1e1a34d07b (patch) | |
tree | d7c595f4b004e2bfe70fc363a8258b0b26cae41b /public | |
parent | 021904e4e65804baa67b38e193e15aa37a391c60 (diff) | |
download | gitea-09fe4a2ae9dfa8b3bc8a5039d0feab1e1a34d07b.tar.gz gitea-09fe4a2ae9dfa8b3bc8a5039d0feab1e1a34d07b.zip |
Batch updates for issues (#926)
Diffstat (limited to 'public')
-rw-r--r-- | public/css/index.css | 3 | ||||
-rw-r--r-- | public/js/index.js | 80 | ||||
-rw-r--r-- | public/less/_repository.less | 4 |
3 files changed, 74 insertions, 13 deletions
diff --git a/public/css/index.css b/public/css/index.css index 54a0c23727..e840659a21 100644 --- a/public/css/index.css +++ b/public/css/index.css @@ -2270,6 +2270,9 @@ footer .ui.language .menu { #search-user-box .results .item img { margin-right: 8px; } +.issue-actions { + display: none; +} .issue.list { list-style: none; padding-top: 15px; diff --git a/public/js/index.js b/public/js/index.js index 98a0efff47..e139d16748 100644 --- a/public/js/index.js +++ b/public/js/index.js @@ -87,6 +87,20 @@ function initEditForm() { } +function updateIssuesMeta(url, action, issueIds, elementId, afterSuccess) { + $.ajax({ + type: "POST", + url: url, + data: { + "_csrf": csrf, + "action": action, + "issue_ids": issueIds, + "id": elementId + }, + success: afterSuccess + }) +} + function initCommentForm() { if ($('.comment.form').length == 0) { return @@ -100,14 +114,6 @@ function initCommentForm() { var $labelMenu = $('.select-label .menu'); var hasLabelUpdateAction = $labelMenu.data('action') == 'update'; - function updateIssueMeta(url, action, id) { - $.post(url, { - "_csrf": csrf, - "action": action, - "id": id - }); - } - $('.select-label').dropdown('setting', 'onHide', function(){ if (hasLabelUpdateAction) { location.reload(); @@ -119,13 +125,23 @@ function initCommentForm() { $(this).removeClass('checked'); $(this).find('.octicon').removeClass('octicon-check'); if (hasLabelUpdateAction) { - updateIssueMeta($labelMenu.data('update-url'), "detach", $(this).data('id')); + updateIssuesMeta( + $labelMenu.data('update-url'), + "detach", + $labelMenu.data('issue-id'), + $(this).data('id') + ); } } else { $(this).addClass('checked'); $(this).find('.octicon').addClass('octicon-check'); if (hasLabelUpdateAction) { - updateIssueMeta($labelMenu.data('update-url'), "attach", $(this).data('id')); + updateIssuesMeta( + $labelMenu.data('update-url'), + "attach", + $labelMenu.data('issue-id'), + $(this).data('id') + ); } } @@ -148,7 +164,12 @@ function initCommentForm() { }); $labelMenu.find('.no-select.item').click(function () { if (hasLabelUpdateAction) { - updateIssueMeta($labelMenu.data('update-url'), "clear", ''); + updateIssuesMeta( + $labelMenu.data('update-url'), + "clear", + $labelMenu.data('issue-id'), + "" + ); } $(this).parent().find('.item').each(function () { @@ -181,7 +202,12 @@ function initCommentForm() { $(this).addClass('selected active'); if (hasUpdateAction) { - updateIssueMeta($menu.data('update-url'), '', $(this).data('id')); + updateIssuesMeta( + $menu.data('update-url'), + "", + $menu.data('issue-id'), + $(this).data('id') + ); } switch (input_id) { case '#milestone_id': @@ -202,7 +228,12 @@ function initCommentForm() { }); if (hasUpdateAction) { - updateIssueMeta($menu.data('update-url'), '', ''); + updateIssuesMeta( + $menu.data('update-url'), + "", + $menu.data('issue-id'), + $(this).data('id') + ); } $list.find('.selected').html(''); @@ -1431,6 +1462,29 @@ $(document).ready(function () { }); $('.markdown').autolink(); + $('.issue-checkbox').click(function() { + var numChecked = $('.issue-checkbox').children('input:checked').length; + if (numChecked > 0) { + $('.issue-filters').hide(); + $('.issue-actions').show(); + } else { + $('.issue-filters').show(); + $('.issue-actions').hide(); + } + }); + + $('.issue-action').click(function () { + var action = this.dataset.action + var elementId = this.dataset.elementId + var issueIDs = $('.issue-checkbox').children('input:checked').map(function() { + return this.dataset.issueId; + }).get().join(); + var url = this.dataset.url + updateIssuesMeta(url, action, issueIDs, elementId, function() { + location.reload(); + }); + }); + buttonsClickOnEnter(); searchUsers(); searchRepositories(); diff --git a/public/less/_repository.less b/public/less/_repository.less index fcf6efda27..2009847670 100644 --- a/public/less/_repository.less +++ b/public/less/_repository.less @@ -1261,6 +1261,10 @@ } } +.issue-actions { + display: none; +} + .issue.list { list-style: none; padding-top: 15px; |