mirror of
https://github.com/DeNNiiInc/dbgate.git
synced 2026-04-19 22:26:01 +00:00
jsl grid display
This commit is contained in:
@@ -7,16 +7,16 @@ import { Select, Expression } from '@dbgate/sqltree';
|
||||
import { ChangeSetFieldDefinition, ChangeSetRowDefinition } from './ChangeSet';
|
||||
|
||||
export interface DisplayColumn {
|
||||
schemaName: string;
|
||||
pureName: string;
|
||||
schemaName?: string;
|
||||
pureName?: string;
|
||||
columnName: string;
|
||||
headerText: string;
|
||||
uniqueName: string;
|
||||
uniquePath: string[];
|
||||
notNull: boolean;
|
||||
autoIncrement: boolean;
|
||||
isPrimaryKey: boolean;
|
||||
foreignKey: ForeignKeyInfo;
|
||||
autoIncrement?: boolean;
|
||||
isPrimaryKey?: boolean;
|
||||
foreignKey?: ForeignKeyInfo;
|
||||
isChecked?: boolean;
|
||||
hintColumnName?: string;
|
||||
commonType?: DbType;
|
||||
@@ -47,9 +47,11 @@ export abstract class GridDisplay {
|
||||
public cache: GridCache,
|
||||
protected setCache: ChangeCacheFunc,
|
||||
protected getTableInfo: ({ schemaName, pureName }) => Promise<TableInfo>,
|
||||
public driver: EngineDriver
|
||||
public driver?: EngineDriver
|
||||
) {}
|
||||
abstract getPageQuery(offset: number, count: number): string;
|
||||
getPageQuery(offset: number, count: number): string {
|
||||
return null;
|
||||
}
|
||||
columns: DisplayColumn[];
|
||||
baseTable?: TableInfo;
|
||||
changeSetKeyFields: string[] = null;
|
||||
@@ -65,7 +67,7 @@ export abstract class GridDisplay {
|
||||
}
|
||||
|
||||
get engine() {
|
||||
return this.driver.engine;
|
||||
return this.driver?.engine;
|
||||
}
|
||||
|
||||
reload() {
|
||||
|
||||
24
packages/datalib/src/JslGridDisplay.ts
Normal file
24
packages/datalib/src/JslGridDisplay.ts
Normal file
@@ -0,0 +1,24 @@
|
||||
import { GridDisplay, ChangeCacheFunc } from './GridDisplay';
|
||||
import { QueryResultColumn } from '@dbgate/types';
|
||||
import { GridConfig, GridCache } from './GridConfig';
|
||||
|
||||
export class JslGridDisplay extends GridDisplay {
|
||||
constructor(
|
||||
jslid,
|
||||
columns: QueryResultColumn[],
|
||||
config: GridConfig,
|
||||
setConfig: (config: GridConfig) => void,
|
||||
cache: GridCache,
|
||||
setCache: ChangeCacheFunc
|
||||
) {
|
||||
super(config, setConfig, cache, setCache, null, null);
|
||||
this.columns = columns.map((col) => ({
|
||||
columnName: col.columnName,
|
||||
headerText: col.columnName,
|
||||
uniqueName: col.columnName,
|
||||
uniquePath: [col.columnName],
|
||||
notNull: col.notNull,
|
||||
autoIncrement: col.autoIncrement,
|
||||
}));
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,6 @@
|
||||
export * from "./GridDisplay";
|
||||
export * from "./GridConfig";
|
||||
export * from "./TableGridDisplay";
|
||||
export * from "./JslGridDisplay";
|
||||
export * from "./ChangeSet";
|
||||
export * from "./filterName";
|
||||
|
||||
Reference in New Issue
Block a user