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
a257f489
Commit
a257f489
authored
Nov 08, 2016
by
Clement Ho
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add clear search button
parent
823185ec
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
43 additions
and
2 deletions
+43
-2
app/assets/javascripts/filtered_search/filtered_search_manager.js.es6
...avascripts/filtered_search/filtered_search_manager.js.es6
+21
-0
app/assets/stylesheets/framework/filters.scss
app/assets/stylesheets/framework/filters.scss
+20
-2
app/views/shared/issuable/_search_bar.html.haml
app/views/shared/issuable/_search_bar.html.haml
+2
-0
No files found.
app/assets/javascripts/filtered_search/filtered_search_manager.js.es6
View file @
a257f489
...
@@ -29,9 +29,23 @@
...
@@ -29,9 +29,23 @@
bindEvents() {
bindEvents() {
const input = document.querySelector('.filtered-search');
const input = document.querySelector('.filtered-search');
const clearSearch = document.querySelector('.clear-search');
input.addEventListener('input', this.tokenize.bind(this));
input.addEventListener('input', this.tokenize.bind(this));
input.addEventListener('keydown', this.checkForEnter.bind(this));
input.addEventListener('keydown', this.checkForEnter.bind(this));
clearSearch.addEventListener('click', this.clearSearch.bind(this));
}
clearSearch(event) {
event.stopPropagation();
event.preventDefault();
this.clearTokens();
const input = document.querySelector('.filtered-search');
input.value = '';
event.target.classList.add('hidden');
}
}
clearTokens() {
clearTokens() {
...
@@ -64,12 +78,19 @@
...
@@ -64,12 +78,19 @@
// Trim the last space value
// Trim the last space value
document.querySelector('.filtered-search').value = inputValue.trim();
document.querySelector('.filtered-search').value = inputValue.trim();
if (inputValue.trim()) {
document.querySelector('.clear-search').classList.remove('hidden');
}
}
}
tokenize(event) {
tokenize(event) {
// Re-calculate tokens
// Re-calculate tokens
this.clearTokens();
this.clearTokens();
// Enable clear button
document.querySelector('.clear-search').classList.remove('hidden');
// TODO: Current implementation does not support token values that have valid spaces in them
// TODO: Current implementation does not support token values that have valid spaces in them
// Example/ label:community contribution
// Example/ label:community contribution
const input = event.target.value;
const input = event.target.value;
...
...
app/assets/stylesheets/framework/filters.scss
View file @
a257f489
...
@@ -39,11 +39,29 @@
...
@@ -39,11 +39,29 @@
color
:
#444
;
color
:
#444
;
}
}
}
}
.fa-filter
{
.fa-filter
{
position
:
absolute
;
position
:
absolute
;
left
:
10px
;
top
:
10px
;
top
:
10px
;
left
:
10px
;
color
:
$gray-darkest
;
}
.fa-times
{
right
:
10px
;
color
:
$gray-darkest
;
color
:
$gray-darkest
;
}
}
.clear-search
{
width
:
35px
;
background-color
:
transparent
;
border
:
none
;
position
:
absolute
;
right
:
0px
;
height
:
100%
;
outline
:
none
;
&
:hover
.fa-times
{
color
:
#444
;
}
}
}
}
app/views/shared/issuable/_search_bar.html.haml
View file @
a257f489
...
@@ -14,6 +14,8 @@
...
@@ -14,6 +14,8 @@
.filtered-search-input-container
.filtered-search-input-container
%input
.form-control.filtered-search
{
placeholder:
'Search or filter results...'
}
%input
.form-control.filtered-search
{
placeholder:
'Search or filter results...'
}
=
icon
(
'filter'
)
=
icon
(
'filter'
)
%button
.clear-search.hidden
=
icon
(
'times'
)
.pull-right
.pull-right
-
if
boards_page
-
if
boards_page
#js-boards-seach
.issue-boards-search
#js-boards-seach
.issue-boards-search
...
...
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