aboutsummaryrefslogtreecommitdiffstats
path: root/web_src/js
diff options
context:
space:
mode:
authorzeripath <art27@cantab.net>2021-03-12 16:07:23 +0000
committerGitHub <noreply@github.com>2021-03-13 00:07:23 +0800
commitccfb205ad126ac6fa3490e43a8075947e05a731a (patch)
tree9c363e6174cfb3ab2e454f14c80d3984c341ad2a /web_src/js
parent855a4f476e848dcb60422d299f003e69adbdc79a (diff)
downloadgitea-ccfb205ad126ac6fa3490e43a8075947e05a731a.tar.gz
gitea-ccfb205ad126ac6fa3490e43a8075947e05a731a.zip
Fix excluding more than two labels on issues list (#14962)
* Fix excluding more than two labels on issues list Fix #14840 Signed-off-by: Andrew Thornton <art27@cantab.net> * refactor DRY * fix multiple-label filter on milestone issuelist * Apply suggestions from code review Co-authored-by: jaqra <48099350+jaqra@users.noreply.github.com> * Update web_src/js/index.js Co-authored-by: Norwin Roosen <git@nroo.de> Co-authored-by: jaqra <48099350+jaqra@users.noreply.github.com>
Diffstat (limited to 'web_src/js')
-rw-r--r--web_src/js/index.js30
1 files changed, 12 insertions, 18 deletions
diff --git a/web_src/js/index.js b/web_src/js/index.js
index cda08870a5..ccd9276059 100644
--- a/web_src/js/index.js
+++ b/web_src/js/index.js
@@ -3753,18 +3753,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);
}
});
});
@@ -3772,17 +3775,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]));
}
}
});