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
1
Merge Requests
1
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
nexedi
gitlab-ce
Commits
8064a400
Commit
8064a400
authored
May 10, 2017
by
Alfredo Sumaran
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add support to filter groups by filter options
parent
312d02ad
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
33 additions
and
11 deletions
+33
-11
app/assets/javascripts/filterable_list.js
app/assets/javascripts/filterable_list.js
+13
-4
app/assets/javascripts/groups/groups_filterable_list.js
app/assets/javascripts/groups/groups_filterable_list.js
+14
-1
app/views/shared/groups/_dropdown.html.haml
app/views/shared/groups/_dropdown.html.haml
+6
-6
No files found.
app/assets/javascripts/filterable_list.js
View file @
8064a400
...
@@ -12,7 +12,10 @@ export default class FilterableList {
...
@@ -12,7 +12,10 @@ export default class FilterableList {
}
}
initSearch
()
{
initSearch
()
{
this
.
debounceFilter
=
_
.
debounce
(
this
.
filterResults
.
bind
(
this
),
500
);
// Wrap to prevent passing event arguments to .filterResults;
this
.
debounceFilter
=
_
.
debounce
(()
=>
{
this
.
filterResults
();
},
500
);
this
.
unbindEvents
();
this
.
unbindEvents
();
this
.
bindEvents
();
this
.
bindEvents
();
...
@@ -26,13 +29,15 @@ export default class FilterableList {
...
@@ -26,13 +29,15 @@ export default class FilterableList {
this
.
listFilterElement
.
removeEventListener
(
'
input
'
,
this
.
debounceFilter
);
this
.
listFilterElement
.
removeEventListener
(
'
input
'
,
this
.
debounceFilter
);
}
}
filterResults
()
{
filterResults
(
url
,
data
)
{
const
endpoint
=
url
||
this
.
filterForm
.
getAttribute
(
'
action
'
);
const
additionalData
=
data
||
$
(
this
.
filterForm
).
serialize
();
$
(
this
.
listHolderElement
).
fadeTo
(
250
,
0.5
);
$
(
this
.
listHolderElement
).
fadeTo
(
250
,
0.5
);
return
$
.
ajax
({
return
$
.
ajax
({
url
:
this
.
filterForm
.
getAttribute
(
'
action
'
)
,
url
:
endpoint
,
data
:
$
(
this
.
filterForm
).
serialize
()
,
data
:
additionalData
,
type
:
'
GET
'
,
type
:
'
GET
'
,
dataType
:
'
json
'
,
dataType
:
'
json
'
,
context
:
this
,
context
:
this
,
...
@@ -42,6 +47,10 @@ export default class FilterableList {
...
@@ -42,6 +47,10 @@ export default class FilterableList {
}
}
onFilterSuccess
(
data
)
{
onFilterSuccess
(
data
)
{
if
(
data
.
html
)
{
this
.
listHolderElement
.
innerHTML
=
data
.
html
;
}
// Change url so if user reload a page - search results are saved
// Change url so if user reload a page - search results are saved
return
window
.
history
.
replaceState
({
return
window
.
history
.
replaceState
({
page
:
this
.
filterUrl
,
page
:
this
.
filterUrl
,
...
...
app/assets/javascripts/groups/groups_filterable_list.js
View file @
8064a400
...
@@ -6,13 +6,17 @@ export default class GroupFilterableList extends FilterableList {
...
@@ -6,13 +6,17 @@ export default class GroupFilterableList extends FilterableList {
super
(
form
,
filter
,
holder
);
super
(
form
,
filter
,
holder
);
this
.
store
=
store
;
this
.
store
=
store
;
this
.
$dropdown
=
$
(
'
.js-group-filter-dropdown-wrap
'
);
}
}
bindEvents
()
{
bindEvents
()
{
super
.
bindEvents
();
super
.
bindEvents
();
this
.
onFormSubmitWrapper
=
this
.
onFormSubmit
.
bind
(
this
);
this
.
onFormSubmitWrapper
=
this
.
onFormSubmit
.
bind
(
this
);
this
.
onFilterOptionClikWrapper
=
this
.
onOptionClick
.
bind
(
this
);
this
.
filterForm
.
addEventListener
(
'
submit
'
,
this
.
onFormSubmitWrapper
);
this
.
filterForm
.
addEventListener
(
'
submit
'
,
this
.
onFormSubmitWrapper
);
this
.
$dropdown
.
on
(
'
click
'
,
'
a
'
,
this
.
onFilterOptionClikWrapper
);
}
}
onFormSubmit
(
e
)
{
onFormSubmit
(
e
)
{
...
@@ -21,8 +25,17 @@ export default class GroupFilterableList extends FilterableList {
...
@@ -21,8 +25,17 @@ export default class GroupFilterableList extends FilterableList {
this
.
filterResults
();
this
.
filterResults
();
}
}
onOptionClick
(
e
)
{
e
.
preventDefault
();
const
currentOption
=
$
.
trim
(
e
.
currentTarget
.
text
);
this
.
filterUrl
=
e
.
currentTarget
.
href
;
this
.
$dropdown
.
find
(
'
.dropdown-label
'
).
text
(
currentOption
);
this
.
filterResults
(
this
.
filterUrl
);
}
onFilterSuccess
(
data
)
{
onFilterSuccess
(
data
)
{
super
.
onFilterSuccess
();
super
.
onFilterSuccess
(
data
);
this
.
store
.
setGroups
(
data
);
this
.
store
.
setGroups
(
data
);
}
}
...
...
app/views/shared/groups/_dropdown.html.haml
View file @
8064a400
.dropdown.inline
.dropdown.inline
.js-group-filter-dropdown-wrap
%button
.dropdown-toggle
{
type:
'button'
,
'data-toggle'
=>
'dropdown'
}
%button
.dropdown-toggle
{
type:
'button'
,
'data-toggle'
=>
'dropdown'
}
%span
.
light
%span
.
dropdown-label
-
if
@sort
.
present?
-
if
@sort
.
present?
=
sort_options_hash
[
@sort
]
=
sort_options_hash
[
@sort
]
-
else
-
else
=
sort_title_recently_created
=
sort_title_recently_created
=
icon
(
'chevron-down'
)
=
icon
(
'chevron-down'
)
%ul
.dropdown-menu.dropdown-menu-align-right
%ul
.dropdown-menu.dropdown-menu-align-right
%li
%li
...
...
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