Commit abd9e622515d6c5ef8e6787411261762e53bd31d
1 parent
4a21fd39
parse api element to client element model
Showing
1 changed file
with
6 additions
and
2 deletions
front-end/h5/src/store/modules/work.js
| 1 | 1 | // import Work from '../../components/core/models/work' |
| 2 | +import Element from '../../components/core/models/element' | |
| 2 | 3 | import strapi from '../../utils/strapi' |
| 3 | 4 | |
| 4 | 5 | export const actions = { |
| ... | ... | @@ -30,8 +31,11 @@ export const actions = { |
| 30 | 31 | |
| 31 | 32 | // mutations |
| 32 | 33 | export const mutations = { |
| 33 | - setWork (state, payload) { | |
| 34 | - state.work = payload | |
| 34 | + setWork (state, work) { | |
| 35 | + work.pages.forEach(page => { | |
| 36 | + page.elements = page.elements.map(element => new Element(element)) | |
| 37 | + }) | |
| 38 | + state.work = work | |
| 35 | 39 | }, |
| 36 | 40 | // createWork (state) { |
| 37 | 41 | // state.work = new Work() | ... | ... |