mirror of
https://github.com/dbgate/dbgate
synced 2024-11-07 20:26:23 +00:00
custom grid display fix
This commit is contained in:
parent
befada8b87
commit
cb0a11fda9
@ -20,6 +20,8 @@ export interface CustomGridColumn {
|
||||
}
|
||||
|
||||
export class CustomGridDisplay extends GridDisplay {
|
||||
customColumns: CustomGridColumn[];
|
||||
|
||||
constructor(
|
||||
public tableName: NamedObjectInfo,
|
||||
columns: CustomGridColumn[],
|
||||
@ -35,6 +37,8 @@ export class CustomGridDisplay extends GridDisplay {
|
||||
) {
|
||||
super(config, setConfig, cache, setCache, driver, dbinfo, serverVersion);
|
||||
|
||||
this.customColumns = columns;
|
||||
|
||||
this.columns = columns.map(col => ({
|
||||
columnName: col.columnName,
|
||||
headerText: col.columnLabel,
|
||||
@ -63,12 +67,15 @@ export class CustomGridDisplay extends GridDisplay {
|
||||
createSelect(options = {}) {
|
||||
const select = this.createSelectBase(
|
||||
this.tableName,
|
||||
[],
|
||||
// @ts-ignore
|
||||
this.columns.map(col => ({
|
||||
columnName: col.columnName,
|
||||
})),
|
||||
options
|
||||
// this.columns.map(col => ({
|
||||
// columnName: col.columnName,
|
||||
// })),
|
||||
options,
|
||||
this.customColumns.find(x => x.isPrimaryKey)?.columnName
|
||||
);
|
||||
select.selectAll = true;
|
||||
if (this.additionalcondition) {
|
||||
if (select.where) {
|
||||
select.where = {
|
||||
|
@ -554,9 +554,9 @@ export abstract class GridDisplay {
|
||||
};
|
||||
}
|
||||
|
||||
createSelectBase(name: NamedObjectInfo, columns: ColumnInfo[], options) {
|
||||
createSelectBase(name: NamedObjectInfo, columns: ColumnInfo[], options, defaultOrderColumnName?: string) {
|
||||
if (!columns) return null;
|
||||
const orderColumnName = columns[0].columnName;
|
||||
const orderColumnName = defaultOrderColumnName ?? columns[0]?.columnName;
|
||||
const select: Select = {
|
||||
commandType: 'select',
|
||||
from: {
|
||||
@ -732,6 +732,7 @@ export abstract class GridDisplay {
|
||||
alias: 'count',
|
||||
},
|
||||
];
|
||||
select.selectAll = false;
|
||||
}
|
||||
return select;
|
||||
// const sql = treeToSql(this.driver, select, dumpSqlSelect);
|
||||
|
@ -15,7 +15,7 @@ export function dumpSqlSelect(dmp: SqlDumper, cmd: Select) {
|
||||
if (cmd.selectAll) {
|
||||
dmp.put('* ');
|
||||
}
|
||||
if (cmd.columns) {
|
||||
if (cmd.columns && cmd.columns.length > 0) {
|
||||
if (cmd.selectAll) dmp.put('&n,');
|
||||
dmp.put('&>&n');
|
||||
dmp.putCollection(',&n', cmd.columns, fld => {
|
||||
|
Loading…
Reference in New Issue
Block a user