Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
P
Papermerge.Js
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Jonas Leder
Papermerge.Js
Commits
eba7f934
Commit
eba7f934
authored
3 years ago
by
Eugen Ciur
Browse files
Options
Downloads
Patches
Plain Diff
use async/await style for doSearch action
parent
9097511f
No related branches found
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
app/components/search/index.js
+10
-21
10 additions, 21 deletions
app/components/search/index.js
app/services/requests.js
+1
-1
1 addition, 1 deletion
app/services/requests.js
app/styles/search.scss
+7
-1
7 additions, 1 deletion
app/styles/search.scss
with
18 additions
and
23 deletions
app/components/search/index.js
+
10
−
21
View file @
eba7f934
...
...
@@ -8,7 +8,7 @@ import { A } from '@ember/array';
export
default
class
SearchComponent
extends
Component
{
@
service
requests
;
@
tracked
query
;
autocomplete_items
=
A
([]);
@
tracked
autocomplete_items
=
A
([]);
/*
@tracked autocomplete_items = A([
{
...
...
@@ -35,27 +35,16 @@ export default class SearchComponent extends Component {
*/
@
action
doSearch
()
{
let
that
=
this
;
async
doSearch
()
{
let
response
=
await
this
.
requests
.
search
(
this
.
query
);
let
data
=
await
response
.
json
();
this
.
requests
.
search
(
this
.
query
).
then
(
resp
=>
resp
.
json
()
).
then
(
data
=>
{
data
.
forEach
(
item
=>
{
console
.
log
(
`pushing item
${
item
.
title
}
`
);
that
.
autocomplete_items
.
push
(
{
'
title
'
:
item
.
title
,
'
type
'
:
'
document
'
,
'
path
'
:
item
.
breadcrumb
,
}
)
});
this
.
autocomplete_items
=
data
.
map
(
item
=>
{
return
{
'
title
'
:
item
.
title
,
'
type
'
:
'
document
'
,
'
path
'
:
item
.
breadcrumb
,
}
});
if
(
this
.
autocomplete_items
)
{
//pass
}
}
}
This diff is collapsed.
Click to expand it.
app/services/requests.js
+
1
−
1
View file @
eba7f934
...
...
@@ -85,7 +85,7 @@ export default class Requests extends Service {
async
search
(
query
)
{
let
url
;
url
=
`
${
base_url
()}
/search?q=
${
query
}
`
;
url
=
`
${
base_url
()}
/search
/
?q=
${
query
}
`
;
return
fetch
(
url
,
{
method
:
'
GET
'
,
...
...
This diff is collapsed.
Click to expand it.
app/styles/search.scss
+
7
−
1
View file @
eba7f934
...
...
@@ -9,20 +9,26 @@
width
:
100%
;
top
:
3rem
;
background-color
:
white
;
padding
:
0rem
1rem
;
border
:
1px
solid
#d4d4d4
;
margin
:
0
;
padding
:
0
;
li
:hover
{
background-color
:
#e9e9e9
;
border-left
:
1px
solid
#0d6efd
;
cursor
:
pointer
;
}
li
{
background-color
:
#fff
;
border-left
:
1px
solid
#d4d4d4
;
z-index
:
1000
;
margin-top
:
0
.5rem
;
list-style
:
none
;
display
:
flex
;
align-items
:
center
;
margin
:
0
;
padding
:
0
.75rem
1rem
;
.path
{
padding-left
:
2rem
;
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment