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

Convert issue list checkboxes to native #23596

Merged
merged 6 commits into from
Mar 30, 2023
Merged
Show file tree
Hide file tree
Changes from 4 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: 1 addition & 3 deletions templates/repo/issue/list.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,7 @@
<div id="issue-filters" class="ui stackable grid">
<div class="six wide column">
{{if $.CanWriteIssuesOrPulls}}
<div class="ui checkbox issue-checkbox-all gt-vm">
<input type="checkbox" title="{{.locale.Tr "repo.issues.action_check_all"}}">
</div>
<input type="checkbox" autocomplete="off" class="issue-checkbox-all gt-vm gt-mr-4" title="{{.locale.Tr "repo.issues.action_check_all"}}">
silverwind marked this conversation as resolved.
Show resolved Hide resolved
{{end}}
{{template "repo/issue/openclose" .}}
</div>
Expand Down
6 changes: 2 additions & 4 deletions templates/shared/issuelist.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,9 @@
{{$approvalCounts := .ApprovalCounts}}
{{range .Issues}}
<li class="item gt-df gt-py-3">
<div class="issue-item-left gt-df">
<div class="issue-item-left gt-df gt-items-start">
{{if $.CanWriteIssuesOrPulls}}
<div class="ui checkbox issue-checkbox">
<input type="checkbox" data-issue-id={{.ID}} title="{{$.locale.Tr "repo.issues.action_check"}} «{{.Title}}»">
</div>
<input type="checkbox" autocomplete="off" class="issue-checkbox gt-mt-2 gt-mr-4" data-issue-id={{.ID}} aria-label="{{$.locale.Tr "repo.issues.action_check"}} &quot;{{.Title}}&quot;">
{{end}}
<div class="issue-item-icon">
{{if .IsPull}}
Expand Down
1 change: 1 addition & 0 deletions web_src/css/helpers.css
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
.gt-relative { position: relative !important; }
.gt-overflow-x-scroll { overflow-x: scroll !important; }
.gt-cursor-default { cursor: default !important; }
.gt-items-start { align-items: flex-start !important; }

.gt-mono {
font-family: var(--fonts-monospace) !important;
Expand Down
4 changes: 0 additions & 4 deletions web_src/css/shared/issuelist.css
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,6 @@
color: var(--color-primary) !important;
}

.issue.list > .item .issue-checkbox {
margin-top: 1px;
}

.issue.list > .item .issue-item-icon svg {
margin-right: 0.75rem;
margin-top: 1px;
Expand Down
22 changes: 4 additions & 18 deletions web_src/js/features/common-issue.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,8 @@ import {updateIssuesMeta} from './repo-issue.js';
import {toggleElem} from '../utils/dom.js';

export function initCommonIssue() {
const $issueSelectAllWrapper = $('.issue-checkbox-all');
const $issueSelectAll = $('.issue-checkbox-all input');
const $issueCheckboxes = $('.issue-checkbox input');
const $issueSelectAll = $('.issue-checkbox-all');
const $issueCheckboxes = $('.issue-checkbox');

const syncIssueSelectionState = () => {
const $checked = $issueCheckboxes.filter(':checked');
Expand All @@ -23,7 +22,7 @@ export function initCommonIssue() {
toggleElem($('#issue-filters'), !anyChecked);
toggleElem($('#issue-actions'), anyChecked);
// there are two panels but only one select-all checkbox, so move the checkbox to the visible panel
$('#issue-filters, #issue-actions').filter(':visible').find('.column:first').prepend($issueSelectAllWrapper);
$('#issue-filters, #issue-actions').filter(':visible').find('.column:first').prepend($issueSelectAll);
};

$issueCheckboxes.on('change', syncIssueSelectionState);
Expand All @@ -38,7 +37,7 @@ export function initCommonIssue() {
let action = this.getAttribute('data-action');
let elementId = this.getAttribute('data-element-id');
const url = this.getAttribute('data-url');
const issueIDs = $('.issue-checkbox').children('input:checked').map((_, el) => {
const issueIDs = $('.issue-checkbox:checked').map((_, el) => {
return el.getAttribute('data-issue-id');
}).get().join(',');
if (elementId === '0' && url.slice(-9) === '/assignee') {
Expand All @@ -54,20 +53,7 @@ export function initCommonIssue() {
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
$('.issue-checkbox input[type="checkbox"]').each((_, e) => { e.checked = false });
}
window.location.reload();
});
});

// NOTICE: This event trigger targets Firefox caching behaviour, as the checkboxes stay
// checked after reload trigger checked event, if checkboxes are checked on load
$('.issue-checkbox input[type="checkbox"]:checked').first().each((_, e) => {
e.checked = false;
$(e).trigger('click');
});
silverwind marked this conversation as resolved.
Show resolved Hide resolved
}