MCPcopy Create free account
hub / github.com/DHTMLX/gantt / children

Method children

scripts/backend/storage_tree.js:3–26  ·  view source on GitHub ↗
(parentId = 0)

Source from the content-addressed store, hash-verified

1var Storage = require("./storage");
2class StorageTree extends Storage{
3 children(parentId = 0) {
4 var all = this._data.data;
5
6 var loaded = this._data.data.filter(function(entry) {
7 return parentId == entry.parent;
8 });
9
10 var search = {};
11 loaded.forEach(function(value){
12 search[value.id] = value;
13 });
14
15 all.forEach(function(task){
16 if(search[task.parent]) {
17 search[task.parent]["$has_child"] = true;
18 }
19 });
20
21 var links = this._data.links.filter(function(entry) {
22 return (search[entry.source] || search[entry.target]);
23 });
24
25 return {data: loaded, links: links};
26 }
27}
28
29module.exports = StorageTree;

Callers 1

getDataMethod · 0.80

Calls 1

filterMethod · 0.65

Tested by

no test coverage detected