forked from retejs/angular-plugin
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathnode.component.ts
More file actions
executable file
·39 lines (32 loc) · 1.09 KB
/
Copy pathnode.component.ts
File metadata and controls
executable file
·39 lines (32 loc) · 1.09 KB
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
import { Component, Input, ChangeDetectionStrategy, ChangeDetectorRef } from '@angular/core';
import { NodeEditor, Node, Input as ReteInput, Output as ReteOutput, Control as ReteControl } from 'rete';
import { NodeService } from '../node.service';
@Component({
templateUrl: './node.component.html',
styleUrls: ['./node.component.sass'],
providers: [NodeService],
changeDetection: ChangeDetectionStrategy.OnPush
})
export class NodeComponent {
@Input() editor!: NodeEditor;
@Input() node!: Node;
@Input() bindSocket!: Function;
@Input() bindControl!: Function;
constructor(protected service: NodeService, protected cdr: ChangeDetectorRef) {}
ngOnInit() {
this.service.setBindings(this.bindSocket, this.bindControl);
this.node.update = () => this.cdr.detectChanges();
}
get inputs() {
return Array.from(this.node.inputs.values());
}
get outputs() {
return Array.from(this.node.outputs.values());
}
get controls() {
return Array.from(this.node.controls.values());
}
selected() {
return this.editor.selected.contains(this.node) ? 'selected' : '';
}
}