You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
willaengine/resources/js/Global/utils/common/convertStructureTreeToList.js

20 lines
466 B

export default (data) => {
var arrayList = [];
function recursiveFunction(array) {
for (const iterator of array) {
if (iterator.children && iterator.children.length) {
let clone = Object.assign({}, iterator);
delete clone.children;
arrayList.push(clone);
let list = recursiveFunction(iterator.children);
arrayList.concat(list);
} else {
arrayList.push(iterator);
}
}
return arrayList;
}
return recursiveFunction(data);
};