blob: 1ce0e81008d38937b93c7a6bf26e3087c7782d1e (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
|
import {Component, ViewChild} from '@angular/core';
import {DrawingBoardTreeComponent} from "../drawing-board-tree/drawing-board-tree.component";
import {AvailableModelsTreeComponent} from "../available-models-tree/available-models-tree.component";
import {ITreeNode} from "angular-tree-component/dist/defs/api";
import {TreeComponent} from 'angular-tree-component';
@Component({
selector: 'service-planning',
templateUrl: './service-planning.component.html',
styleUrls: ['./service-planning.component.scss']
})
export class ServicePlanningComponent {
@ViewChild(DrawingBoardTreeComponent) drawingModelTree;
@ViewChild(AvailableModelsTreeComponent) availableModelTree;
isShowTree(): boolean {
return true;
}
public highlightNodeBySelectingInstance(modelId: number): void {
this.availableModelTree.tree.treeModel.getNodeBy((node: ITreeNode) => node.data.id === modelId)
.setActiveAndVisible().expand();
}
public highlightInstancesBySelectingNode(id: number): void {
if(this.isShowTree()) {
let _this = this;
let matchInstances = _this.searchTree(id);
if (!matchInstances.length)
_this.clearSelectionInTree(_this.drawingModelTree.tree);
matchInstances.forEach(function (instance, index) {
let multi : boolean = !!index;
_this.drawingModelTree.tree.treeModel.getNodeById(instance.id)
.setActiveAndVisible(multi).expand();
});
}
}
clearSelectionInTree(tree: TreeComponent): void {
let activateNode = tree.treeModel.getActiveNode();
activateNode ? activateNode.toggleActivated().blur() : null;
}
searchTree(modelId: number) {
let _this = this;
let results = [];
let nodes = _this.drawingModelTree.nodes;
nodes.forEach(function (node) {
_this.searchTreeNode(node, modelId, results);
});
return results;
}
searchTreeNode(node, modelId: number, results): void {
if(node.modelId === modelId){
results.push(node);
}
if (node.children != null){
for(let i = 0; i < node.children.length; i++){
this.searchTreeNode(node.children[i], modelId, results);
}
}
}
}
export class ServicePlanningEmptyComponent extends ServicePlanningComponent {
isShowTree() : boolean {
return false;
}
}
|