aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorzeripath2021-03-12 17:12:14 +0000
committerGitHub2021-03-12 18:12:14 +0100
commit3e7dccdf476758e6e8bfe18044588e36b5d22884 (patch)
treefd0976e416c53d6b6cf443d2cd7f02929620cc9d
parent33c2c49627455bd19d411ecd858c2ca2eceab731 (diff)
Fix excluding more than two labels on issues list (#14962) (#14973)
Backport #14962 Fix #14840 Signed-off-by: Andrew Thornton <art27@cantab.net> Co-authored-by: Norwin Roosen <git@nroo.de> Co-authored-by: jaqra <48099350+jaqra@users.noreply.github.com> Co-authored-by: Norwin Roosen <git@nroo.de> Co-authored-by: jaqra <48099350+jaqra@users.noreply.github.com>
-rw-r--r--templates/repo/issue/milestone_issues.tmpl2
-rw-r--r--web_src/js/index.js30
2 files changed, 13 insertions, 19 deletions
diff --git a/templates/repo/issue/milestone_issues.tmpl b/templates/repo/issue/milestone_issues.tmpl
index 8d8c39256..28b11ad6d 100644
--- a/templates/repo/issue/milestone_issues.tmpl
+++ b/templates/repo/issue/milestone_issues.tmpl
@@ -63,7 +63,7 @@
<span class="info">{{.i18n.Tr "repo.issues.filter_label_exclude" | Safe}}</span>
<a class="item" href="{{$.Link}}?q={{$.Keyword}}&type={{$.ViewType}}&sort={{$.SortType}}&state={{$.State}}&assignee={{$.AssigneeID}}">{{.i18n.Tr "repo.issues.filter_label_no_select"}}</a>
{{range .Labels}}
- <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>
+ <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>
{{end}}
</div>
</div>
diff --git a/web_src/js/index.js b/web_src/js/index.js
index 2bfa691d6..b7a31c575 100644
--- a/web_src/js/index.js
+++ b/web_src/js/index.js
@@ -3592,18 +3592,21 @@ function initIssueList() {
fullTextSearch: true
});
+ function excludeLabel (item) {
+ const href = $(item).attr('href');
+ const id = $(item).data('label-id');
+
+ const regStr = `labels=((?:-?[0-9]+%2c)*)(${id})((?:%2c-?[0-9]+)*)&`;
+ const newStr = 'labels=$1-$2$3&';
+
+ window.location = href.replace(new RegExp(regStr), newStr);
+ }
+
$('.menu a.label-filter-item').each(function () {
$(this).on('click', function (e) {
if (e.altKey) {
e.preventDefault();
-
- const href = $(this).attr('href');
- const id = $(this).data('label-id');
-
- const regStr = `labels=(-?[0-9]+%2c)*(${id})(%2c-?[0-9]+)*&`;
- const newStr = 'labels=$1-$2$3&';
-
- window.location = href.replace(new RegExp(regStr), newStr);
+ excludeLabel(this);
}
});
});
@@ -3611,17 +3614,8 @@ function initIssueList() {
$('.menu .ui.dropdown.label-filter').on('keydown', (e) => {
if (e.altKey && e.keyCode === 13) {
const selectedItems = $('.menu .ui.dropdown.label-filter .menu .item.selected');
-
if (selectedItems.length > 0) {
- const item = $(selectedItems[0]);
-
- const href = item.attr('href');
- const id = item.data('label-id');
-
- const regStr = `labels=(-?[0-9]+%2c)*(${id})(%2c-?[0-9]+)*&`;
- const newStr = 'labels=$1-$2$3&';
-
- window.location = href.replace(new RegExp(regStr), newStr);
+ excludeLabel($(selectedItems[0]));
}
}
});