From dbd9d8dd54fd3b0ff7b02ae7b7da8369654e3725 Mon Sep 17 00:00:00 2001 From: jaqra <48099350+jaqra@users.noreply.github.com> Date: Wed, 23 Oct 2019 19:29:14 +0300 Subject: Add 'Alt + click' feature to exclude labels (#8199) Add 'Alt + click' and 'Alt +enter' feature to exclude particular labels on searching for issues. --- public/js/index.js | 35 +++++++++++++++++++++++++++++++++-- 1 file changed, 33 insertions(+), 2 deletions(-) (limited to 'public/js') diff --git a/public/js/index.js b/public/js/index.js index 90819677a5..cf19bf71a0 100644 --- a/public/js/index.js +++ b/public/js/index.js @@ -3278,8 +3278,39 @@ function initIssueList() { }, fullTextSearch: true - }) - ; + }); + + $(".menu a.label-filter-item").each(function() { + $(this).click(function(e) { + 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&"; + + window.location = href.replace(new RegExp(regStr), newStr); + } + }); + }); + + $(".menu .ui.dropdown.label-filter").keydown(function(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); + } + } + }); } function cancelCodeComment(btn) { const form = $(btn).closest("form"); -- cgit v1.2.3