perspectives WIP

This commit is contained in:
Jan Prochazka
2022-06-23 16:50:56 +02:00
parent aca92f3889
commit b6b75f0743
3 changed files with 39 additions and 4 deletions

View File

@@ -1,7 +1,11 @@
import { PerspectiveTableNode, PerspectiveTreeNode } from './PerspectiveTreeNode';
export class PerspectiveDisplayColumn {
constructor(public label: string, public field: string) {}
subColumns: PerspectiveDisplayColumn[] = [];
title: string;
dataField: string;
constructor() {}
}
export class PerspectiveDisplay {
@@ -9,10 +13,25 @@ export class PerspectiveDisplay {
constructor(public root: PerspectiveTreeNode, public rows: any[]) {
const children = root.childNodes;
this.fillChildren(root.childNodes, this.columns);
}
fillChildren(children: PerspectiveTreeNode[], columns: PerspectiveDisplayColumn[]) {
for (const child of children) {
if (child.isChecked) {
this.columns.push(new PerspectiveDisplayColumn(child.title, child.codeName));
const childColumn = this.nodeToColumn(child);
columns.push(childColumn);
}
}
}
nodeToColumn(node: PerspectiveTreeNode) {
const res = new PerspectiveDisplayColumn();
res.title = node.columnTitle;
res.dataField = node.dataField;
if (node.isExpandable) {
this.fillChildren(node.childNodes, res.subColumns);
}
return res;
}
}