From 4a40d7aa3621135e25b10ab53df8448a09f6e4c8 Mon Sep 17 00:00:00 2001 From: Norwin Roosen Date: Fri, 12 Mar 2021 07:03:54 +0100 Subject: [PATCH 1/2] refactor DRY --- web_src/js/index.js | 30 ++++++++++++------------------ 1 file changed, 12 insertions(+), 18 deletions(-) diff --git a/web_src/js/index.js b/web_src/js/index.js index b5fa293947910..3f1aeafaff30b 100644 --- a/web_src/js/index.js +++ b/web_src/js/index.js @@ -3753,18 +3753,21 @@ function initIssueList() { fullTextSearch: true }); + function removeLabel (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); + removeLabel(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); + removeLabel($(selectedItems[0])); } } }); From a6094f455271a98112bb28b9c7631704849e2f2b Mon Sep 17 00:00:00 2001 From: Norwin Roosen Date: Fri, 12 Mar 2021 07:04:38 +0100 Subject: [PATCH 2/2] fix multiple-label filter on milestone issuelist --- templates/repo/issue/milestone_issues.tmpl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/templates/repo/issue/milestone_issues.tmpl b/templates/repo/issue/milestone_issues.tmpl index c2c81682ff0ff..4f4a91b211c4d 100644 --- a/templates/repo/issue/milestone_issues.tmpl +++ b/templates/repo/issue/milestone_issues.tmpl @@ -54,7 +54,7 @@ {{.i18n.Tr "repo.issues.filter_label_exclude" | Safe}} {{.i18n.Tr "repo.issues.filter_label_no_select"}} {{range .Labels}} - {{if .IsExcluded}}{{svg "octicon-circle-slash"}}{{else if contain $.SelLabelIDs .ID}}{{svg "octicon-check"}}{{end}} {{.Name | RenderEmoji}} + {{if .IsExcluded}}{{svg "octicon-circle-slash"}}{{else if contain $.SelLabelIDs .ID}}{{svg "octicon-check"}}{{end}} {{.Name | RenderEmoji}} {{end}}