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
1edeecb0
Commit
1edeecb0
authored
Nov 15, 2018
by
Alexis Reigel
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
inherit DropdownUser from DropdownAjaxFilter
parent
2e052925
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
20 additions
and
63 deletions
+20
-63
app/assets/javascripts/filtered_search/dropdown_user.js
app/assets/javascripts/filtered_search/dropdown_user.js
+20
-63
No files found.
app/assets/javascripts/filtered_search/dropdown_user.js
View file @
1edeecb0
import
Flash
from
'
../flash
'
;
import
AjaxFilter
from
'
../droplab/plugins/ajax_filter
'
;
import
FilteredSearchDropdown
from
'
./filtered_search_dropdown
'
;
import
{
addClassIfElementExists
}
from
'
../lib/utils/dom_utils
'
;
import
{
addClassIfElementExists
}
from
'
../lib/utils/dom_utils
'
;
import
DropdownUtils
from
'
./dropdown_utils
'
;
import
DropdownAjaxFilter
from
'
./dropdown_ajax_filter
'
;
import
FilteredSearchTokenizer
from
'
./filtered_search_tokenizer
'
;
export
default
class
DropdownUser
extends
FilteredSearchDropdown
{
export
default
class
DropdownUser
extends
DropdownAjaxFilter
{
constructor
(
options
=
{})
{
constructor
(
options
=
{})
{
const
{
tokenKeys
}
=
options
;
super
({
super
(
options
);
...
options
,
this
.
config
=
{
endpoint
:
'
/autocomplete/users.json
'
,
AjaxFilter
:
{
symbol
:
'
@
'
,
endpoint
:
`
${
gon
.
relative_url_root
||
''
}
/autocomplete/users.json`
,
});
searchKey
:
'
search
'
,
}
params
:
{
active
:
true
,
ajaxFilterConfig
()
{
group_id
:
this
.
getGroupId
(),
return
{
project_id
:
this
.
getProjectId
(),
...
super
.
ajaxFilterConfig
(),
current_user
:
true
,
params
:
{
},
active
:
true
,
searchValueFunction
:
this
.
getSearchInput
.
bind
(
this
),
group_id
:
this
.
getGroupId
(),
loadingTemplate
:
this
.
loadingTemplate
,
project_id
:
this
.
getProjectId
(),
onLoadingFinished
:
()
=>
{
current_user
:
true
,
this
.
hideCurrentUser
();
},
},
onLoadingFinished
:
()
=>
{
onError
()
{
this
.
hideCurrentUser
();
/* eslint-disable no-new */
new
Flash
(
'
An error occurred fetching the dropdown data.
'
);
/* eslint-enable no-new */
},
},
},
};
};
this
.
tokenKeys
=
tokenKeys
;
}
}
hideCurrentUser
()
{
hideCurrentUser
()
{
addClassIfElementExists
(
this
.
dropdown
.
querySelector
(
'
.js-current-user
'
),
'
hidden
'
);
addClassIfElementExists
(
this
.
dropdown
.
querySelector
(
'
.js-current-user
'
),
'
hidden
'
);
}
}
itemClicked
(
e
)
{
super
.
itemClicked
(
e
,
selected
=>
selected
.
querySelector
(
'
.dropdown-light-content
'
).
innerText
.
trim
(),
);
}
renderContent
(
forceShowList
=
false
)
{
this
.
droplab
.
changeHookList
(
this
.
hookId
,
this
.
dropdown
,
[
AjaxFilter
],
this
.
config
);
super
.
renderContent
(
forceShowList
);
}
getGroupId
()
{
getGroupId
()
{
return
this
.
input
.
getAttribute
(
'
data-group-id
'
);
return
this
.
input
.
getAttribute
(
'
data-group-id
'
);
}
}
...
@@ -56,27 +36,4 @@ export default class DropdownUser extends FilteredSearchDropdown {
...
@@ -56,27 +36,4 @@ export default class DropdownUser extends FilteredSearchDropdown {
getProjectId
()
{
getProjectId
()
{
return
this
.
input
.
getAttribute
(
'
data-project-id
'
);
return
this
.
input
.
getAttribute
(
'
data-project-id
'
);
}
}
getSearchInput
()
{
const
query
=
DropdownUtils
.
getSearchInput
(
this
.
input
);
const
{
lastToken
}
=
FilteredSearchTokenizer
.
processTokens
(
query
,
this
.
tokenKeys
.
get
());
let
value
=
lastToken
||
''
;
if
(
value
[
0
]
===
'
@
'
)
{
value
=
value
.
slice
(
1
);
}
// Removes the first character if it is a quotation so that we can search
// with multiple words
if
(
value
[
0
]
===
'
"
'
||
value
[
0
]
===
"
'
"
)
{
value
=
value
.
slice
(
1
);
}
return
value
;
}
init
()
{
this
.
droplab
.
addHook
(
this
.
input
,
this
.
dropdown
,
[
AjaxFilter
],
this
.
config
).
init
();
}
}
}
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