// searchData(){
// let defaultMeshData = this.dataServ.getModelObjectData();
// let filterData = []
// // if(defaultMeshData.length>0){
// // defaultMeshData.forEach(mesh => {
// // if(mesh.children.length>0){
// // this.getSearchChildren(mesh)
// // }
// // });
// // }
// // this.meshObject = this.dataServ.getModelObjectData().filter(p => (p.isParentKnowledgeSkills).map(p => ({
// // ...p,
// // subCategories: this.getSearchChildren(p)
// // })));
// let result = defaultMeshData.reduce((a/*Accumulator*/, o/*Current object in array*/) => {
// // 1. We get the events with a specific category (In this case -> 3)
// var filtered = o.children.filter((children) => (children.name).toLowerCase().indexOf(this.searchInput.toLowerCase()) > -1);
// // 2. If the previous filter returns at least one event, we need to push
// // the current object 'o' with the filtered events.
// if (filtered.length) { // if length !== 0 we need to push the object.
// // 3. We use Object.assign to avoid any mutation over the original object.
// // So, basically we create a new object with the original properties
// // and finally we assign the filtered events to the property events.
// a.push(Object.assign({}, o, {children: filtered}));
// }
// return a;
// }, []/*Initial value (this array will contain the filtered objects)*/);
// console.log(result)
// }
// getSearchChildren(mesh){
// // if(mesh.children.length>0){
// // return mesh.children = mesh.children.filter(children => (children.name).toLowerCase().indexOf(this.searchInput.toLowerCase()) > -1)
// // }
// let result = mesh.reduce((a/*Accumulator*/, o/*Current object in array*/) => {
// // 1. We get the events with a specific category (In this case -> 3)
// var filtered = o.children.filter((children) => (children.name).toLowerCase().indexOf(this.searchInput.toLowerCase()) > -1);
// // 2. If the previous filter returns at least one event, we need to push
// // the current object 'o' with the filtered events.
// if (filtered.length) { // if length !== 0 we need to push the object.
// // 3. We use Object.assign to avoid any mutation over the original object.
// // So, basically we create a new object with the original properties
// // and finally we assign the filtered events to the property events.
// a.push(Object.assign({}, o, {children: filtered}));
// }
// return a;
// }, []/*Initial value (this array will contain the filtered objects)*/);
// return result;
// }
// getSearchChildren(mesh){
// if(mesh.length>0){
// let result = mesh.reduce((a/*Accumulator*/, o/*Current object in array*/) => {
// // 1. We get the events with a specific category (In this case -> 3)
// var filtered = o.children.filter((children) => (children.name).toLowerCase().indexOf(this.searchInput.toLowerCase()) > -1).map(child=> ({...child, children:this.getSearchChildren(child.children)}));
// if (filtered.length) { // if length !== 0 we need to push the object.
// a.push(Object.assign({}, o, {children: filtered}));
// }
// return a;
// }, []/*Initial value (this array will contain the filtered objects)*/);
// return result;
// }else{
// return mesh;
// }
// }
// searchData(){
// // this.meshObject = this.dataServ.getModelObjectData().filter(p => (p.isParentKnowledgeSkills).map(p => ({
// // ...p,
// // subCategories: this.getSearchChildren(p)
// // })));
// let result =[];
// let defaultMeshData = this.dataServ.getModelObjectData();
// if(this.searchInput==''){
// result = defaultMeshData
// }else{
// result = defaultMeshData.reduce((a/*Accumulator*/, o/*Current object in array*/) => {
// // var filtered = o.children.filter((children) => (children.name).toLowerCase().indexOf(this.searchInput.toLowerCase()) > -1).map(child=> ({...child, children:this.getSearchChildren(child)}));
// var filtered = o.children.map(child=> ({...child, children:this.getSearchChildren(child.children)}));
// if (filtered.length) {
// a.push(Object.assign({}, o, {children: filtered}));
// }
// return a;
// }, []/*Initial value (this array will contain the filtered objects)*/);
// console.log(result);
// }
// this.meshObject = result;
// }
/**
* Dynamic filter child list data filter and return data
*/
getSearchChildren(mesh) {
var result = [];
mesh.children.forEach(child => {
if (child.name.toLowerCase().indexOf(this.searchInput.toLowerCase()) > -1) {
result.push(child);
} else {
if (child.hasChildren && mesh['children'] && mesh['children'].length > 0) {
// child list filter
child['children'] = this.getSearchChildren(child);
if (child['children'] && child['children'].length > 0) {
result.push(child);
}
}
}
});
return result;
}
/***
* Search mesh parent list and call child list
*/
searchData() {
var defaultMeshData = JSON.parse(JSON.stringify(this.dataServ.getModelObjectData()));
let result = [];
this.expand = true;
if (this.searchInput == '') {
result = defaultMeshData;
this.expand = false;
} else {
defaultMeshData = JSON.parse(JSON.stringify(defaultMeshData.filter(e => e.parent == "")));
defaultMeshData.forEach(mesh => {
if (mesh.name.toLowerCase().indexOf(this.searchInput.toLowerCase()) > -1) {
result.push(mesh);
} else {
if (mesh.hasChildren && mesh['children'] && mesh['children'].length > 0) {
// child list filter
mesh['children'] = this.getSearchChildren(mesh);
if (mesh['children'] && mesh['children'].length > 0) {
result.push(mesh);
}
}
}
});
}
this.meshObject = result;
}
/**
* Search clear list data
*/
searchClear() {
this.expand = false;
this.searchInput = '';
this.meshObject = JSON.parse(JSON.stringify(this.dataServ.getModelObjectData()));
}