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
7d7f5185
Commit
7d7f5185
authored
Apr 12, 2019
by
Mycha de Vrees
Browse files
map series to bookslist
parent
666e3ec9
Pipeline
#353
passed with stage
in 1 minute and 23 seconds
Changes
3
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
src/pages/Books/BooksList.vue
View file @
7d7f5185
...
...
@@ -43,6 +43,9 @@
</router-link>
</
template
>
</template>
<
template
slot=
"serie"
slot-scope=
"row"
>
{{
row
.
value
.
name
}}
</
template
>
</b-table>
<TablePagination
:total-rows=
"totalRows"
...
...
@@ -85,7 +88,7 @@ export default {
{
key
:
'
title
'
,
label
:
'
Title
'
,
sortable
:
true
},
{
key
:
'
language
'
,
label
:
'
Language
'
,
sortable
:
true
},
{
key
:
'
authors
'
,
label
:
'
Authors
'
,
sortable
:
true
},
{
key
:
'
serie
_id
'
,
label
:
'
Serie
s
'
,
sortable
:
true
}
{
key
:
'
serie
'
,
label
:
'
Serie
'
,
sortable
:
true
}
],
bookItems
:
[],
totalRows
:
this
.
bookRows
...
...
src/store/modules/book.js
View file @
7d7f5185
...
...
@@ -89,7 +89,7 @@ const actions = {
const
newCtx
=
CtxTransformer
.
transformCtx
(
ctx
)
const
params
=
{
contentType
:
'
application/json
'
,
include
:
'
authors
'
,
include
:
'
authors
,serie
'
,
...
newCtx
}
const
response
=
await
getBooks
(
params
)
...
...
src/transformers/BookTransformer.js
View file @
7d7f5185
...
...
@@ -10,17 +10,26 @@ function fetchMultipleBooks (response) {
...
book
.
attributes
}
if
(
Object
.
hasOwnProperty
.
call
(
book
,
'
relationships
'
))
{
if
(
Object
.
hasOwnProperty
.
call
(
book
.
relationships
,
'
authors
'
))
{
if
(
Object
.
hasOwnProperty
.
call
(
book
.
relationships
,
'
authors
'
)
&&
book
.
relationships
.
authors
.
data
)
{
book
.
relationships
.
authors
.
data
.
map
((
author
)
=>
{
const
foundAuthor
=
_
.
find
(
response
.
data
.
included
,
(
included
)
=>
included
.
type
===
'
author
'
&&
included
.
id
===
author
.
id
)
const
authorObj
=
{
id
:
foundAuthor
.
id
,
name
:
foundAuthor
.
attributes
.
name
...
foundAuthor
.
attributes
}
authors
.
push
(
authorObj
)
obj
.
authors
=
authors
})
}
if
(
Object
.
hasOwnProperty
.
call
(
book
.
relationships
,
'
serie
'
)
&&
book
.
relationships
.
serie
.
data
)
{
const
serieId
=
book
.
relationships
.
serie
.
data
.
id
const
foundSerie
=
_
.
find
(
response
.
data
.
included
,
(
included
)
=>
included
.
type
===
'
book_serie
'
&&
included
.
id
===
serieId
)
const
serieObj
=
{
id
:
foundSerie
.
id
,
...
foundSerie
.
attributes
}
obj
.
serie
=
serieObj
}
}
books
.
push
(
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