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
0x43
eBookHub-frontend
Commits
7e4fc42d
Commit
7e4fc42d
authored
Apr 12, 2019
by
Mycha de Vrees
Browse files
fixes for book fetching
parent
d36b4eb9
Pipeline
#347
failed with stage
in 1 minute and 21 seconds
Changes
4
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
src/pages/Books/BooksList.vue
View file @
7e4fc42d
...
...
@@ -40,7 +40,7 @@
<
template
slot=
"authors"
slot-scope=
"row"
>
<template
v-for=
"(value, index) in row.value"
>
<router-link
:to=
"
{ name: 'Author view', params: { id: value.id }}" :key="index">
{{
value
.
name
}}{{
index
-
1
===
row
.
value
.
length
?
''
:
'
,
'
}}
{{
value
.
name
}}{{
index
+
1
===
row
.
value
.
length
?
''
:
'
,
'
}}
</router-link>
</
template
>
</template>
...
...
src/pages/Books/ViewBook.vue
View file @
7e4fc42d
...
...
@@ -36,8 +36,8 @@
* @vue-data {Boolean} isBusy - determine isBusy state for table
*/
// import { TablePagination } from '@/components'
import
{
mapActions
}
from
'
vuex
'
//
import _ from 'lodash'
import
{
mapActions
,
mapGetters
}
from
'
vuex
'
import
_
from
'
lodash
'
export
default
{
props
:
[
'
id
'
],
...
...
@@ -46,20 +46,18 @@ export default {
book
:
{}
}
},
computed
:
{
...
mapGetters
([
'
getCurrentBook
'
])
},
methods
:
{
...
mapActions
([
'
fetchBook
'
]),
async
fill
Book
()
{
async
_fetch
Book
()
{
await
this
.
fetchBook
({
id
:
this
.
id
,
vm
:
this
})
this
.
book
=
this
.
$store
.
state
.
book
.
c
urrent
this
.
book
=
_
.
cloneDeep
(
this
.
getC
urrent
Book
)
}
},
created
()
{
this
.
fill
Book
()
this
.
_fetch
Book
()
}
// watch: {
// author () {
// this.author = this.$store.state.author.current
// }
// }
}
</
script
>
src/store/modules/book.js
View file @
7e4fc42d
...
...
@@ -25,6 +25,9 @@ const getters = {
*/
getAllBooks
(
state
)
{
return
state
.
all
},
getCurrentBook
(
state
)
{
return
state
.
current
}
}
...
...
src/transformers/BookTransformer.js
View file @
7e4fc42d
...
...
@@ -24,7 +24,6 @@ function fetchMultipleBooks (response) {
}
function
fetchSingleBook
(
response
)
{
console
.
log
(
response
)
const
authors
=
[]
const
obj
=
{
id
:
response
.
data
.
data
.
id
,
...
...
@@ -32,7 +31,11 @@ function fetchSingleBook (response) {
}
response
.
data
.
data
.
relationships
.
authors
.
data
.
map
((
author
)
=>
{
const
foundAuthor
=
_
.
find
(
response
.
data
.
included
,
(
included
)
=>
included
.
type
===
'
author
'
&&
included
.
id
===
author
.
id
)
authors
.
push
(
foundAuthor
.
attributes
.
name
)
const
authorObj
=
{
id
:
foundAuthor
.
id
,
name
:
foundAuthor
.
attributes
.
name
}
authors
.
push
(
authorObj
)
obj
.
authors
=
authors
})
return
obj
...
...
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