diff options
Diffstat (limited to 'web_src/js/index.js')
-rw-r--r-- | web_src/js/index.js | 43 |
1 files changed, 35 insertions, 8 deletions
diff --git a/web_src/js/index.js b/web_src/js/index.js index a0e410c133..93b27483be 100644 --- a/web_src/js/index.js +++ b/web_src/js/index.js @@ -158,7 +158,7 @@ function initLabelEdit() { }); } -function updateIssuesMeta(url, action, issueIds, elementId) { +function updateIssuesMeta(url, action, issueIds, elementId, isAdd) { return new Promise(((resolve) => { $.ajax({ type: 'POST', @@ -167,7 +167,8 @@ function updateIssuesMeta(url, action, issueIds, elementId) { _csrf: csrf, action, issue_ids: issueIds, - id: elementId + id: elementId, + is_add: isAdd }, success: resolve }); @@ -390,7 +391,8 @@ function initCommentForm() { label['update-url'], label.action, label['issue-id'], - elementId + elementId, + label['is-checked'] ); promises.push(promise); }); @@ -400,22 +402,30 @@ function initCommentForm() { $listMenu.find('.item:not(.no-select)').click(function () { // we don't need the action attribute when updating assignees - if (selector === 'select-assignees-modify') { + if (selector === 'select-assignees-modify' || selector === 'select-reviewers-modify') { // UI magic. We need to do this here, otherwise it would destroy the functionality of // adding/removing labels + + if ($(this).data('can-change') === 'block') { + return false; + } + if ($(this).hasClass('checked')) { $(this).removeClass('checked'); $(this).find('.octicon-check').addClass('invisible'); + $(this).data('is-checked', 'remove'); } else { $(this).addClass('checked'); $(this).find('.octicon-check').removeClass('invisible'); + $(this).data('is-checked', 'add'); } updateIssuesMeta( $listMenu.data('update-url'), '', $listMenu.data('issue-id'), - $(this).data('id') + $(this).data('id'), + $(this).data('is-checked') ); $listMenu.data('action', 'update'); // Update to reload the page when we updated items return false; @@ -474,6 +484,7 @@ function initCommentForm() { $listMenu.data('update-url'), 'clear', $listMenu.data('issue-id'), + '', '' ).then(reload); } @@ -481,6 +492,7 @@ function initCommentForm() { $(this).parent().find('.item').each(function () { $(this).removeClass('checked'); $(this).find('.octicon').addClass('invisible'); + $(this).data('is-checked', 'remove'); }); $list.find('.item').each(function () { @@ -495,6 +507,7 @@ function initCommentForm() { initListSubmits('select-label', 'labels'); initListSubmits('select-assignees', 'assignees'); initListSubmits('select-assignees-modify', 'assignees'); + initListSubmits('select-reviewers-modify', 'assignees'); function selectItem(select_id, input_id) { const $menu = $(`${select_id} .menu`); @@ -512,7 +525,8 @@ function initCommentForm() { $menu.data('update-url'), '', $menu.data('issue-id'), - $(this).data('id') + $(this).data('id'), + $(this).data('is-checked') ).then(reload); } switch (input_id) { @@ -538,7 +552,8 @@ function initCommentForm() { $menu.data('update-url'), '', $menu.data('issue-id'), - $(this).data('id') + $(this).data('id'), + $(this).data('is-checked') ).then(reload); } @@ -648,6 +663,18 @@ function initInstall() { function initIssueComments() { if ($('.repository.view.issue .comments').length === 0) return; + $('.re-request-review').click((event) => { + const $this = $('.re-request-review'); + event.preventDefault(); + updateIssuesMeta( + $this.data('update-url'), + '', + $this.data('issue-id'), + $this.data('id'), + $this.data('is-checked') + ).then(reload); + }); + $(document).click((event) => { const urlTarget = $(':target'); if (urlTarget.length === 0) return; @@ -2516,7 +2543,7 @@ $(document).ready(async () => { elementId = ''; action = 'clear'; } - updateIssuesMeta(url, action, issueIDs, elementId).then(() => { + updateIssuesMeta(url, action, issueIDs, elementId, '').then(() => { // NOTICE: This reset of checkbox state targets Firefox caching behaviour, as the checkboxes stay checked after reload if (action === 'close' || action === 'open') { // uncheck all checkboxes |