Skip to content
Snippets Groups Projects
Commit 9c368e94 authored by Maximilian Giller's avatar Maximilian Giller :squid:
Browse files

Button to select all nodes of a certain type

parent 8db57fcc
No related branches found
No related tags found
No related merge requests found
Pipeline #56946 failed
...@@ -12,6 +12,7 @@ import { Link } from "../structures/graph/link"; ...@@ -12,6 +12,7 @@ import { Link } from "../structures/graph/link";
import { NodeTypesEditor } from "./nodetypeseditor"; import { NodeTypesEditor } from "./nodetypeseditor";
import { SpaceManager } from "./spacemanager"; import { SpaceManager } from "./spacemanager";
import { SelectLayer } from "./selectlayer"; import { SelectLayer } from "./selectlayer";
import { NodeType } from "../structures/graph/nodetype";
type propTypes = { type propTypes = {
spaceId: string; spaceId: string;
...@@ -100,6 +101,7 @@ export class Editor extends React.PureComponent<propTypes, stateTypes> { ...@@ -100,6 +101,7 @@ export class Editor extends React.PureComponent<propTypes, stateTypes> {
this.selectNode = this.selectNode.bind(this); this.selectNode = this.selectNode.bind(this);
this.handleResize = this.handleResize.bind(this); this.handleResize = this.handleResize.bind(this);
this.handleBoxSelect = this.handleBoxSelect.bind(this); this.handleBoxSelect = this.handleBoxSelect.bind(this);
this.handleNodeTypeSelect = this.handleNodeTypeSelect.bind(this);
this.renderer = React.createRef(); this.renderer = React.createRef();
this.graphContainer = React.createRef(); this.graphContainer = React.createRef();
...@@ -598,6 +600,13 @@ export class Editor extends React.PureComponent<propTypes, stateTypes> { ...@@ -598,6 +600,13 @@ export class Editor extends React.PureComponent<propTypes, stateTypes> {
return undefined; return undefined;
} }
private handleNodeTypeSelect(type: NodeType) {
const nodesWithType = this.state.graph.nodes.filter((n: Node) =>
n.type.equals(type)
);
this.selectNodes(nodesWithType);
}
private handleNodeDrag(node: Node) { private handleNodeDrag(node: Node) {
this.graphInFocus = true; this.graphInFocus = true;
...@@ -735,6 +744,7 @@ export class Editor extends React.PureComponent<propTypes, stateTypes> { ...@@ -735,6 +744,7 @@ export class Editor extends React.PureComponent<propTypes, stateTypes> {
<NodeTypesEditor <NodeTypesEditor
onChange={this.forceUpdate} onChange={this.forceUpdate}
graph={this.state.graph} graph={this.state.graph}
onSelectAll={this.handleNodeTypeSelect}
/> />
<hr /> <hr />
<h3>Settings</h3> <h3>Settings</h3>
......
...@@ -8,6 +8,7 @@ type propTypes = { ...@@ -8,6 +8,7 @@ type propTypes = {
graph: Graph; graph: Graph;
type: NodeType; type: NodeType;
onChange: { (): void }; onChange: { (): void };
onSelectAll: (type: NodeType) => void;
}; };
type stateTypes = { type stateTypes = {
temporaryColor: string; temporaryColor: string;
...@@ -82,7 +83,6 @@ export class NodeTypeEntry extends React.Component<propTypes, stateTypes> { ...@@ -82,7 +83,6 @@ export class NodeTypeEntry extends React.Component<propTypes, stateTypes> {
return; return;
} }
//TODO: Make sure, that this event is not triggered to quickly!
(this.props.type as any)[property] = newValue; (this.props.type as any)[property] = newValue;
this.props.onChange(); this.props.onChange();
...@@ -139,6 +139,9 @@ export class NodeTypeEntry extends React.Component<propTypes, stateTypes> { ...@@ -139,6 +139,9 @@ export class NodeTypeEntry extends React.Component<propTypes, stateTypes> {
} }
onChange={(event) => this.handleColorChange(event)} onChange={(event) => this.handleColorChange(event)}
/> />
<button onClick={() => this.props.onSelectAll(this.props.type)}>
Select nodes
</button>
{this.props.graph && this.props.graph.types.length > 1 ? ( {this.props.graph && this.props.graph.types.length > 1 ? (
<button onClick={this.deleteType}>Delete</button> <button onClick={this.deleteType}>Delete</button>
) : ( ) : (
......
...@@ -8,6 +8,7 @@ import { NodeType } from "../structures/graph/nodetype"; ...@@ -8,6 +8,7 @@ import { NodeType } from "../structures/graph/nodetype";
type propTypes = { type propTypes = {
graph: Graph; graph: Graph;
onChange: { (): void }; onChange: { (): void };
onSelectAll: (type: NodeType) => void;
}; };
export class NodeTypesEditor extends React.Component<propTypes> { export class NodeTypesEditor extends React.Component<propTypes> {
...@@ -35,6 +36,7 @@ export class NodeTypesEditor extends React.Component<propTypes> { ...@@ -35,6 +36,7 @@ export class NodeTypesEditor extends React.Component<propTypes> {
key={type.id} key={type.id}
type={type} type={type}
graph={this.props.graph} graph={this.props.graph}
onSelectAll={this.props.onSelectAll}
/> />
))} ))}
</ul> </ul>
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment