Skip to content

Commit ffd2a68

Browse files
zeripathnoerwjaqra
committed
Fix excluding more than two labels on issues list (go-gitea#14962)
Backport go-gitea#14962 Fix go-gitea#14840 Signed-off-by: Andrew Thornton <[email protected]> Co-authored-by: Norwin Roosen <[email protected]> Co-authored-by: jaqra <[email protected]>
1 parent 33c2c49 commit ffd2a68

File tree

2 files changed

+13
-19
lines changed

2 files changed

+13
-19
lines changed

templates/repo/issue/milestone_issues.tmpl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@
6363
<span class="info">{{.i18n.Tr "repo.issues.filter_label_exclude" | Safe}}</span>
6464
<a class="item" href="{{$.Link}}?q={{$.Keyword}}&type={{$.ViewType}}&sort={{$.SortType}}&state={{$.State}}&assignee={{$.AssigneeID}}">{{.i18n.Tr "repo.issues.filter_label_no_select"}}</a>
6565
{{range .Labels}}
66-
<a class="item label-filter-item" href="{{$.Link}}?q={{$.Keyword}}&type={{$.ViewType}}&sort={{$.SortType}}&state={{$.State}}&labels={{.ID}}&assignee={{$.AssigneeID}}" data-label-id="{{.ID}}">{{if .IsExcluded}}{{svg "octicon-circle-slash"}}{{else if contain $.SelLabelIDs .ID}}{{svg "octicon-check"}}{{end}}<span class="label color" style="background-color: {{.Color}}"></span> {{.Name | RenderEmoji}}</a>
66+
<a class="item label-filter-item" href="{{$.Link}}?q={{$.Keyword}}&type={{$.ViewType}}&sort={{$.SortType}}&state={{$.State}}&labels={{.QueryString}}&assignee={{$.AssigneeID}}" data-label-id="{{.ID}}">{{if .IsExcluded}}{{svg "octicon-circle-slash"}}{{else if contain $.SelLabelIDs .ID}}{{svg "octicon-check"}}{{end}}<span class="label color" style="background-color: {{.Color}}"></span> {{.Name | RenderEmoji}}</a>
6767
{{end}}
6868
</div>
6969
</div>

web_src/js/index.js

Lines changed: 12 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -3592,36 +3592,30 @@ function initIssueList() {
35923592
fullTextSearch: true
35933593
});
35943594

3595+
function excludeLabel (item) {
3596+
const href = $(item).attr('href');
3597+
const id = $(item).data('label-id');
3598+
3599+
const regStr = `labels=((?:-?[0-9]+%2c)*)(${id})((?:%2c-?[0-9]+)*)&`;
3600+
const newStr = 'labels=$1-$2$3&';
3601+
3602+
window.location = href.replace(new RegExp(regStr), newStr);
3603+
}
3604+
35953605
$('.menu a.label-filter-item').each(function () {
35963606
$(this).on('click', function (e) {
35973607
if (e.altKey) {
35983608
e.preventDefault();
3599-
3600-
const href = $(this).attr('href');
3601-
const id = $(this).data('label-id');
3602-
3603-
const regStr = `labels=(-?[0-9]+%2c)*(${id})(%2c-?[0-9]+)*&`;
3604-
const newStr = 'labels=$1-$2$3&';
3605-
3606-
window.location = href.replace(new RegExp(regStr), newStr);
3609+
excludeLabel(this);
36073610
}
36083611
});
36093612
});
36103613

36113614
$('.menu .ui.dropdown.label-filter').on('keydown', (e) => {
36123615
if (e.altKey && e.keyCode === 13) {
36133616
const selectedItems = $('.menu .ui.dropdown.label-filter .menu .item.selected');
3614-
36153617
if (selectedItems.length > 0) {
3616-
const item = $(selectedItems[0]);
3617-
3618-
const href = item.attr('href');
3619-
const id = item.data('label-id');
3620-
3621-
const regStr = `labels=(-?[0-9]+%2c)*(${id})(%2c-?[0-9]+)*&`;
3622-
const newStr = 'labels=$1-$2$3&';
3623-
3624-
window.location = href.replace(new RegExp(regStr), newStr);
3618+
excludeLabel($(selectedItems[0]));
36253619
}
36263620
}
36273621
});

0 commit comments

Comments
 (0)