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
iv
gitlab-ce
Commits
521c0f5f
Commit
521c0f5f
authored
Mar 21, 2016
by
Alfredo Sumaran
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Reduce the use of loops
parent
a477d604
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
9 additions
and
14 deletions
+9
-14
app/assets/javascripts/search_autocomplete.js.coffee
app/assets/javascripts/search_autocomplete.js.coffee
+9
-14
No files found.
app/assets/javascripts/search_autocomplete.js.coffee
View file @
521c0f5f
...
...
@@ -97,25 +97,20 @@ class @SearchAutocomplete
},
(
response
)
->
data
=
[]
# Save groups ordering according to server response
groupNames
=
_
.
unique
(
_
.
pluck
(
response
,
'category'
))
# Group results by category name
groups
=
_
.
groupBy
response
,
(
item
)
->
item
.
category
# List results
for
groupName
in
groupNames
for
suggestion
in
response
# Add group header before list each group
if
lastCategory
isnt
suggestion
.
category
data
.
push
header
:
suggestion
.
category
lastCategory
=
suggestion
.
category
data
.
push
header
:
groupName
text
:
suggestion
.
label
url
:
suggestion
.
url
# List group
for
item
in
groups
[
groupName
]
data
.
push
text
:
item
.
label
url
:
item
.
url
callback
(
data
)
).
always
->
loading
=
false
...
...
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