Moved static GetDepth to getDepth class method
This commit is contained in:
parent
8792c8bee5
commit
be00496581
2 changed files with 13 additions and 13 deletions
|
@ -29,7 +29,7 @@ export class ElementsSidebar extends React.Component<IElementsSidebarProps> {
|
||||||
|
|
||||||
const containerRows: React.ReactNode[] = [];
|
const containerRows: React.ReactNode[] = [];
|
||||||
this.iterateChilds((container: Container) => {
|
this.iterateChilds((container: Container) => {
|
||||||
const depth: number = Container.getDepth(container);
|
const depth: number = container.getDepth();
|
||||||
const key = container.props.properties.id.toString();
|
const key = container.props.properties.id.toString();
|
||||||
const text = '|\t'.repeat(depth) + key;
|
const text = '|\t'.repeat(depth) + key;
|
||||||
const selectedClass: string = this.props.SelectedContainer !== null &&
|
const selectedClass: string = this.props.SelectedContainer !== null &&
|
||||||
|
|
|
@ -40,6 +40,18 @@ export class Container extends React.Component<IContainerProps> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public getDepth() {
|
||||||
|
let depth = 0;
|
||||||
|
|
||||||
|
let current: Container | null = this.props.parent;
|
||||||
|
while (current != null) {
|
||||||
|
depth++;
|
||||||
|
current = current.props.parent;
|
||||||
|
}
|
||||||
|
|
||||||
|
return depth;
|
||||||
|
}
|
||||||
|
|
||||||
public render(): React.ReactNode {
|
public render(): React.ReactNode {
|
||||||
const containersElements = this.props.children.map(child => child.render());
|
const containersElements = this.props.children.map(child => child.render());
|
||||||
const defaultStyle = {
|
const defaultStyle = {
|
||||||
|
@ -69,16 +81,4 @@ export class Container extends React.Component<IContainerProps> {
|
||||||
</g>
|
</g>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static getDepth(container: Container): number {
|
|
||||||
let depth = 0;
|
|
||||||
|
|
||||||
let current: Container | null = container.props.parent;
|
|
||||||
while (current != null) {
|
|
||||||
depth++;
|
|
||||||
current = current.props.parent;
|
|
||||||
}
|
|
||||||
|
|
||||||
return depth;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue