0
0
Fork 0

Handle params search on mounted

This commit is contained in:
William Buezas 2024-05-22 10:56:37 -03:00
parent f4807d887f
commit 1347e4ec40
1 changed files with 20 additions and 12 deletions

View File

@ -94,19 +94,27 @@ function getNodeIds(node) {
return ids; return ids;
} }
watch(storeData, async (val) => { watch(
// Se triggerea cuando se actualiza el store.data, el cual es el resultado del fetch de la searchbar storeData,
nodes.value[0].children = [...val]; async (val) => {
const fetchedNodeKeys = val.flatMap(getNodeIds); // Se triggerea cuando se actualiza el store.data, el cual es el resultado del fetch de la searchbar
state.set('Tree', [...fetchedNodeKeys]); nodes.value[0].children = [...val];
const tree = state.get('Tree'); const fetchedNodeKeys = val.flatMap(getNodeIds);
for (let n of tree) { state.set('Tree', [...fetchedNodeKeys]);
await fetchNodeLeaves(n); const tree = state.get('Tree');
} for (let n of tree) {
expanded.value = [null, 1, ...fetchedNodeKeys]; await fetchNodeLeaves(n);
}); }
expanded.value = [null, 1, ...fetchedNodeKeys];
},
{ immediate: true }
);
onMounted(async (n) => { onMounted(async () => {
if (store.userParams?.search) {
await arrayData.fetch({ append: false });
return;
}
const tree = [...state.get('Tree'), 1]; const tree = [...state.get('Tree'), 1];
const lastStateTree = state.get('TreeState'); const lastStateTree = state.get('TreeState');
if (tree) { if (tree) {