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
6c885d89
Commit
6c885d89
authored
Apr 05, 2019
by
Mycha de Vrees
Browse files
remove created() and let bookprovider handle results
parent
5ad32751
Pipeline
#332
passed with stage
in 1 minute and 36 seconds
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
src/pages/BooksList.vue
View file @
6c885d89
...
...
@@ -24,7 +24,7 @@
<b-table
striped
hover
borderless
show-empty
id=
"booksTable"
ref=
"booksTable"
:items=
"book
Items
"
:items=
"book
sProvider
"
:fields=
"bookFields"
:busy.sync=
"isBusy"
:filter=
"booksFilter"
...
...
@@ -100,9 +100,8 @@ export default {
this
.
isBusy
=
true
await
this
.
fetchBooks
({
ctx
,
vm
:
this
})
// await this.$store.dispatch('fetchBooks', {ctx, vm: this})
this
.
isBusy
=
false
this
.
totalRows
=
this
.
$store
.
state
.
book
.
count
return
this
.
$store
.
state
.
book
.
all
}
},
...
...
@@ -121,12 +120,6 @@ export default {
this
.
currentPage
=
1
this
.
filterDebounce
(
filterValue
,
this
.
filter
)
}
},
created
()
{
this
.
$store
.
dispatch
(
'
fetchBooks
'
,
{
vm
:
this
}).
then
(
this
.
$nextTick
).
then
(()
=>
{
this
.
bookItems
=
this
.
$store
.
state
.
book
.
all
this
.
totalRows
=
this
.
bookItems
.
length
})
}
}
</
script
>
src/store/modules/book.js
View file @
6c885d89
...
...
@@ -5,6 +5,7 @@
import
BookTransformer
from
'
@/transformers/BookTransformer
'
import
{
RetrieveaBookobject_0
as
getBook
}
from
'
@/api/api.js
'
import
CtxTransformer
from
'
../../transformers/CtxTransformer
'
// Types
export
const
BOOK_STATE_RESETTING
=
'
BOOK_STATE_RESETTING
'
...
...
@@ -31,7 +32,8 @@ const getters = {
* @returns {{all: {}, isFetching: boolean, error: string }}
*/
const
getDefaultState
=
()
=>
({
all
:
{},
all
:
[],
count
:
0
,
isFetching
:
false
,
error
:
null
})
...
...
@@ -57,12 +59,13 @@ const actions = {
*/
async
fetchBooks
({
commit
},
{
ctx
,
vm
})
{
try
{
console
.
log
(
ctx
)
commit
(
BOOKS_FETCHING
,
true
,
null
)
const
params
=
{
contentType
:
'
application/json
'
}
const
newCtx
=
CtxTransformer
.
transformCtx
(
ctx
)
const
params
=
{
contentType
:
'
application/json
'
,
...
newCtx
}
const
response
=
await
getBook
(
params
)
const
books
=
BookTransformer
.
fetch
(
response
)
commit
(
BOOKS_FETCH_SUCCESS
,
books
)
const
{
count
}
=
response
.
data
.
meta
commit
(
BOOKS_FETCH_SUCCESS
,
{
books
,
count
})
}
catch
(
error
)
{
vm
.
$notify
({
message
:
error
,
...
...
@@ -85,8 +88,9 @@ const mutations = {
state
.
isFetching
=
current
state
.
error
=
error
},
[
BOOKS_FETCH_SUCCESS
]
(
state
,
books
)
{
[
BOOKS_FETCH_SUCCESS
]
(
state
,
{
books
,
count
}
)
{
state
.
all
=
books
state
.
count
=
count
state
.
isFetching
=
false
}
}
...
...
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