From 34c503c5573995ad0df4803df86647341b0d5de7 Mon Sep 17 00:00:00 2001 From: jaqra Date: Mon, 16 Sep 2019 23:04:22 +0300 Subject: [PATCH 01/10] Add 'Alt + click' feature to exclude labels --- models/issue.go | 8 ++++++-- models/issue_label.go | 6 +++++- public/js/index.js | 17 +++++++++++++++++ templates/repo/issue/list.tmpl | 2 +- 4 files changed, 29 insertions(+), 4 deletions(-) diff --git a/models/issue.go b/models/issue.go index 511bfa31c411e..65f547118df45 100644 --- a/models/issue.go +++ b/models/issue.go @@ -1394,8 +1394,12 @@ func (opts *IssuesOptions) setupSession(sess *xorm.Session) { if opts.LabelIDs != nil { for i, labelID := range opts.LabelIDs { - sess.Join("INNER", fmt.Sprintf("issue_label il%d", i), - fmt.Sprintf("issue.id = il%[1]d.issue_id AND il%[1]d.label_id = %[2]d", i, labelID)) + if labelID > 0 { + sess.Join("INNER", fmt.Sprintf("issue_label il%d", i), + fmt.Sprintf("issue.id = il%[1]d.issue_id AND il%[1]d.label_id = %[2]d", i, labelID)) + } else { + sess.Where("issue.id not in (select issue_id from issue_label where label_id = ?)", -labelID) + } } } } diff --git a/models/issue_label.go b/models/issue_label.go index f378f62e654ec..958bd8f7479f4 100644 --- a/models/issue_label.go +++ b/models/issue_label.go @@ -71,6 +71,7 @@ type Label struct { IsChecked bool `xorm:"-"` QueryString string IsSelected bool + IsExcluded bool } // APIFormat converts a Label to the api.Label format @@ -96,7 +97,10 @@ func (label *Label) LoadSelectedLabelsAfterClick(currentSelectedLabels []int64) for _, s := range currentSelectedLabels { if s == label.ID { labelSelected = true - } else if s > 0 { + } else if -s == label.ID { + labelSelected = true + label.IsExcluded = true + } else if s != 0 { labelQuerySlice = append(labelQuerySlice, strconv.FormatInt(s, 10)) } } diff --git a/public/js/index.js b/public/js/index.js index d99457514b0bd..2efcfa26111f9 100644 --- a/public/js/index.js +++ b/public/js/index.js @@ -1,6 +1,7 @@ /* globals wipPrefixes, issuesTribute, emojiTribute */ /* exported timeAddManual, toggleStopwatch, cancelStopwatch, initHeatmap */ /* exported toggleDeadlineForm, setDeadline, deleteDependencyModal, cancelCodeComment, onOAuthLoginClick */ +/* exported onLabelFilterItemClick */ 'use strict'; function htmlEncode(text) { @@ -3122,3 +3123,19 @@ function onOAuthLoginClick() { oauthNav.show(); },5000); } + +(function addLabelFilterClickEvents() { + $(".menu a.label-filter-item").each(function() { + $(this).click(function(e) { + const href = $(this).attr("href"); + const id = $(this).data("label-id"); + + if (e.altKey) { + const regStr = "labels=(-?[0-9]+%2c)*(" + id + ")(%2c-?[0-9]+)*&"; + const newStr = "labels=$1-$2$3&"; + + window.location = href.replace(new RegExp(regStr), newStr); + } + }); + }); +})(); diff --git a/templates/repo/issue/list.tmpl b/templates/repo/issue/list.tmpl index 4874d97da45aa..feaccd3cf89af 100644 --- a/templates/repo/issue/list.tmpl +++ b/templates/repo/issue/list.tmpl @@ -50,7 +50,7 @@ From d3b650bf77266997560eb572f5bdd42ee7419428 Mon Sep 17 00:00:00 2001 From: jaqra Date: Tue, 17 Sep 2019 00:42:02 +0300 Subject: [PATCH 02/10] :lipstick: --- public/js/index.js | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/public/js/index.js b/public/js/index.js index 2efcfa26111f9..1a9f941b53450 100644 --- a/public/js/index.js +++ b/public/js/index.js @@ -1,7 +1,6 @@ /* globals wipPrefixes, issuesTribute, emojiTribute */ /* exported timeAddManual, toggleStopwatch, cancelStopwatch, initHeatmap */ /* exported toggleDeadlineForm, setDeadline, deleteDependencyModal, cancelCodeComment, onOAuthLoginClick */ -/* exported onLabelFilterItemClick */ 'use strict'; function htmlEncode(text) { @@ -3127,10 +3126,10 @@ function onOAuthLoginClick() { (function addLabelFilterClickEvents() { $(".menu a.label-filter-item").each(function() { $(this).click(function(e) { - const href = $(this).attr("href"); - const id = $(this).data("label-id"); - if (e.altKey) { + 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&"; From 1324fbc2761982837b00fe865d967af668f453a7 Mon Sep 17 00:00:00 2001 From: jaqra Date: Thu, 17 Oct 2019 00:39:07 +0300 Subject: [PATCH 03/10] Add info --- public/css/index.css | 2 ++ public/less/_repository.less | 18 ++++++++++++++++++ templates/repo/issue/list.tmpl | 1 + 3 files changed, 21 insertions(+) diff --git a/public/css/index.css b/public/css/index.css index 113fdbf6318a8..ae4250aa14d2f 100644 --- a/public/css/index.css +++ b/public/css/index.css @@ -452,6 +452,8 @@ footer .ui.left,footer .ui.right{line-height:40px} .repository .filter.menu .label.color{border-radius:3px;margin-left:15px;padding:0 8px} .repository .filter.menu .octicon{float:left;margin:5px -7px 0 -5px;width:16px} .repository .filter.menu.labels .octicon{margin:-2px -7px 0 -5px} +.repository .filter.menu.labels .menu .info{display:inline-block;padding:9px 7px 7px 7px;text-align:center;border-bottom:1px solid #ccc;font-size:12px} +.repository .filter.menu.labels .menu .info code{border:1px solid #ccc;border-radius:3px;background:#fff;padding:3px 2px 1px 2px;font-size:11px} .repository .filter.menu .text{margin-left:.9em} .repository .filter.menu .menu{max-height:300px;overflow-x:auto;right:0!important;left:auto!important} .repository .filter.menu .dropdown.item{margin:1px;padding-right:0} diff --git a/public/less/_repository.less b/public/less/_repository.less index 74ca683c4e53b..bbe6af4511527 100644 --- a/public/less/_repository.less +++ b/public/less/_repository.less @@ -158,6 +158,24 @@ margin: -2px -7px 0 -5px; } + &.labels { + .menu .info { + display: inline-block; + padding: 9px 7px 7px 7px; + text-align: center; + border-bottom: 1px solid #cccccc; + font-size: 12px; + + code { + border: 1px solid #cccccc; + border-radius: 3px; + background: #ffffff; + padding: 3px 2px 1px 2px; + font-size: 11px; + } + } + } + .text { margin-left: 0.9em; } diff --git a/templates/repo/issue/list.tmpl b/templates/repo/issue/list.tmpl index feaccd3cf89af..28632ee754bd1 100644 --- a/templates/repo/issue/list.tmpl +++ b/templates/repo/issue/list.tmpl @@ -48,6 +48,7 @@