Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Léo-Paul Géneau
gitlab-ce
Commits
6e7e9e80
Commit
6e7e9e80
authored
Feb 21, 2017
by
Simon Knox
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
prevent filtering Issues by multiple milestones, authors, or assignees
parent
7867b992
Changes
5
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
53 additions
and
16 deletions
+53
-16
app/assets/javascripts/filtered_search/dropdown_hint.js
app/assets/javascripts/filtered_search/dropdown_hint.js
+8
-6
app/assets/javascripts/filtered_search/dropdown_utils.js
app/assets/javascripts/filtered_search/dropdown_utils.js
+11
-7
app/views/shared/issuable/_search_bar.html.haml
app/views/shared/issuable/_search_bar.html.haml
+1
-1
changelogs/unreleased/27174-filter-filters.yml
changelogs/unreleased/27174-filter-filters.yml
+4
-0
spec/javascripts/filtered_search/dropdown_utils_spec.js
spec/javascripts/filtered_search/dropdown_utils_spec.js
+29
-2
No files found.
app/assets/javascripts/filtered_search/dropdown_hint.js
View file @
6e7e9e80
...
@@ -57,13 +57,15 @@ require('./filtered_search_dropdown');
...
@@ -57,13 +57,15 @@ require('./filtered_search_dropdown');
const
dropdownData
=
[];
const
dropdownData
=
[];
[].
forEach
.
call
(
this
.
input
.
closest
(
'
.filtered-search-input-container
'
).
querySelectorAll
(
'
.dropdown-menu
'
),
(
dropdownMenu
)
=>
{
[].
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
)
{
if
(
icon
&&
hint
&&
tag
)
{
dropdownData
.
push
({
dropdownData
.
push
(
Object
.
assign
({
icon
:
`fa-
${
icon
}
`
,
icon
:
`fa-
${
icon
}
`
,
hint
,
hint
,
tag
:
`<
${
tag
}
>`
,
tag
:
`<
${
tag
}
>`
,
});
},
type
&&
{
type
}),
);
}
}
});
});
...
...
app/assets/javascripts/filtered_search/dropdown_utils.js
View file @
6e7e9e80
...
@@ -51,14 +51,18 @@
...
@@ -51,14 +51,18 @@
static
filterHint
(
input
,
item
)
{
static
filterHint
(
input
,
item
)
{
const
updatedItem
=
item
;
const
updatedItem
=
item
;
const
searchInput
=
gl
.
DropdownUtils
.
getSearchInput
(
input
);
const
searchInput
=
gl
.
DropdownUtils
.
getSearchQuery
(
input
);
let
{
lastToken
}
=
gl
.
FilteredSearchTokenizer
.
processTokens
(
searchInput
);
const
{
lastToken
,
tokens
}
=
gl
.
FilteredSearchTokenizer
.
processTokens
(
searchInput
);
lastToken
=
lastToken
.
key
||
lastToken
||
''
;
const
lastKey
=
lastToken
.
key
||
lastToken
||
''
;
const
allowMultiple
=
item
.
type
===
'
array
'
;
if
(
!
lastToken
||
searchInput
.
split
(
''
).
last
()
===
'
'
)
{
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
;
updatedItem
.
droplab_hidden
=
false
;
}
else
if
(
last
Token
)
{
}
else
if
(
last
Key
)
{
const
split
=
last
Token
.
split
(
'
:
'
);
const
split
=
last
Key
.
split
(
'
:
'
);
const
tokenName
=
split
[
0
].
split
(
'
'
).
last
();
const
tokenName
=
split
[
0
].
split
(
'
'
).
last
();
const
match
=
updatedItem
.
hint
.
indexOf
(
tokenName
.
toLowerCase
())
===
-
1
;
const
match
=
updatedItem
.
hint
.
indexOf
(
tokenName
.
toLowerCase
())
===
-
1
;
...
...
app/views/shared/issuable/_search_bar.html.haml
View file @
6e7e9e80
...
@@ -73,7 +73,7 @@
...
@@ -73,7 +73,7 @@
%li
.filter-dropdown-item
%li
.filter-dropdown-item
%button
.btn.btn-link.js-data-value
%button
.btn.btn-link.js-data-value
{{title}}
{{title}}
#js-dropdown-label
.dropdown-menu
{
data:
{
icon:
'tag'
,
hint:
'label'
,
tag:
'~label'
}
}
#js-dropdown-label
.dropdown-menu
{
data:
{
icon:
'tag'
,
hint:
'label'
,
tag:
'~label'
,
type:
'array'
}
}
%ul
{
data:
{
dropdown:
true
}
}
%ul
{
data:
{
dropdown:
true
}
}
%li
.filter-dropdown-item
{
data:
{
value:
'none'
}
}
%li
.filter-dropdown-item
{
data:
{
value:
'none'
}
}
%button
.btn.btn-link
%button
.btn.btn-link
...
...
changelogs/unreleased/27174-filter-filters.yml
0 → 100644
View file @
6e7e9e80
---
title
:
Prevent filtering issues by multiple Milestones or Authors
merge_request
:
author
:
spec/javascripts/filtered_search/dropdown_utils_spec.js
View file @
6e7e9e80
...
@@ -126,7 +126,11 @@ require('~/filtered_search/filtered_search_dropdown_manager');
...
@@ -126,7 +126,11 @@ require('~/filtered_search/filtered_search_dropdown_manager');
beforeEach
(()
=>
{
beforeEach
(()
=>
{
setFixtures
(
`
setFixtures
(
`
<input type="text" id="test" />
<ul class="tokens-container">
<li class="input-token">
<input class="filtered-search" type="text" id="test" />
</li>
</ul>
`
);
`
);
input
=
document
.
getElementById
(
'
test
'
);
input
=
document
.
getElementById
(
'
test
'
);
...
@@ -142,7 +146,7 @@ require('~/filtered_search/filtered_search_dropdown_manager');
...
@@ -142,7 +146,7 @@ require('~/filtered_search/filtered_search_dropdown_manager');
input
.
value
=
'
o
'
;
input
.
value
=
'
o
'
;
updatedItem
=
gl
.
DropdownUtils
.
filterHint
(
input
,
{
updatedItem
=
gl
.
DropdownUtils
.
filterHint
(
input
,
{
hint
:
'
label
'
,
hint
:
'
label
'
,
}
,
'
o
'
);
});
expect
(
updatedItem
.
droplab_hidden
).
toBe
(
true
);
expect
(
updatedItem
.
droplab_hidden
).
toBe
(
true
);
});
});
...
@@ -150,6 +154,29 @@ require('~/filtered_search/filtered_search_dropdown_manager');
...
@@ -150,6 +154,29 @@ require('~/filtered_search/filtered_search_dropdown_manager');
const
updatedItem
=
gl
.
DropdownUtils
.
filterHint
(
input
,
{},
''
);
const
updatedItem
=
gl
.
DropdownUtils
.
filterHint
(
input
,
{},
''
);
expect
(
updatedItem
.
droplab_hidden
).
toBe
(
false
);
expect
(
updatedItem
.
droplab_hidden
).
toBe
(
false
);
});
});
it
(
'
should allow multiple if item.type is array
'
,
()
=>
{
input
.
value
=
'
label:~first la
'
;
const
updatedItem
=
gl
.
DropdownUtils
.
filterHint
(
input
,
{
hint
:
'
label
'
,
type
:
'
array
'
,
});
expect
(
updatedItem
.
droplab_hidden
).
toBe
(
false
);
});
it
(
'
should prevent multiple if item.type is not array
'
,
()
=>
{
input
.
value
=
'
milestone:~first mile
'
;
let
updatedItem
=
gl
.
DropdownUtils
.
filterHint
(
input
,
{
hint
:
'
milestone
'
,
});
expect
(
updatedItem
.
droplab_hidden
).
toBe
(
true
);
updatedItem
=
gl
.
DropdownUtils
.
filterHint
(
input
,
{
hint
:
'
milestone
'
,
type
:
'
string
'
,
});
expect
(
updatedItem
.
droplab_hidden
).
toBe
(
true
);
});
});
});
describe
(
'
setDataValueIfSelected
'
,
()
=>
{
describe
(
'
setDataValueIfSelected
'
,
()
=>
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment