Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
C
coopwire-hypothesis
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
孙灵跃 Leon Sun
coopwire-hypothesis
Commits
57827351
Commit
57827351
authored
Jul 24, 2014
by
Ujvari Gergely
Committed by
gergely-ujvari
Jul 29, 2014
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Searchfilter handles empty query
parent
ed4a2b9e
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
53 additions
and
54 deletions
+53
-54
searchfilters.coffee
h/static/scripts/searchfilters.coffee
+48
-48
services.coffee
h/static/scripts/services.coffee
+0
-1
simple-search.scss
h/static/styles/simple-search.scss
+5
-5
No files found.
h/static/scripts/searchfilters.coffee
View file @
57827351
...
...
@@ -19,9 +19,6 @@ class SearchFilter
tokens
generateFacetedFilter
:
(
searchtext
)
->
return
unless
searchtext
terms
=
@
_tokenize
(
searchtext
)
any
=
[]
quote
=
[]
result
=
[]
...
...
@@ -31,51 +28,54 @@ class SearchFilter
uri
=
[]
user
=
[]
for
term
in
terms
filter
=
term
.
slice
0
,
term
.
indexOf
":"
unless
filter
?
then
filter
=
""
switch
filter
when
'quote'
then
quote
.
push
term
[
6
..]
when
'result'
then
result
.
push
term
[
7
..]
when
'since'
# We'll turn this into seconds
time
=
term
[
6
..].
toLowerCase
()
if
time
.
match
/^\d+$/
# Only digits, assuming seconds
since
.
push
time
if
time
.
match
/^\d+sec$/
# Time given in seconds
t
=
/^(\d+)sec$/
.
exec
(
time
)[
1
]
since
.
push
t
if
time
.
match
/^\d+min$/
# Time given in minutes
t
=
/^(\d+)min$/
.
exec
(
time
)[
1
]
since
.
push
t
*
60
if
time
.
match
/^\d+hour$/
# Time given in hours
t
=
/^(\d+)hour$/
.
exec
(
time
)[
1
]
since
.
push
t
*
60
*
60
if
time
.
match
/^\d+day$/
# Time given in days
t
=
/^(\d+)day$/
.
exec
(
time
)[
1
]
since
.
push
t
*
60
*
60
*
24
if
time
.
match
/^\d+week$/
# Time given in week
t
=
/^(\d+)week$/
.
exec
(
time
)[
1
]
since
.
push
t
*
60
*
60
*
24
*
7
if
time
.
match
/^\d+month$/
# Time given in month
t
=
/^(\d+)month$/
.
exec
(
time
)[
1
]
since
.
push
t
*
60
*
60
*
24
*
30
if
time
.
match
/^\d+year$/
# Time given in year
t
=
/^(\d+)year$/
.
exec
(
time
)[
1
]
since
.
push
t
*
60
*
60
*
24
*
365
when
'tag'
then
tag
.
push
term
[
4
..]
when
'text'
then
text
.
push
term
[
5
..]
when
'uri'
then
uri
.
push
term
[
4
..]
when
'user'
then
user
.
push
term
[
5
..]
else
any
.
push
term
if
searchtext
terms
=
@
_tokenize
(
searchtext
)
for
term
in
terms
filter
=
term
.
slice
0
,
term
.
indexOf
":"
unless
filter
?
then
filter
=
""
switch
filter
when
'quote'
then
quote
.
push
term
[
6
..]
when
'result'
then
result
.
push
term
[
7
..]
when
'since'
# We'll turn this into seconds
time
=
term
[
6
..].
toLowerCase
()
if
time
.
match
/^\d+$/
# Only digits, assuming seconds
since
.
push
time
if
time
.
match
/^\d+sec$/
# Time given in seconds
t
=
/^(\d+)sec$/
.
exec
(
time
)[
1
]
since
.
push
t
if
time
.
match
/^\d+min$/
# Time given in minutes
t
=
/^(\d+)min$/
.
exec
(
time
)[
1
]
since
.
push
t
*
60
if
time
.
match
/^\d+hour$/
# Time given in hours
t
=
/^(\d+)hour$/
.
exec
(
time
)[
1
]
since
.
push
t
*
60
*
60
if
time
.
match
/^\d+day$/
# Time given in days
t
=
/^(\d+)day$/
.
exec
(
time
)[
1
]
since
.
push
t
*
60
*
60
*
24
if
time
.
match
/^\d+week$/
# Time given in week
t
=
/^(\d+)week$/
.
exec
(
time
)[
1
]
since
.
push
t
*
60
*
60
*
24
*
7
if
time
.
match
/^\d+month$/
# Time given in month
t
=
/^(\d+)month$/
.
exec
(
time
)[
1
]
since
.
push
t
*
60
*
60
*
24
*
30
if
time
.
match
/^\d+year$/
# Time given in year
t
=
/^(\d+)year$/
.
exec
(
time
)[
1
]
since
.
push
t
*
60
*
60
*
24
*
365
when
'tag'
then
tag
.
push
term
[
4
..]
when
'text'
then
text
.
push
term
[
5
..]
when
'uri'
then
uri
.
push
term
[
4
..]
when
'user'
then
user
.
push
term
[
5
..]
else
any
.
push
term
any
:
terms
:
any
operator
:
'and'
...
...
h/static/scripts/services.coffee
View file @
57827351
...
...
@@ -783,7 +783,6 @@ class ViewFilter
#
# Returns the list of matching annotation IDs.
filter
:
(
annotations
,
query
)
=>
return
[]
unless
query
.
query
filters
=
@
searchfilter
.
generateFacetedFilter
query
.
query
results
=
[]
...
...
h/static/styles/simple-search.scss
View file @
57827351
...
...
@@ -5,7 +5,7 @@
color
:
$gray
;
&
.simple-search-inactive
{
color
:
$gray
L
ighter
;
color
:
$gray
-l
ighter
;
}
}
...
...
@@ -26,8 +26,8 @@
padding-left
:
2em
;
.simple-search-inactive
&
{
background-color
:
$gray
L
ightest
;
border-color
:
$gray
L
ightest
!
important
;
background-color
:
$gray
-l
ightest
;
border-color
:
$gray
-l
ightest
!
important
;
}
}
...
...
@@ -45,7 +45,7 @@
top
:
50%
;
border
:
none
;
border-radius
:
50%
;
background
:
$gray
L
ight
;
background
:
$gray
-l
ight
;
color
:
#fff
;
width
:
16px
;
height
:
16px
;
...
...
@@ -58,7 +58,7 @@
&
:focus
,
&
:hover
,
&
:active:not
([
disabled
])
{
@include
transition
(
background-color
200ms
ease-in
);
background-color
:
$gray
L
ight
;
background-color
:
$gray
-l
ight
;
color
:
#fff
;
border
:
none
;
background-image
:
none
;
...
...
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