mirror of
https://github.com/DeNNiiInc/dbgate.git
synced 2026-04-22 18:06:01 +00:00
perspectives: render simple table
This commit is contained in:
18
packages/datalib/src/PerspectiveDisplay.ts
Normal file
18
packages/datalib/src/PerspectiveDisplay.ts
Normal file
@@ -0,0 +1,18 @@
|
||||
import { PerspectiveTableNode, PerspectiveTreeNode } from './PerspectiveTreeNode';
|
||||
|
||||
export class PerspectiveDisplayColumn {
|
||||
constructor(public label: string, public field: string) {}
|
||||
}
|
||||
|
||||
export class PerspectiveDisplay {
|
||||
columns: PerspectiveDisplayColumn[] = [];
|
||||
|
||||
constructor(public root: PerspectiveTreeNode, public rows: any[]) {
|
||||
const children = root.childNodes;
|
||||
for (const child of children) {
|
||||
if (child.isChecked) {
|
||||
this.columns.push(new PerspectiveDisplayColumn(child.title, child.codeName));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -7,6 +7,7 @@ import _cloneDeep from 'lodash/cloneDeep';
|
||||
export interface PerspectiveDataLoadProps {
|
||||
schemaName: string;
|
||||
pureName: string;
|
||||
dataColumns: string[];
|
||||
bindingColumns?: string[];
|
||||
bindingValues?: any[][];
|
||||
}
|
||||
@@ -128,6 +129,7 @@ export class PerspectiveTableColumnNode extends PerspectiveTreeNode {
|
||||
pureName: this.foreignKey.refTableName,
|
||||
bindingColumns: [this.foreignKey.columns[0].refColumnName],
|
||||
bindingValues: parentRows.map(row => row[this.foreignKey.columns[0].columnName]),
|
||||
dataColumns: null,
|
||||
};
|
||||
}
|
||||
|
||||
@@ -178,6 +180,7 @@ export class PerspectiveTableNode extends PerspectiveTreeNode {
|
||||
return {
|
||||
schemaName: this.table.schemaName,
|
||||
pureName: this.table.pureName,
|
||||
dataColumns: null,
|
||||
};
|
||||
}
|
||||
|
||||
@@ -227,6 +230,7 @@ export class PerspectiveTableReferenceNode extends PerspectiveTableNode {
|
||||
pureName: this.table.pureName,
|
||||
bindingColumns: [this.foreignKey.columns[0].columnName],
|
||||
bindingValues: parentRows.map(row => row[this.foreignKey.columns[0].refColumnName]),
|
||||
dataColumns: null,
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
@@ -14,3 +14,4 @@ export * from './FormViewDisplay';
|
||||
export * from './TableFormViewDisplay';
|
||||
export * from './CollectionGridDisplay';
|
||||
export * from './deleteCascade';
|
||||
export * from './PerspectiveDisplay';
|
||||
|
||||
Reference in New Issue
Block a user