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
53d575ac
Commit
53d575ac
authored
Sep 04, 2017
by
kushalpandya
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Projects Dropdown Search Input Component
parent
65a883a0
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
64 additions
and
0 deletions
+64
-0
app/assets/javascripts/projects_dropdown/components/search.vue
...ssets/javascripts/projects_dropdown/components/search.vue
+64
-0
No files found.
app/assets/javascripts/projects_dropdown/components/search.vue
0 → 100644
View file @
53d575ac
<
script
>
import
_
from
'
underscore
'
;
import
eventHub
from
'
../event_hub
'
;
export
default
{
data
()
{
return
{
searchQuery
:
''
,
};
},
watch
:
{
searchQuery
()
{
this
.
handleInput
();
},
},
methods
:
{
setFocus
()
{
this
.
$refs
.
search
.
focus
();
},
emitSearchEvents
()
{
if
(
this
.
searchQuery
)
{
eventHub
.
$emit
(
'
searchProjects
'
,
this
.
searchQuery
);
}
else
{
eventHub
.
$emit
(
'
searchCleared
'
);
}
},
/**
* Callback function within _.debounce is intentionally
* kept as ES5 `function() {}` instead of ES6 `() => {}`
* as it otherwise messes up function context
* and component reference is no longer accessible via `this`
*/
// eslint-disable-next-line func-names
handleInput
:
_
.
debounce
(
function
()
{
this
.
emitSearchEvents
();
},
500
),
},
mounted
()
{
eventHub
.
$on
(
'
dropdownOpen
'
,
this
.
setFocus
);
},
beforeDestroy
()
{
eventHub
.
$off
(
'
dropdownOpen
'
,
this
.
setFocus
);
},
};
</
script
>
<
template
>
<div
class=
"search-input-container hidden-xs"
>
<input
type=
"search"
class=
"form-control"
ref=
"search"
v-model=
"searchQuery"
:placeholder=
"s__('ProjectsDropdown|Search projects')"
/>
<i
v-if=
"!searchQuery"
class=
"search-icon fa fa-fw fa-search"
aria-hidden=
"true"
/>
</div>
</
template
>
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