Explorar el Código

:sparkles: address #74 | added get single page action

tags/0.9.0
J hace 4 años
padre
commit
e79f7484f1
Se han modificado 1 ficheros con 15 adiciones y 0 borrados
  1. 15
    0
      vue-theme/src/store/modules/page.js

+ 15
- 0
vue-theme/src/store/modules/page.js Ver fichero

@@ -4,6 +4,7 @@ import api from '../../utils/api'
4 4
 const state = {
5 5
     all: [],
6 6
     loaded: false,
7
+    singlePage: null
7 8
 }
8 9
 
9 10
 // getters
@@ -21,6 +22,14 @@ const actions = {
21 22
             commit('PAGES_LOADED', true)
22 23
         })
23 24
     },
25
+    getSinglePage({ commit }, id) {
26
+        commit('CLEAR_SINGLE_PAGE')
27
+        commit('PAGES_LOADED', false)
28
+        api.getSingleType('pages', id, page => {
29
+            commit('STORE_FETCHED_SINGLE_PAGE', page)
30
+            commit('PAGES_LOADED', true)
31
+        })
32
+    },
24 33
 }
25 34
 
26 35
 // mutations
@@ -28,9 +37,15 @@ const mutations = {
28 37
     STORE_FETCHED_PAGES(state, { pages }) {
29 38
         state.all = pages
30 39
     },
40
+    STORE_FETCHED_SINGLE_PAGE(state, page) {
41
+        state.singlePage = page
42
+    },
31 43
     CLEAR_PAGES(state) {
32 44
         state.all = []
33 45
     },
46
+    CLEAR_SINGLE_PAGE(state) {
47
+        state.singlePage = null
48
+    },
34 49
     PAGES_LOADED(state, val) {
35 50
         state.loaded = val
36 51
     },

Loading…
Cancelar
Guardar