Return also labels from <dougal-context-menu/>.

Keeping in mind that the input model is a tree and labels
may be at any level in the tree, not just in the leaves.
This commit is contained in:
D. Berge
2022-02-27 18:53:54 +01:00
parent 0c91e40817
commit 0be5dba2b9

View File

@@ -21,6 +21,7 @@
<dougal-context-menu v-if="item.items"
:value="showSubmenu"
:items="item.items"
:labels="labels.concat(item.labels||[])"
@input="selected"
submenu>
<template v-slot:activator="{ on, attrs }">
@@ -56,6 +57,7 @@ export default {
props: {
value: { type: [ MouseEvent, Object, Boolean ] },
labels: { type: [ Array ], default: () => [] },
absolute: { type: Boolean, default: false },
submenu: { type: Boolean, default: false },
items: { type: Array, default: () => [] }
@@ -97,7 +99,12 @@ export default {
selected (item) {
this.show = false;
this.$emit('input', item);
if (typeof item === 'object' && item !== null) {
const labels = this.labels.concat(item.labels??[]);
this.$emit('input', {...item, labels});
} else {
this.$emit('input', item);
}
}
}