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
3e89960d
Commit
3e89960d
authored
Jul 20, 2017
by
Clement Ho
Committed by
Jacob Schatz
Jul 20, 2017
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Refactor filtered search dropdown parameters
parent
01e02988
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
36 additions
and
16 deletions
+36
-16
app/assets/javascripts/filtered_search/dropdown_hint.js
app/assets/javascripts/filtered_search/dropdown_hint.js
+3
-2
app/assets/javascripts/filtered_search/dropdown_non_user.js
app/assets/javascripts/filtered_search/dropdown_non_user.js
+3
-2
app/assets/javascripts/filtered_search/dropdown_user.js
app/assets/javascripts/filtered_search/dropdown_user.js
+3
-2
app/assets/javascripts/filtered_search/filtered_search_dropdown.js
...s/javascripts/filtered_search/filtered_search_dropdown.js
+1
-1
app/assets/javascripts/filtered_search/filtered_search_dropdown_manager.js
...ripts/filtered_search/filtered_search_dropdown_manager.js
+19
-7
spec/javascripts/filtered_search/dropdown_user_spec.js
spec/javascripts/filtered_search/dropdown_user_spec.js
+7
-2
No files found.
app/assets/javascripts/filtered_search/dropdown_hint.js
View file @
3e89960d
...
@@ -2,8 +2,9 @@ import Filter from '~/droplab/plugins/filter';
...
@@ -2,8 +2,9 @@ import Filter from '~/droplab/plugins/filter';
import
'
./filtered_search_dropdown
'
;
import
'
./filtered_search_dropdown
'
;
class
DropdownHint
extends
gl
.
FilteredSearchDropdown
{
class
DropdownHint
extends
gl
.
FilteredSearchDropdown
{
constructor
(
droplab
,
dropdown
,
input
,
tokenKeys
,
filter
)
{
constructor
(
options
=
{})
{
super
(
droplab
,
dropdown
,
input
,
filter
);
const
{
input
,
tokenKeys
}
=
options
;
super
(
options
);
this
.
config
=
{
this
.
config
=
{
Filter
:
{
Filter
:
{
template
:
'
hint
'
,
template
:
'
hint
'
,
...
...
app/assets/javascripts/filtered_search/dropdown_non_user.js
View file @
3e89960d
...
@@ -5,8 +5,9 @@ import Filter from '~/droplab/plugins/filter';
...
@@ -5,8 +5,9 @@ import Filter from '~/droplab/plugins/filter';
import
'
./filtered_search_dropdown
'
;
import
'
./filtered_search_dropdown
'
;
class
DropdownNonUser
extends
gl
.
FilteredSearchDropdown
{
class
DropdownNonUser
extends
gl
.
FilteredSearchDropdown
{
constructor
(
droplab
,
dropdown
,
input
,
tokenKeys
,
filter
,
endpoint
,
symbol
)
{
constructor
(
options
=
{})
{
super
(
droplab
,
dropdown
,
input
,
filter
);
const
{
input
,
endpoint
,
symbol
}
=
options
;
super
(
options
);
this
.
symbol
=
symbol
;
this
.
symbol
=
symbol
;
this
.
config
=
{
this
.
config
=
{
Ajax
:
{
Ajax
:
{
...
...
app/assets/javascripts/filtered_search/dropdown_user.js
View file @
3e89960d
...
@@ -5,8 +5,9 @@ import './filtered_search_dropdown';
...
@@ -5,8 +5,9 @@ import './filtered_search_dropdown';
import
{
addClassIfElementExists
}
from
'
../lib/utils/dom_utils
'
;
import
{
addClassIfElementExists
}
from
'
../lib/utils/dom_utils
'
;
class
DropdownUser
extends
gl
.
FilteredSearchDropdown
{
class
DropdownUser
extends
gl
.
FilteredSearchDropdown
{
constructor
(
droplab
,
dropdown
,
input
,
tokenKeys
,
filter
)
{
constructor
(
options
=
{})
{
super
(
droplab
,
dropdown
,
input
,
filter
);
const
{
tokenKeys
}
=
options
;
super
(
options
);
this
.
config
=
{
this
.
config
=
{
AjaxFilter
:
{
AjaxFilter
:
{
endpoint
:
`
${
gon
.
relative_url_root
||
''
}
/autocomplete/users.json`
,
endpoint
:
`
${
gon
.
relative_url_root
||
''
}
/autocomplete/users.json`
,
...
...
app/assets/javascripts/filtered_search/filtered_search_dropdown.js
View file @
3e89960d
const
DATA_DROPDOWN_TRIGGER
=
'
data-dropdown-trigger
'
;
const
DATA_DROPDOWN_TRIGGER
=
'
data-dropdown-trigger
'
;
class
FilteredSearchDropdown
{
class
FilteredSearchDropdown
{
constructor
(
droplab
,
dropdown
,
input
,
filter
)
{
constructor
(
{
droplab
,
dropdown
,
input
,
filter
}
)
{
this
.
droplab
=
droplab
;
this
.
droplab
=
droplab
;
this
.
hookId
=
input
&&
input
.
id
;
this
.
hookId
=
input
&&
input
.
id
;
this
.
input
=
input
;
this
.
input
=
input
;
...
...
app/assets/javascripts/filtered_search/filtered_search_dropdown_manager.js
View file @
3e89960d
...
@@ -42,13 +42,19 @@ class FilteredSearchDropdownManager {
...
@@ -42,13 +42,19 @@ class FilteredSearchDropdownManager {
milestone
:
{
milestone
:
{
reference
:
null
,
reference
:
null
,
gl
:
'
DropdownNonUser
'
,
gl
:
'
DropdownNonUser
'
,
extraArguments
:
[
`
${
this
.
baseEndpoint
}
/milestones.json`
,
'
%
'
],
extraArguments
:
{
endpoint
:
`
${
this
.
baseEndpoint
}
/milestones.json`
,
symbol
:
'
%
'
,
},
element
:
this
.
container
.
querySelector
(
'
#js-dropdown-milestone
'
),
element
:
this
.
container
.
querySelector
(
'
#js-dropdown-milestone
'
),
},
},
label
:
{
label
:
{
reference
:
null
,
reference
:
null
,
gl
:
'
DropdownNonUser
'
,
gl
:
'
DropdownNonUser
'
,
extraArguments
:
[
`
${
this
.
baseEndpoint
}
/labels.json`
,
'
~
'
],
extraArguments
:
{
endpoint
:
`
${
this
.
baseEndpoint
}
/labels.json`
,
symbol
:
'
~
'
,
},
element
:
this
.
container
.
querySelector
(
'
#js-dropdown-label
'
),
element
:
this
.
container
.
querySelector
(
'
#js-dropdown-label
'
),
},
},
hint
:
{
hint
:
{
...
@@ -97,13 +103,19 @@ class FilteredSearchDropdownManager {
...
@@ -97,13 +103,19 @@ class FilteredSearchDropdownManager {
let
forceShowList
=
false
;
let
forceShowList
=
false
;
if
(
!
mappingKey
.
reference
)
{
if
(
!
mappingKey
.
reference
)
{
const
dl
=
this
.
droplab
;
const
defaultArguments
=
{
const
defaultArguments
=
droplab
:
this
.
droplab
,
[
null
,
dl
,
element
,
this
.
filteredSearchInput
,
this
.
filteredSearchTokenKeys
,
key
];
dropdown
:
element
,
const
glArguments
=
defaultArguments
.
concat
(
mappingKey
.
extraArguments
||
[]);
input
:
this
.
filteredSearchInput
,
tokenKeys
:
this
.
filteredSearchTokenKeys
,
filter
:
key
,
};
const
extraArguments
=
mappingKey
.
extraArguments
||
{};
const
glArguments
=
Object
.
assign
({},
defaultArguments
,
extraArguments
);
// Passing glArguments to `new gl[glClass](<arguments>)`
// Passing glArguments to `new gl[glClass](<arguments>)`
mappingKey
.
reference
=
new
(
Function
.
prototype
.
bind
.
apply
(
gl
[
glClass
],
glArguments
))();
mappingKey
.
reference
=
new
(
Function
.
prototype
.
bind
.
apply
(
gl
[
glClass
],
[
null
,
glArguments
]))();
}
}
if
(
firstLoad
)
{
if
(
firstLoad
)
{
...
...
spec/javascripts/filtered_search/dropdown_user_spec.js
View file @
3e89960d
...
@@ -12,7 +12,9 @@ describe('Dropdown User', () => {
...
@@ -12,7 +12,9 @@ describe('Dropdown User', () => {
spyOn
(
gl
.
DropdownUser
.
prototype
,
'
getProjectId
'
).
and
.
callFake
(()
=>
{});
spyOn
(
gl
.
DropdownUser
.
prototype
,
'
getProjectId
'
).
and
.
callFake
(()
=>
{});
spyOn
(
gl
.
DropdownUtils
,
'
getSearchInput
'
).
and
.
callFake
(()
=>
{});
spyOn
(
gl
.
DropdownUtils
,
'
getSearchInput
'
).
and
.
callFake
(()
=>
{});
dropdownUser
=
new
gl
.
DropdownUser
(
null
,
null
,
null
,
gl
.
FilteredSearchTokenKeys
);
dropdownUser
=
new
gl
.
DropdownUser
({
tokenKeys
:
gl
.
FilteredSearchTokenKeys
,
});
});
});
it
(
'
should not return the double quote found in value
'
,
()
=>
{
it
(
'
should not return the double quote found in value
'
,
()
=>
{
...
@@ -78,7 +80,10 @@ describe('Dropdown User', () => {
...
@@ -78,7 +80,10 @@ describe('Dropdown User', () => {
loadFixtures
(
fixtureTemplate
);
loadFixtures
(
fixtureTemplate
);
authorFilterDropdownElement
=
document
.
querySelector
(
'
#js-dropdown-author
'
);
authorFilterDropdownElement
=
document
.
querySelector
(
'
#js-dropdown-author
'
);
const
dummyInput
=
document
.
createElement
(
'
div
'
);
const
dummyInput
=
document
.
createElement
(
'
div
'
);
dropdown
=
new
gl
.
DropdownUser
(
null
,
authorFilterDropdownElement
,
dummyInput
);
dropdown
=
new
gl
.
DropdownUser
({
dropdown
:
authorFilterDropdownElement
,
input
:
dummyInput
,
});
});
});
const
findCurrentUserElement
=
()
=>
authorFilterDropdownElement
.
querySelector
(
'
.js-current-user
'
);
const
findCurrentUserElement
=
()
=>
authorFilterDropdownElement
.
querySelector
(
'
.js-current-user
'
);
...
...
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