Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adds a checkbox to select all issues/PRs #20177

Merged
merged 20 commits into from
Jul 28, 2022
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions templates/repo/issue/list.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,10 @@
<div class="ui divider"></div>
<div id="issue-filters" class="ui stackable grid">
<div class="six wide column">
<div class="ui checkbox issue-checkbox-all">
<input type="checkbox"></input>
<label></label>
</div>
tyroneyeh marked this conversation as resolved.
Show resolved Hide resolved
{{template "repo/issue/openclose" .}}
</div>
<div class="ten wide right aligned column">
Expand Down
27 changes: 24 additions & 3 deletions web_src/js/features/common-issue.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,36 @@ import $ from 'jquery';
import {updateIssuesMeta} from './repo-issue.js';

export function initCommonIssue() {
$('.issue-checkbox').on('click', () => {
const numChecked = $('.issue-checkbox').children('input:checked').length;
if (numChecked > 0) {
function checkboxOperate(e) {
tyroneyeh marked this conversation as resolved.
Show resolved Hide resolved
const issuecheckbox = $('.issue-checkbox input');
if (e.shiftKey && window.checkboxfirst !== undefined) {
for (let i = window.checkboxfirst + 1, j = issuecheckbox.index($(e.currentTarget).find('input')); i < j; i++) {
issuecheckbox[i].checked = 1;
}
delete window.checkboxfirst;
tyroneyeh marked this conversation as resolved.
Show resolved Hide resolved
} else {
window.checkboxfirst = issuecheckbox.index($(e.currentTarget).find('input'));
}
if (issuecheckbox.is(':checked')) {
$('#issue-filters').addClass('hide');
$('#issue-actions').removeClass('hide');
$('#issue-actions .six').prepend($('.issue-checkbox-all'));
} else {
$('#issue-filters').removeClass('hide');
$('#issue-actions').addClass('hide');
$('#issue-filters .six').prepend($('.issue-checkbox-all'));
wxiaoguang marked this conversation as resolved.
Show resolved Hide resolved
}
}

$('.issue-checkbox').on('click', (e) => {
checkboxOperate(e);
});
tyroneyeh marked this conversation as resolved.
Show resolved Hide resolved

$('.issue-checkbox-all').on('click', (e) => {
const selected = $('.issue-checkbox input:checked');
$('.issue-checkbox input:not(:checked)').prop('checked', 1);
selected.prop('checked', 0);
checkboxOperate(e);
wxiaoguang marked this conversation as resolved.
Show resolved Hide resolved
});

$('.issue-action').on('click', async function () {
Expand Down