Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
bonita
bonita-web-pages
Commits
1438231e
Commit
1438231e
authored
Mar 08, 2018
by
julienmege
Browse files
pass search filter to the parent
parent
8ddc096b
Changes
3
Hide whitespace changes
Inline
Side-by-side
user-list-vue-webpack/src/App.vue
View file @
1438231e
<
template
>
<div
id=
"app"
>
<img
src=
"./assets/logo.png"
>
<Filters
:userList=
"users"
/>
<UserList/>
<Filters
:search=
"searchQuery"
@
input=
"search =>
{ searchQuery = search }"/>
<UserList
:search=
"searchQuery"
/>
</div>
</
template
>
<
script
>
import
UserList
from
'
./components/UserList/UserList
'
import
Filters
from
'
./components/Filters
'
import
fetchUsers
from
'
@bonita/api/src/fetchUsers.js
'
export
default
{
name
:
'
App
'
,
data
()
{
return
{
u
se
rs
:
[]
se
archQuery
:
''
}
},
created
()
{
// fetch the data when the view is created and the data is already being observed
fetchUsers
().
then
((
users
)
=>
{
this
.
users
=
users
})
},
components
:
{
UserList
,
Filters
...
...
user-list-vue-webpack/src/components/Filters.vue
View file @
1438231e
<
template
>
<div
class=
"filters"
>
<h1>
{{
msg
}}
</h1>
<ul>
<li
v-bind:key=
"user.userName"
v-for=
"user in userList"
>
{{
user
.
userName
}}
</li>
</ul>
</div>
<h1>
Search:
</h1>
<input
v-bind:value=
"searchFilter"
v-on:input=
"updateSearch($event.target.value)"
>
</div>
</
template
>
<
script
>
export
default
{
name
:
'
Filters
'
,
props
:
[
'
u
se
rList
'
],
props
:
[
'
se
arch
'
],
data
()
{
return
{
msg
:
'
Welcome to Your Vue.js App
'
,
usersList
:
[]
searchFilter
:
this
.
search
}
},
created
()
{
methods
:
{
updateSearch
:
function
(
value
)
{
this
.
$emit
(
'
input
'
,
value
)
}
}
}
</
script
>
...
...
user-list-vue-webpack/src/components/UserList/script.js
View file @
1438231e
import
fetchUsers
from
'
../../../../common/api/src/fetchUsers.js
'
export
default
{
name
:
'
Users
'
,
props
:
[
'
search
'
],
data
()
{
return
{
msg
:
'
Welcome to Your Vue.js App
'
,
...
...
Write
Preview
Supports
Markdown
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