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

atinc / ngx-tethys / d9ae709b-3c27-4b69-b125-b8b80b54f90b

pending completion
d9ae709b-3c27-4b69-b125-b8b80b54f90b

Pull #2757

circleci

mengshuicmq
fix: fix code review
Pull Request #2757: feat(color-picker): color-picker support disabled (#INFR-8645)

98 of 6315 branches covered (1.55%)

Branch coverage included in aggregate %.

1 of 1 new or added line in 1 file covered. (100.0%)

2392 of 13661 relevant lines covered (17.51%)

83.12 hits per line

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

0.0
/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

×
6
export class ThyTreeNode<T = any> {
×
7
    key?: number | string;
8

×
9
    title?: string;
×
10

11
    children: ThyTreeNode[];
12

×
13
    parentNode: ThyTreeNode;
×
14

×
15
    level = 0;
×
16

×
17
    origin: ThyTreeNodeData<T>;
×
18

×
19
    isExpanded: boolean;
×
20

×
21
    isChecked: ThyTreeNodeCheckState;
×
22

×
23
    isLoading: boolean;
×
24

×
25
    isDisabled: boolean;
×
26

27
    itemClass?: string[];
×
28

×
29
    private readonly service: ThyTreeService;
×
30

31
    get treeService(): ThyTreeService {
32
        if (this.service) {
×
33
            return this.service;
×
34
        } else if (this.parentNode) {
×
35
            return this.parentNode.treeService;
36
        }
37
    }
38

×
39
    constructor(node: ThyTreeNodeData, parent: ThyTreeNode = null, service?: ThyTreeService) {
×
40
        this.title = node.title;
41
        this.key = node.key;
42
        this.children = [];
×
43
        this.parentNode = parent;
×
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;
×
50
        if (node.itemClass) {
51
            this.itemClass = isArray(node.itemClass) ? node.itemClass : [node.itemClass];
52
        }
×
53
        if (node.children) {
×
54
            node.children.forEach(childNode => {
×
55
                this.children.push(new ThyTreeNode(childNode, this, service));
56
            });
57
        }
×
58
        this.service = service;
×
59
        if (node.children && node.children.length && service) {
60
            this.isChecked = service.checkStateResolve(this);
×
61
        }
×
62
    }
63

64
    public setKey(key: string) {
×
65
        this.origin.key = key;
66
        this.key = key;
67
    }
×
68

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

×
74
    private _setExpanded(expanded: boolean, propagate = false) {
×
75
        this.origin.expanded = expanded;
×
76
        this.isExpanded = expanded;
×
77
        if (propagate && this.children) {
78
            this.children.forEach(n => n._setExpanded(expanded, propagate));
79
        }
×
80
    }
81

82
    public setExpanded(expanded: boolean, propagate = false) {
×
83
        this._setExpanded(expanded, propagate);
×
84
        this.treeService.syncFlattenTreeNodes();
×
85
    }
86

87
    public setLoading(loading: boolean): void {
88
        this.isLoading = loading;
89
        this.treeService.syncFlattenTreeNodes();
90
    }
91

92
    public setChecked(checked: boolean, propagateUp = true, propagateDown = true) {
93
        this.treeService.setNodeChecked(this, checked, propagateUp, propagateDown);
94
    }
95

96
    public syncNodeCheckState() {
97
        this.treeService.syncNodeCheckState(this);
98
    }
99

100
    public getParentNode(): ThyTreeNode {
101
        return this.parentNode;
102
    }
103

104
    public getChildren(): ThyTreeNode[] {
105
        return this.children;
106
    }
107

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

118
        this.origin.children = this.getChildren().map(n => n.origin);
119
        this.setLoading(false);
120
        this.treeService.$statusChange.next({
121
            eventName: 'addChildren',
122
            node: this
123
        });
124
    }
125
}
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