Skip to content

Commit 25aa946

Browse files
committed
components place along html elements update their name when it is changed
1 parent 63c79f8 commit 25aa946

File tree

1 file changed

+48
-0
lines changed

1 file changed

+48
-0
lines changed

src/store/mutations.js

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -330,6 +330,54 @@ const mutations = {
330330
}
331331
}
332332
}
333+
//
334+
for (const item of Object.values(state.componentMap)) {
335+
if (item.htmlList) {
336+
const newArray = [...item.htmlList];
337+
338+
const changeAllChildComponents = (array, name) => {
339+
const queue = [...array.filter(el => typeof el === 'object')];
340+
while(queue.length) {
341+
const evaluate = queue.shift();
342+
if(evaluate.text === name) {
343+
evaluate.text = payload; 
344+
}
345+
for(let i = 0; i < evaluate.children.length; i++) {
346+
if (evaluate.children[i].text === name) {
347+
evaluate.children[i].text = payload;
348+
}
349+
if (evaluate.children.length) {
350+
queue.push(...evaluate.children)
351+
}
352+
}
353+
}
354+
}
355+
356+
changeAllChildComponents(newArray, temp)
357+
item.htmlList = newArray
358+
}
359+
}
360+
/*
361+
const breadthFirstSearchParent = (array, id) => {
362+
const queue = [...array.filter(el => typeof el === 'object')]
363+
while (queue.length) {
364+
const evaluated = queue.shift()
365+
for (let i = 0; i < evaluated.children.length; i++) {
366+
if (evaluated.children[i].id === id) {
367+
return {
368+
evaluated,
369+
index: i
370+
}
371+
}
372+
if (evaluated.children.length) {
373+
queue.push(...evaluated.children)
374+
}
375+
}
376+
}
377+
}
378+
*/
379+
380+
333381
},
334382

335383
// *** HTML ELEMENTS *** //////////////////////////////////////////////

0 commit comments

Comments
 (0)