From 8af8bbc73f77944bb8e2753feba8663dc32a1b92 Mon Sep 17 00:00:00 2001 From: axolotle Date: Wed, 30 Jun 2021 21:09:02 +0200 Subject: [PATCH] add history --- src/App.vue | 6 +- .../scss/base/_bootstrap-overrides.scss | 8 + src/components/nodes/NodeViewFooter.vue | 2 +- src/messages/fr.json | 1 + src/pages/_partials/NodesHistory.vue | 228 ++++++++++++++++++ src/store/modules/library.js | 5 +- src/store/nodes.js | 11 +- 7 files changed, 257 insertions(+), 4 deletions(-) create mode 100644 src/pages/_partials/NodesHistory.vue diff --git a/src/App.vue b/src/App.vue index ec6b6a8..8df30b8 100644 --- a/src/App.vue +++ b/src/App.vue @@ -5,18 +5,22 @@
+ + + + diff --git a/src/store/modules/library.js b/src/store/modules/library.js index e45f2e7..597eeaa 100644 --- a/src/store/modules/library.js +++ b/src/store/modules/library.js @@ -134,8 +134,10 @@ export default { async 'UPDATE_NODEBOOK' ({ state, commit, dispatch }, query) { const { mode = 'tree', nodebook } = parseNodesQueryParams(query) commit('SET_MODE', mode) - await dispatch('GET_NODES', { ids: [].concat(...nodebook), dataLevel: 'full' }) + const ids = [].concat(...nodebook) + await dispatch('GET_NODES', { ids, dataLevel: 'full' }) commit('SET_NODEBOOK', nodebook) + commit('ADD_HISTORY_ENTRIES', ids) }, // ╭╮╷╭─╮┌─╮┌─╴╭─╴ @@ -157,6 +159,7 @@ export default { const stack = state.nodebook.find(stack => stack[0] === parentId) commit('ADD_NODEBOOK_NODE', [stack, parentId, childId]) dispatch('UPDATE_QUERY_NODES') + commit('ADD_HISTORY_ENTRIES', [childId || parentId]) }, 'CLOSE_NODE' ({ state, commit, dispatch }, { parentId, childId }) { diff --git a/src/store/nodes.js b/src/store/nodes.js index 1880ce5..5da5495 100644 --- a/src/store/nodes.js +++ b/src/store/nodes.js @@ -84,6 +84,14 @@ export default { } }, + 'ADD_HISTORY_ENTRIES' (state, ids) { + for (const id of ids) { + if (!state.history.includes(id)) { + state.history.push(id) + } + } + }, + 'UPDATE_OPTIONS_VISIBILITY' (state, visible) { state.optionsVisible = visible } @@ -144,6 +152,7 @@ export default { // Args getters nodes: state => ids => ids.map(id => state.nodes[id]), node: state => id => state.nodes[id], - optionsVisible: state => state.optionsVisible + optionsVisible: state => state.optionsVisible, + history: state => state.history.map(id => state.nodes[id]) } }