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
Jérome Perrin
gitlab-ce
Commits
8229b545
Commit
8229b545
authored
Jun 06, 2017
by
Clement Ho
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Refactor to use class name to determine state
parent
75e0ec0f
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
34 additions
and
31 deletions
+34
-31
app/assets/javascripts/filtered_search/filtered_search_manager.js
...ts/javascripts/filtered_search/filtered_search_manager.js
+34
-31
No files found.
app/assets/javascripts/filtered_search/filtered_search_manager.js
View file @
8229b545
...
...
@@ -78,42 +78,36 @@ class FilteredSearchManager {
}
bindStateEvents
()
{
const
stateFilters
=
document
.
querySelector
(
'
.container-fluid .issues-state-filters
'
);
this
.
stateFilters
=
document
.
querySelector
(
'
.container-fluid .issues-state-filters
'
);
if
(
stateFilters
)
{
this
.
searchStateOpened
=
this
.
search
.
bind
(
this
,
'
opened
'
);
this
.
searchStateMerged
=
this
.
search
.
bind
(
this
,
'
merged
'
);
this
.
searchStateClosed
=
this
.
search
.
bind
(
this
,
'
closed
'
);
this
.
searchStateAll
=
this
.
search
.
bind
(
this
,
'
all
'
);
if
(
this
.
stateFilters
)
{
this
.
searchStateWrapper
=
this
.
searchState
.
bind
(
this
);
stateFilters
.
querySelector
(
'
.state-opened
'
)
.
addEventListener
(
'
click
'
,
this
.
searchState
Opened
);
stateFilters
.
querySelector
(
'
.state-closed
'
)
.
addEventListener
(
'
click
'
,
this
.
searchState
Closed
);
stateFilters
.
querySelector
(
'
.state-all
'
)
.
addEventListener
(
'
click
'
,
this
.
searchState
All
);
this
.
stateFilters
.
querySelector
(
'
.state-opened
'
)
.
addEventListener
(
'
click
'
,
this
.
searchState
Wrapper
);
this
.
stateFilters
.
querySelector
(
'
.state-closed
'
)
.
addEventListener
(
'
click
'
,
this
.
searchState
Wrapper
);
this
.
stateFilters
.
querySelector
(
'
.state-all
'
)
.
addEventListener
(
'
click
'
,
this
.
searchState
Wrapper
);
const
mergedState
=
stateFilters
.
querySelector
(
'
.state-merged
'
);
if
(
mergedState
)
{
mergedState
.
addEventListener
(
'
click
'
,
this
.
searchStateMerged
);
this
.
mergedState
=
this
.
stateFilters
.
querySelector
(
'
.state-merged
'
);
if
(
this
.
mergedState
)
{
this
.
mergedState
.
addEventListener
(
'
click
'
,
this
.
searchStateWrapper
);
}
}
}
unbindStateEvents
()
{
const
stateFilters
=
document
.
querySelector
(
'
.container-fluid .issues-state-filters
'
);
if
(
this
.
stateFilters
)
{
this
.
stateFilters
.
querySelector
(
'
.state-opened
'
)
.
removeEventListener
(
'
click
'
,
this
.
searchStateWrapper
);
this
.
stateFilters
.
querySelector
(
'
.state-closed
'
)
.
removeEventListener
(
'
click
'
,
this
.
searchStateWrapper
);
this
.
stateFilters
.
querySelector
(
'
.state-all
'
)
.
removeEventListener
(
'
click
'
,
this
.
searchStateWrapper
);
if
(
stateFilters
)
{
stateFilters
.
querySelector
(
'
.state-opened
'
)
.
removeEventListener
(
'
click
'
,
this
.
searchStateOpened
);
stateFilters
.
querySelector
(
'
.state-closed
'
)
.
removeEventListener
(
'
click
'
,
this
.
searchStateClosed
);
stateFilters
.
querySelector
(
'
.state-all
'
)
.
removeEventListener
(
'
click
'
,
this
.
searchStateAll
);
const
mergedState
=
stateFilters
.
querySelector
(
'
.state-merged
'
);
if
(
mergedState
)
{
mergedState
.
removeEventListener
(
'
click
'
,
this
.
searchStateMerged
);
if
(
this
.
mergedState
)
{
this
.
mergedState
.
removeEventListener
(
'
click
'
,
this
.
searchStateWrapper
);
}
}
}
...
...
@@ -504,6 +498,15 @@ class FilteredSearchManager {
}
}
searchState
(
e
)
{
const
target
=
e
.
currentTarget
;
// return class name that has a prefix of `state-`
const
stateClassName
=
[].
find
.
call
(
target
.
classList
,
name
=>
name
.
match
(
/
(
state-
)(\w
+
)
/g
));
const
state
=
stateClassName
.
replace
(
'
state-
'
,
''
);
this
.
search
(
state
);
}
search
(
state
=
null
)
{
const
paths
=
[];
const
searchQuery
=
gl
.
DropdownUtils
.
getSearchQuery
();
...
...
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