make node-views emit instead of calling the store

This commit is contained in:
axolotle
2021-06-10 17:51:28 +02:00
parent 346a3ffdfe
commit 95d4b6f66f
6 changed files with 16 additions and 9 deletions
+3 -2
View File
@@ -191,11 +191,12 @@ export default {
// BASIC HANDLERS
onNodeClick (nodeData) {
// FIXME CURRENT PROBLEM AS API TREATING TEXTPRODs as TEXTREFs (no `parents:`)
const { id, parents } = nodeData
if (parents) {
this.$emit('open', parents[0].id, id)
this.$emit('open-node', parents[0].id, id)
} else {
this.$emit('open', id)
this.$emit('open-node', id)
}
}
},
+2 -2
View File
@@ -36,12 +36,12 @@ export default {
},
computed: {
...mapGetters(['activeNodes']),
...mapGetters(['activeNodes'])
},
methods: {
onOpen (childId) {
this.$store.dispatch('OPEN_NODE', [this.parentId, childId])
this.$emit('open-child', childId)
}
},
+2 -2
View File
@@ -71,8 +71,8 @@ export default {
methods: {
toCommaList,
onOpen (nodeId) {
this.$store.dispatch('OPEN_NODE', [nodeId])
onOpen (siblingId) {
this.$parent.$emit('open-node', siblingId)
}
}
}
+1 -1
View File
@@ -42,7 +42,7 @@ export default {
toCommaList,
onClose () {
this.$store.dispatch('CLOSE_NODE', this.node.id)
this.$parent.$emit('close-node', this.node.id)
}
}
}
+7 -2
View File
@@ -14,7 +14,12 @@
</div>
</h4>
<node-view-child-list v-if="mode === 'view'" :children="node.children" :parent-id="node.id" />
<node-view-child-list
v-if="mode === 'view'"
:children="node.children"
:parent-id="node.id"
@open-child="$parent.$emit('open-child', $event)"
/>
<button-close v-if="mode === 'view'" @click="onClose()" />
</div>
</div>
@@ -42,7 +47,7 @@ export default {
toCommaList,
onClose () {
this.$store.dispatch('CLOSE_NODE', this.node.id)
this.$parent.$emit('close-node', this.node.id)
}
}
}