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
Boxiang Sun
gitlab-ce
Commits
86a3dee2
Commit
86a3dee2
authored
Mar 07, 2017
by
Clement Ho
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Prevent visual token dropdown from opening the wrong filter dropdown
parent
bd1d7781
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
81 additions
and
25 deletions
+81
-25
app/assets/javascripts/filtered_search/dropdown_utils.js
app/assets/javascripts/filtered_search/dropdown_utils.js
+36
-18
app/assets/javascripts/filtered_search/filtered_search_dropdown_manager.js
...ripts/filtered_search/filtered_search_dropdown_manager.js
+1
-1
app/assets/javascripts/filtered_search/filtered_search_manager.js
...ts/javascripts/filtered_search/filtered_search_manager.js
+6
-3
spec/features/issues/filtered_search/visual_tokens_spec.rb
spec/features/issues/filtered_search/visual_tokens_spec.rb
+30
-0
spec/support/filtered_search_helpers.rb
spec/support/filtered_search_helpers.rb
+8
-3
No files found.
app/assets/javascripts/filtered_search/dropdown_utils.js
View file @
86a3dee2
...
@@ -80,30 +80,48 @@
...
@@ -80,30 +80,48 @@
}
}
// Determines the full search query (visual tokens + input)
// Determines the full search query (visual tokens + input)
static
getSearchQuery
()
{
static
getSearchQuery
(
untilInput
=
false
)
{
const
tokens
Container
=
document
.
querySelector
(
'
.tokens-container
'
);
const
tokens
=
[].
slice
.
call
(
document
.
querySelectorAll
(
'
.tokens-container li
'
)
);
const
values
=
[];
const
values
=
[];
[].
forEach
.
call
(
tokensContainer
.
querySelectorAll
(
'
.js-visual-token
'
),
(
token
)
=>
{
if
(
untilInput
)
{
const
name
=
token
.
querySelector
(
'
.name
'
);
const
inputIndex
=
_
.
findIndex
(
tokens
,
t
=>
t
.
classList
.
contains
(
'
input-token
'
)
);
const
value
=
token
.
querySelector
(
'
.value
'
);
// Add one to include input-token to the tokens array
const
symbol
=
value
&&
value
.
dataset
.
symbol
?
value
.
dataset
.
symbol
:
''
;
tokens
.
splice
(
inputIndex
+
1
)
;
let
valueText
=
''
;
}
if
(
value
&&
value
.
innerText
)
{
tokens
.
forEach
((
token
)
=>
{
valueText
=
value
.
innerText
;
if
(
token
.
classList
.
contains
(
'
js-visual-token
'
))
{
}
const
name
=
token
.
querySelector
(
'
.name
'
);
const
value
=
token
.
querySelector
(
'
.value
'
);
if
(
token
.
className
.
indexOf
(
'
filtered-search-token
'
)
!==
-
1
)
{
const
symbol
=
value
&&
value
.
dataset
.
symbol
?
value
.
dataset
.
symbol
:
''
;
values
.
push
(
`
${
name
.
innerText
.
toLowerCase
()}
:
${
symbol
}${
valueText
}
`
);
let
valueText
=
''
;
}
else
{
values
.
push
(
name
.
innerText
);
if
(
value
&&
value
.
innerText
)
{
valueText
=
value
.
innerText
;
}
if
(
token
.
className
.
indexOf
(
'
filtered-search-token
'
)
!==
-
1
)
{
values
.
push
(
`
${
name
.
innerText
.
toLowerCase
()}
:
${
symbol
}${
valueText
}
`
);
}
else
{
values
.
push
(
name
.
innerText
);
}
}
else
if
(
token
.
classList
.
contains
(
'
input-token
'
))
{
const
{
isLastVisualTokenValid
}
=
gl
.
FilteredSearchVisualTokens
.
getLastVisualTokenBeforeInput
();
const
input
=
document
.
querySelector
(
'
.filtered-search
'
);
const
inputValue
=
input
&&
input
.
value
;
if
(
isLastVisualTokenValid
)
{
values
.
push
(
inputValue
);
}
else
{
const
previous
=
values
.
pop
();
values
.
push
(
`
${
previous
}${
inputValue
}
`
);
}
}
}
});
});
const
input
=
document
.
querySelector
(
'
.filtered-search
'
);
values
.
push
(
input
&&
input
.
value
);
return
values
.
join
(
'
'
);
return
values
.
join
(
'
'
);
}
}
...
...
app/assets/javascripts/filtered_search/filtered_search_dropdown_manager.js
View file @
86a3dee2
...
@@ -139,7 +139,7 @@
...
@@ -139,7 +139,7 @@
}
}
setDropdown
()
{
setDropdown
()
{
const
query
=
gl
.
DropdownUtils
.
getSearchQuery
();
const
query
=
gl
.
DropdownUtils
.
getSearchQuery
(
true
);
const
{
lastToken
,
searchToken
}
=
this
.
tokenizer
.
processTokens
(
query
);
const
{
lastToken
,
searchToken
}
=
this
.
tokenizer
.
processTokens
(
query
);
if
(
this
.
currentDropdown
)
{
if
(
this
.
currentDropdown
)
{
...
...
app/assets/javascripts/filtered_search/filtered_search_manager.js
View file @
86a3dee2
...
@@ -363,10 +363,13 @@
...
@@ -363,10 +363,13 @@
tokenChange
()
{
tokenChange
()
{
const
dropdown
=
this
.
dropdownManager
.
mapping
[
this
.
dropdownManager
.
currentDropdown
];
const
dropdown
=
this
.
dropdownManager
.
mapping
[
this
.
dropdownManager
.
currentDropdown
];
const
currentDropdownRef
=
dropdown
.
reference
;
this
.
setDropdownWrapper
();
if
(
dropdown
)
{
currentDropdownRef
.
dispatchInputEvent
();
const
currentDropdownRef
=
dropdown
.
reference
;
this
.
setDropdownWrapper
();
currentDropdownRef
.
dispatchInputEvent
();
}
}
}
}
}
...
...
spec/features/issues/filtered_search/visual_tokens_spec.rb
View file @
86a3dee2
...
@@ -242,6 +242,23 @@ describe 'Visual tokens', js: true, feature: true do
...
@@ -242,6 +242,23 @@ describe 'Visual tokens', js: true, feature: true do
end
end
end
end
describe
'editing a search term while editing another filter token'
do
before
do
input_filtered_search
(
'author assignee:'
,
submit:
false
)
first
(
'.tokens-container .filtered-search-term'
).
double_click
end
it
'opens hint dropdown'
do
expect
(
page
).
to
have_css
(
'#js-dropdown-hint'
,
visible:
true
)
end
it
'opens author dropdown'
do
find
(
'#js-dropdown-hint .filter-dropdown .filter-dropdown-item'
,
text:
'author'
).
click
expect
(
page
).
to
have_css
(
'#js-dropdown-author'
,
visible:
true
)
end
end
describe
'add new token after editing existing token'
do
describe
'add new token after editing existing token'
do
before
do
before
do
input_filtered_search
(
'author:@root assignee:none'
,
submit:
false
)
input_filtered_search
(
'author:@root assignee:none'
,
submit:
false
)
...
@@ -319,4 +336,17 @@ describe 'Visual tokens', js: true, feature: true do
...
@@ -319,4 +336,17 @@ describe 'Visual tokens', js: true, feature: true do
expect
(
token
.
find
(
'.name'
).
text
).
to
eq
(
'Author'
)
expect
(
token
.
find
(
'.name'
).
text
).
to
eq
(
'Author'
)
end
end
end
end
describe
'search using incomplete visual tokens'
do
before
do
input_filtered_search
(
'author:@root assignee:none'
,
extra_space:
false
)
end
it
'tokenizes the search term to complete visual token'
do
expect_tokens
([
{
name:
'author'
,
value:
'@root'
},
{
name:
'assignee'
,
value:
'none'
}
])
end
end
end
end
spec/support/filtered_search_helpers.rb
View file @
86a3dee2
...
@@ -4,9 +4,14 @@ module FilteredSearchHelpers
...
@@ -4,9 +4,14 @@ module FilteredSearchHelpers
end
end
# Enables input to be set (similar to copy and paste)
# Enables input to be set (similar to copy and paste)
def
input_filtered_search
(
search_term
,
submit:
true
)
def
input_filtered_search
(
search_term
,
submit:
true
,
extra_space:
true
)
# Add an extra space to engage visual tokens
search
=
search_term
filtered_search
.
set
(
"
#{
search_term
}
"
)
if
extra_space
# Add an extra space to engage visual tokens
search
=
"
#{
search_term
}
"
end
filtered_search
.
set
(
search
)
if
submit
if
submit
filtered_search
.
send_keys
(
:enter
)
filtered_search
.
send_keys
(
:enter
)
...
...
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