summaryrefslogtreecommitdiff
path: root/app/assets
diff options
context:
space:
mode:
authorSimon Knox <psimyn@gmail.com>2017-02-21 16:32:08 +1100
committerSimon Knox <psimyn@gmail.com>2017-03-11 10:12:49 +1100
commit6e7e9e80e0a89c2c295ccaa4b8469b5ed33acd27 (patch)
treefbe9a3ecc0950bb4c639f09647ab91b75beef42c /app/assets
parent7867b9929ce8e03eda6da4c87e24e59210b1ee81 (diff)
downloadgitlab-ce-6e7e9e80e0a89c2c295ccaa4b8469b5ed33acd27.tar.gz
prevent filtering Issues by multiple milestones, authors, or assignees27174-filter-filters
Diffstat (limited to 'app/assets')
-rw-r--r--app/assets/javascripts/filtered_search/dropdown_hint.js14
-rw-r--r--app/assets/javascripts/filtered_search/dropdown_utils.js18
2 files changed, 19 insertions, 13 deletions
diff --git a/app/assets/javascripts/filtered_search/dropdown_hint.js b/app/assets/javascripts/filtered_search/dropdown_hint.js
index 38ff3fb7158..28e5e3232cb 100644
--- a/app/assets/javascripts/filtered_search/dropdown_hint.js
+++ b/app/assets/javascripts/filtered_search/dropdown_hint.js
@@ -57,13 +57,15 @@ require('./filtered_search_dropdown');
const dropdownData = [];
[].forEach.call(this.input.closest('.filtered-search-input-container').querySelectorAll('.dropdown-menu'), (dropdownMenu) => {
- const { icon, hint, tag } = dropdownMenu.dataset;
+ const { icon, hint, tag, type } = dropdownMenu.dataset;
if (icon && hint && tag) {
- dropdownData.push({
- icon: `fa-${icon}`,
- hint,
- tag: `&lt;${tag}&gt;`,
- });
+ dropdownData.push(
+ Object.assign({
+ icon: `fa-${icon}`,
+ hint,
+ tag: `&lt;${tag}&gt;`,
+ }, type && { type }),
+ );
}
});
diff --git a/app/assets/javascripts/filtered_search/dropdown_utils.js b/app/assets/javascripts/filtered_search/dropdown_utils.js
index a5a6b56a0d3..77bf191f343 100644
--- a/app/assets/javascripts/filtered_search/dropdown_utils.js
+++ b/app/assets/javascripts/filtered_search/dropdown_utils.js
@@ -51,14 +51,18 @@
static filterHint(input, item) {
const updatedItem = item;
- const searchInput = gl.DropdownUtils.getSearchInput(input);
- let { lastToken } = gl.FilteredSearchTokenizer.processTokens(searchInput);
- lastToken = lastToken.key || lastToken || '';
-
- if (!lastToken || searchInput.split('').last() === ' ') {
+ const searchInput = gl.DropdownUtils.getSearchQuery(input);
+ const { lastToken, tokens } = gl.FilteredSearchTokenizer.processTokens(searchInput);
+ const lastKey = lastToken.key || lastToken || '';
+ const allowMultiple = item.type === 'array';
+ const itemInExistingTokens = tokens.some(t => t.key === item.hint);
+
+ if (!allowMultiple && itemInExistingTokens) {
+ updatedItem.droplab_hidden = true;
+ } else if (!lastKey || searchInput.split('').last() === ' ') {
updatedItem.droplab_hidden = false;
- } else if (lastToken) {
- const split = lastToken.split(':');
+ } else if (lastKey) {
+ const split = lastKey.split(':');
const tokenName = split[0].split(' ').last();
const match = updatedItem.hint.indexOf(tokenName.toLowerCase()) === -1;