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/js | |
parent | 021904e4e65804baa67b38e193e15aa37a391c60 (diff) | |
download | gitea-09fe4a2ae9dfa8b3bc8a5039d0feab1e1a34d07b.tar.gz gitea-09fe4a2ae9dfa8b3bc8a5039d0feab1e1a34d07b.zip |
Batch updates for issues (#926)
Diffstat (limited to 'public/js')
-rw-r--r-- | public/js/index.js | 80 |
1 files changed, 67 insertions, 13 deletions
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(); |