Commit 853f5a20 authored by Mycha de Vrees's avatar Mycha de Vrees
Browse files

fix pagination after provider fetch

parent 96f6e49a
Pipeline #330 passed with stage
in 1 minute and 34 seconds
......@@ -30,7 +30,7 @@
:filter="genresFilter"
:current-page="currentPage"
:per-page="perPage"
:sort-by.sync="sort"
:sort-by.sync="sortBy"
:sort-desc.sync="sortDesc"
@filtered="onFiltered"
>
......@@ -99,16 +99,15 @@ export default {
this.isBusy = true
await this.fetchGenres({ctx, vm: this})
// await this.$store.dispatch('fetchGenres', {ctx, vm: this})
this.isBusy = false
this.totalRows = this.$store.state.genre.count
return this.$store.state.genre.all
}
},
computed: {
genreRows: {
get () {
return this.genreItems.length
return this.$store.state.genre.count
},
set (newVal) {
this.totalRows = newVal
......
......@@ -32,7 +32,8 @@ const getters = {
* @returns {{all: {}, isFetching: boolean, error: string }}
*/
const getDefaultState = () => ({
all: {},
all: [],
count: 0,
isFetching: false,
error: null
})
......@@ -63,7 +64,8 @@ const actions = {
const params = { contentType: 'application/json', ...newCtx }
const response = await getGenre(params)
const genres = GenreTransformer.fetch(response)
commit(GENRES_FETCH_SUCCESS, genres)
const { count } = response.data.meta
commit(GENRES_FETCH_SUCCESS, { genres, count })
} catch (error) {
vm.$notify({
message: error,
......@@ -86,8 +88,9 @@ const mutations = {
state.isFetching = current
state.error = error
},
[GENRES_FETCH_SUCCESS] (state, genres) {
[GENRES_FETCH_SUCCESS] (state, { genres, count }) {
state.all = genres
state.count = count
state.isFetching = false
}
}
......
......@@ -10,7 +10,6 @@ class CtxTransformer extends Transformer {
* @returns {object}
*/
static transformCtx (ctx) {
console.log(ctx)
return {
...ctx,
pageOffset: (ctx.currentPage - 1) * 10,
......
......@@ -18,6 +18,7 @@ class GenreTransformer extends Transformer {
}
genres.push(obj)
})
return genres
}
}
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment