history is functionnal and with state transition

This commit is contained in:
2019-09-25 16:08:58 +02:00
parent 1957aa3dc5
commit b272bca0ca
12 changed files with 279 additions and 86 deletions
+3 -1
View File
@@ -3,11 +3,13 @@ import Vuex from 'vuex'
import Corpus from './modules/corpus'
import Search from './modules/search'
import History from './modules/history'
Vue.use(Vuex)
export default new Vuex.Store({
modules: {
Corpus,
Search
Search,
History
}
})
+46
View File
@@ -0,0 +1,46 @@
// import { REST } from 'api/rest-axios'
import router from '../../router'
export default {
namespaced: true,
router,
// initial state
state: {
items: [],
opened: false
},
// getters
getters: {},
// mutations
mutations: {
addItem (state, item) {
state.items.push(item)
},
setOpened (state, opened) {
state.opened = opened
}
},
// actions
actions: {
addItem ({ dispatch, commit, state }, item) {
console.log('history add item', item, router)
commit('addItem', item)
commit('setOpened', true)
router.push({
name: `item`,
params: { uuid: item.uuid }
})
},
navigateToItem ({ dispatch, commit, state }, item) {
console.log('history navigate to item', item, router)
// commit('addItem', item)
router.push({
name: `item`,
params: { uuid: item.uuid }
})
}
}
}