mirror of
https://github.com/DeNNiiInc/dbgate.git
synced 2026-04-19 10:46:00 +00:00
perspectives WIP
This commit is contained in:
50
packages/datalib/src/PerspectiveColumnDefinition.ts
Normal file
50
packages/datalib/src/PerspectiveColumnDefinition.ts
Normal file
@@ -0,0 +1,50 @@
|
||||
import { ColumnInfo, ForeignKeyInfo, TableInfo } from 'dbgate-types';
|
||||
import { clearConfigCache } from 'prettier';
|
||||
import { ChangePerspectiveConfigFunc, PerspectiveConfig } from './PerspectiveConfig';
|
||||
|
||||
export abstract class PerspectiveColumnDefinition {
|
||||
abstract get title();
|
||||
abstract get props();
|
||||
abstract get isExpanded();
|
||||
abstract get isExpandable();
|
||||
abstract get level();
|
||||
abstract toggleExpanded();
|
||||
}
|
||||
|
||||
export class PerspectiveTableColumnDefinition extends PerspectiveColumnDefinition {
|
||||
foreignKey: ForeignKeyInfo;
|
||||
constructor(
|
||||
public column: ColumnInfo,
|
||||
public table: TableInfo,
|
||||
public config: PerspectiveConfig,
|
||||
public setConfig: ChangePerspectiveConfigFunc
|
||||
) {
|
||||
super();
|
||||
|
||||
this.foreignKey =
|
||||
table.foreignKeys &&
|
||||
table.foreignKeys.find(fk => fk.columns.length == 1 && fk.columns[0].columnName == column.columnName);
|
||||
}
|
||||
|
||||
get title() {
|
||||
return this.column.columnName;
|
||||
}
|
||||
|
||||
get props() {
|
||||
return this.column;
|
||||
}
|
||||
|
||||
get isExpanded() {
|
||||
return this.config.expandedColumns.includes(this.column.uniqueName);
|
||||
}
|
||||
|
||||
get isExpandable() {
|
||||
return !!this.foreignKey;
|
||||
}
|
||||
|
||||
get level() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
toggleExpanded() {}
|
||||
}
|
||||
Reference in New Issue
Block a user