mirror of
https://github.com/DeNNiiInc/dbgate.git
synced 2026-04-27 11:25:59 +00:00
perspectives WIP
This commit is contained in:
@@ -1,7 +1,11 @@
|
|||||||
import { PerspectiveTableNode, PerspectiveTreeNode } from './PerspectiveTreeNode';
|
import { PerspectiveTableNode, PerspectiveTreeNode } from './PerspectiveTreeNode';
|
||||||
|
|
||||||
export class PerspectiveDisplayColumn {
|
export class PerspectiveDisplayColumn {
|
||||||
constructor(public label: string, public field: string) {}
|
subColumns: PerspectiveDisplayColumn[] = [];
|
||||||
|
title: string;
|
||||||
|
dataField: string;
|
||||||
|
|
||||||
|
constructor() {}
|
||||||
}
|
}
|
||||||
|
|
||||||
export class PerspectiveDisplay {
|
export class PerspectiveDisplay {
|
||||||
@@ -9,10 +13,25 @@ export class PerspectiveDisplay {
|
|||||||
|
|
||||||
constructor(public root: PerspectiveTreeNode, public rows: any[]) {
|
constructor(public root: PerspectiveTreeNode, public rows: any[]) {
|
||||||
const children = root.childNodes;
|
const children = root.childNodes;
|
||||||
|
this.fillChildren(root.childNodes, this.columns);
|
||||||
|
}
|
||||||
|
|
||||||
|
fillChildren(children: PerspectiveTreeNode[], columns: PerspectiveDisplayColumn[]) {
|
||||||
for (const child of children) {
|
for (const child of children) {
|
||||||
if (child.isChecked) {
|
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() {
|
get fieldName() {
|
||||||
return this.codeName;
|
return this.codeName;
|
||||||
}
|
}
|
||||||
|
get dataField() {
|
||||||
|
return this.codeName;
|
||||||
|
}
|
||||||
abstract getNodeLoadProps(parentRows: any[]): PerspectiveDataLoadProps;
|
abstract getNodeLoadProps(parentRows: any[]): PerspectiveDataLoadProps;
|
||||||
get isRoot() {
|
get isRoot() {
|
||||||
return this.parentNode == null;
|
return this.parentNode == null;
|
||||||
@@ -75,6 +78,9 @@ export abstract class PerspectiveTreeNode {
|
|||||||
get isChecked() {
|
get isChecked() {
|
||||||
return this.config.checkedColumns.includes(this.uniqueName);
|
return this.config.checkedColumns.includes(this.uniqueName);
|
||||||
}
|
}
|
||||||
|
get columnTitle() {
|
||||||
|
return this.title;
|
||||||
|
}
|
||||||
|
|
||||||
toggleExpanded(value?: boolean) {
|
toggleExpanded(value?: boolean) {
|
||||||
this.includeInColumnSet('expandedColumns', this.uniqueName, value == null ? !this.isExpanded : value);
|
this.includeInColumnSet('expandedColumns', this.uniqueName, value == null ? !this.isExpanded : value);
|
||||||
@@ -233,6 +239,10 @@ export class PerspectiveTableReferenceNode extends PerspectiveTableNode {
|
|||||||
dataColumns: null,
|
dataColumns: null,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
get columnTitle() {
|
||||||
|
return this.table.pureName;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export function getTableChildPerspectiveNodes(
|
export function getTableChildPerspectiveNodes(
|
||||||
|
|||||||
@@ -78,9 +78,15 @@
|
|||||||
{#if display}
|
{#if display}
|
||||||
<table>
|
<table>
|
||||||
<thead>
|
<thead>
|
||||||
|
<!-- {#each display.columnLevels as columnLevel}
|
||||||
|
<tr>
|
||||||
|
|
||||||
|
</tr>
|
||||||
|
{/each} -->
|
||||||
|
|
||||||
<tr>
|
<tr>
|
||||||
{#each display.columns as column}
|
{#each display.columns as column}
|
||||||
<th>{column.label}</th>
|
<th>{column.title}</th>
|
||||||
{/each}
|
{/each}
|
||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
@@ -88,7 +94,7 @@
|
|||||||
{#each display.rows as row}
|
{#each display.rows as row}
|
||||||
<tr>
|
<tr>
|
||||||
{#each display.columns as column}
|
{#each display.columns as column}
|
||||||
<td>{row[column.field]}</td>
|
<td>{row[column.dataField]}</td>
|
||||||
{/each}
|
{/each}
|
||||||
</tr>
|
</tr>
|
||||||
{/each}
|
{/each}
|
||||||
|
|||||||
Reference in New Issue
Block a user