mirror of
https://github.com/DeNNiiInc/dbgate.git
synced 2026-04-19 03:45:59 +00:00
perspectives WIP
This commit is contained in:
@@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -53,6 +53,9 @@ export abstract class PerspectiveTreeNode {
|
||||
get fieldName() {
|
||||
return this.codeName;
|
||||
}
|
||||
get dataField() {
|
||||
return this.codeName;
|
||||
}
|
||||
abstract getNodeLoadProps(parentRows: any[]): PerspectiveDataLoadProps;
|
||||
get isRoot() {
|
||||
return this.parentNode == null;
|
||||
@@ -75,6 +78,9 @@ export abstract class PerspectiveTreeNode {
|
||||
get isChecked() {
|
||||
return this.config.checkedColumns.includes(this.uniqueName);
|
||||
}
|
||||
get columnTitle() {
|
||||
return this.title;
|
||||
}
|
||||
|
||||
toggleExpanded(value?: boolean) {
|
||||
this.includeInColumnSet('expandedColumns', this.uniqueName, value == null ? !this.isExpanded : value);
|
||||
@@ -233,6 +239,10 @@ export class PerspectiveTableReferenceNode extends PerspectiveTableNode {
|
||||
dataColumns: null,
|
||||
};
|
||||
}
|
||||
|
||||
get columnTitle() {
|
||||
return this.table.pureName;
|
||||
}
|
||||
}
|
||||
|
||||
export function getTableChildPerspectiveNodes(
|
||||
|
||||
Reference in New Issue
Block a user