• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

atinc / ngx-tethys / ebc321d8-d8ed-4ed1-9e59-a5945729a8da

24 Aug 2023 02:49AM UTC coverage: 90.055% (-0.1%) from 90.181%
ebc321d8-d8ed-4ed1-9e59-a5945729a8da

Pull #2771

circleci

web-flow
feat(dropdown): update thyImmediateRender template remove div #INFR-9359 (#2794)

* feat(dropdown): update thyImmediateRender template remove div #INFR-9359

* feat(dropdown): update test

* feat(dropdown): update test

* build: code review

* build: code review
Pull Request #2771: feat: bump angular to 16.x

5104 of 6321 branches covered (80.75%)

Branch coverage included in aggregate %.

144 of 144 new or added lines in 15 files covered. (100.0%)

12897 of 13668 relevant lines covered (94.36%)

977.88 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

84.71
/src/tree/tree-node.class.ts
1
import { helpers, isArray } from 'ngx-tethys/util';
2

3
import { ThyTreeNodeCheckState, ThyTreeNodeData } from './tree.class';
4
import { ThyTreeService } from './tree.service';
5

1,146!
6
export class ThyTreeNode<T = any> {
1,146✔
7
    key?: number | string;
8

×
9
    title?: string;
×
10

11
    children: ThyTreeNode[];
12

×
13
    parentNode: ThyTreeNode;
8,103✔
14

8,103✔
15
    level = 0;
8,103✔
16

8,103✔
17
    origin: ThyTreeNodeData<T>;
8,103✔
18

8,103✔
19
    isExpanded: boolean;
8,103✔
20

8,103✔
21
    isChecked: ThyTreeNodeCheckState;
8,103✔
22

8,103✔
23
    isLoading: boolean;
8,103✔
24

8,103✔
25
    isDisabled: boolean;
7!
26

27
    itemClass?: string[];
8,103✔
28

1,646✔
29
    private readonly service: ThyTreeService;
7,909✔
30

31
    get treeService(): ThyTreeService {
32
        if (this.service) {
8,103✔
33
            return this.service;
8,103✔
34
        } else if (this.parentNode) {
1,007✔
35
            return this.parentNode.treeService;
36
        }
37
    }
38

1✔
39
    constructor(node: ThyTreeNodeData, parent: ThyTreeNode = null, service?: ThyTreeService) {
1✔
40
        this.title = node.title;
41
        this.key = node.key;
42
        this.children = [];
1✔
43
        this.parentNode = parent;
1✔
44
        this.level = parent ? parent.level + 1 : this.level;
45
        this.origin = node;
46
        this.isDisabled = node.disabled || false;
×
47
        this.isExpanded = node.expanded || false;
48
        this.isChecked = node.checked ? ThyTreeNodeCheckState.checked : ThyTreeNodeCheckState.unchecked;
×
49
        this.isLoading = false;
1,161✔
50
        if (node.itemClass) {
1,161✔
51
            this.itemClass = isArray(node.itemClass) ? node.itemClass : [node.itemClass];
1,161✔
52
        }
31✔
53
        if (node.children) {
54
            node.children.forEach(childNode => {
55
                this.children.push(new ThyTreeNode(childNode, this, service));
1,130✔
56
            });
1,132✔
57
        }
1,132✔
58
        this.service = service;
59
        if (node.children && node.children.length && service) {
60
            this.isChecked = service.checkStateResolve(this);
2✔
61
        }
2✔
62
    }
63

19✔
64
    public setKey(key: string) {
10✔
65
        this.origin.key = key;
66
        this.key = key;
67
    }
1✔
68

69
    public setTitle(title: string) {
70
        this.origin.title = title;
×
71
        this.title = title;
72
    }
73

2✔
74
    public setLevel(level: number) {
75
        this.level = level;
1✔
76
    }
1✔
77

1!
78
    private _setExpanded(expanded: boolean, propagate = false) {
10!
79
        this.origin.expanded = expanded;
10✔
80
        this.isExpanded = expanded;
81
        if (propagate && this.children) {
82
            this.children.forEach(n => n._setExpanded(expanded, propagate));
×
83
        }
84
    }
85

10✔
86
    public setExpanded(expanded: boolean, propagate = false) {
1✔
87
        this._setExpanded(expanded, propagate);
1✔
88
        this.treeService.syncFlattenTreeNodes();
89
    }
90

91
    public setLoading(loading: boolean): void {
92
        this.isLoading = loading;
93
        this.treeService.syncFlattenTreeNodes();
94
    }
95

96
    public setChecked(checked: boolean, propagateUp = true, propagateDown = true) {
97
        this.treeService.setNodeChecked(this, checked, propagateUp, propagateDown);
98
    }
99

100
    public syncNodeCheckState() {
101
        this.treeService.syncNodeCheckState(this);
102
    }
103

104
    public getParentNode(): ThyTreeNode {
105
        return this.parentNode;
106
    }
107

108
    public getChildren(): ThyTreeNode[] {
109
        return this.children;
110
    }
111

112
    public addChildren(children: ThyTreeNodeData | ThyTreeNodeData[], index: number = -1): void {
113
        children = helpers.coerceArray(children);
114
        ((children as ThyTreeNodeData[]) || []).forEach((childNode: ThyTreeNodeData, i: number) => {
115
            if (index === -1) {
116
                this.children.push(new ThyTreeNode(childNode, this));
117
            } else {
118
                this.children.splice(index + i, 0, new ThyTreeNode(childNode, this, this.treeService));
119
            }
120
        });
121

122
        this.origin.children = this.getChildren().map(n => n.origin);
123
        this.setLoading(false);
124
        this.treeService.statusChange$.next({
125
            eventName: 'addChildren',
126
            node: this
127
        });
128
    }
129
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc