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
40bbecf6
Commit
40bbecf6
authored
Feb 06, 2018
by
Phil Hughes
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Converted search_autocomplete.js to use axios
parent
1a430836
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
23 additions
and
16 deletions
+23
-16
app/assets/javascripts/search_autocomplete.js
app/assets/javascripts/search_autocomplete.js
+23
-16
No files found.
app/assets/javascripts/search_autocomplete.js
View file @
40bbecf6
/* eslint-disable no-return-assign, one-var, no-var, no-underscore-dangle, one-var-declaration-per-line, no-unused-vars, no-cond-assign, consistent-return, object-shorthand, prefer-arrow-callback, func-names, space-before-function-paren, prefer-template, quotes, class-methods-use-this, no-sequences, wrap-iife, no-lonely-if, no-else-return, no-param-reassign, vars-on-top, max-len */
/* eslint-disable no-return-assign, one-var, no-var, no-underscore-dangle, one-var-declaration-per-line, no-unused-vars, no-cond-assign, consistent-return, object-shorthand, prefer-arrow-callback, func-names, space-before-function-paren, prefer-template, quotes, class-methods-use-this, no-sequences, wrap-iife, no-lonely-if, no-else-return, no-param-reassign, vars-on-top, max-len */
import
axios
from
'
./lib/utils/axios_utils
'
;
import
{
isInGroupsPage
,
isInProjectPage
,
getGroupSlug
,
getProjectSlug
}
from
'
./lib/utils/common_utils
'
;
import
{
isInGroupsPage
,
isInProjectPage
,
getGroupSlug
,
getProjectSlug
}
from
'
./lib/utils/common_utils
'
;
/**
/**
...
@@ -146,23 +147,25 @@ export default class SearchAutocomplete {
...
@@ -146,23 +147,25 @@ export default class SearchAutocomplete {
this
.
loadingSuggestions
=
true
;
this
.
loadingSuggestions
=
true
;
return
$
.
get
(
this
.
autocompletePath
,
{
return
axios
.
get
(
this
.
autocompletePath
,
{
params
:
{
project_id
:
this
.
projectId
,
project_id
:
this
.
projectId
,
project_ref
:
this
.
projectRef
,
project_ref
:
this
.
projectRef
,
term
:
term
,
term
:
term
,
},
(
response
)
=>
{
},
var
firstCategory
,
i
,
lastCategory
,
len
,
suggestion
;
}).
then
((
response
)
=>
{
// Hide dropdown menu if no suggestions returns
// Hide dropdown menu if no suggestions returns
if
(
!
response
.
length
)
{
if
(
!
response
.
data
.
length
)
{
this
.
disableAutocomplete
();
this
.
disableAutocomplete
();
return
;
return
;
}
}
const
data
=
[];
const
data
=
[];
// List results
// List results
firstCategory
=
true
;
let
firstCategory
=
true
;
for
(
i
=
0
,
len
=
response
.
length
;
i
<
len
;
i
+=
1
)
{
let
lastCategory
;
suggestion
=
response
[
i
];
for
(
let
i
=
0
,
len
=
response
.
data
.
length
;
i
<
len
;
i
+=
1
)
{
const
suggestion
=
response
.
data
[
i
];
// Add group header before list each group
// Add group header before list each group
if
(
lastCategory
!==
suggestion
.
category
)
{
if
(
lastCategory
!==
suggestion
.
category
)
{
if
(
!
firstCategory
)
{
if
(
!
firstCategory
)
{
...
@@ -177,7 +180,7 @@ export default class SearchAutocomplete {
...
@@ -177,7 +180,7 @@ export default class SearchAutocomplete {
lastCategory
=
suggestion
.
category
;
lastCategory
=
suggestion
.
category
;
}
}
data
.
push
({
data
.
push
({
id
:
(
suggestion
.
category
.
toLowerCase
())
+
"
-
"
+
suggestion
.
id
,
id
:
`
${
suggestion
.
category
.
toLowerCase
()}
-
${
suggestion
.
id
}
`
,
category
:
suggestion
.
category
,
category
:
suggestion
.
category
,
text
:
suggestion
.
label
,
text
:
suggestion
.
label
,
url
:
suggestion
.
url
,
url
:
suggestion
.
url
,
...
@@ -187,13 +190,17 @@ export default class SearchAutocomplete {
...
@@ -187,13 +190,17 @@ export default class SearchAutocomplete {
if
(
data
.
length
)
{
if
(
data
.
length
)
{
data
.
push
(
'
separator
'
);
data
.
push
(
'
separator
'
);
data
.
push
({
data
.
push
({
text
:
"
Result name contains
\"
"
+
term
+
"
\"
"
,
text
:
`Result name contains "
${
term
}
"`
,
url
:
"
/search?search=
"
+
term
+
"
&project_id=
"
+
(
this
.
projectInputEl
.
val
())
+
"
&group_id=
"
+
(
this
.
groupInputEl
.
val
())
,
url
:
`/search?search=
${
term
}
&project_id=
${
this
.
projectInputEl
.
val
()}
&group_id=
${
this
.
groupInputEl
.
val
()}
`
,
});
});
}
}
return
callback
(
data
);
})
callback
(
data
);
.
always
(()
=>
{
this
.
loadingSuggestions
=
false
;
});
this
.
loadingSuggestions
=
false
;
}).
catch
(()
=>
{
this
.
loadingSuggestions
=
false
;
});
}
}
getCategoryContents
()
{
getCategoryContents
()
{
...
...
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