Improve node management when using search bar
gitea/salix-front/pipeline/pr-dev This commit looks good
Details
gitea/salix-front/pipeline/pr-dev This commit looks good
Details
This commit is contained in:
parent
990e3f6e75
commit
f4807d887f
|
@ -82,10 +82,28 @@ const onSelected = async (val, node) => {
|
|||
}
|
||||
};
|
||||
|
||||
function getNodeIds(node) {
|
||||
let ids = [];
|
||||
if (node.id) ids.push(node.id);
|
||||
|
||||
if (node.childs) {
|
||||
node.childs.forEach((child) => {
|
||||
ids = ids.concat(getNodeIds(child));
|
||||
});
|
||||
}
|
||||
return ids;
|
||||
}
|
||||
|
||||
watch(storeData, async (val) => {
|
||||
// Se triggerea cuando se actualiza el store.data, el cual es el resultado del fetch de la searchbar
|
||||
nodes.value[0].children = [...val];
|
||||
await fetchNodeLeaves(1);
|
||||
const fetchedNodeKeys = val.flatMap(getNodeIds);
|
||||
state.set('Tree', [...fetchedNodeKeys]);
|
||||
const tree = state.get('Tree');
|
||||
for (let n of tree) {
|
||||
await fetchNodeLeaves(n);
|
||||
}
|
||||
expanded.value = [null, 1, ...fetchedNodeKeys];
|
||||
});
|
||||
|
||||
onMounted(async (n) => {
|
||||
|
|
Loading…
Reference in New Issue