formview - expand FK columns

This commit is contained in:
Jan Prochazka
2021-01-23 18:48:23 +01:00
parent 427f23e1e0
commit e4ad9acb68
3 changed files with 54 additions and 7 deletions

View File

@@ -32,12 +32,27 @@ export class TableFormViewDisplay extends FormViewDisplay {
) {
super(config, setConfig, cache, setCache, driver, dbinfo);
this.gridDisplay = new TableGridDisplay(tableName, driver, config, setConfig, cache, setCache, dbinfo);
this.gridDisplay.addAllExpandedColumnsToSelected = true;
this.isLoadedCorrectly = this.gridDisplay.isLoadedCorrectly && !!this.driver;
this.columns = this.gridDisplay.columns;
this.columns = [];
this.addDisplayColumns(this.gridDisplay.columns);
this.baseTable = this.gridDisplay.baseTable;
}
addDisplayColumns(columns: DisplayColumn[]) {
for (const col of columns) {
this.columns.push(col);
if (this.gridDisplay.isExpandedColumn(col.uniqueName)) {
const table = this.gridDisplay.getFkTarget(col);
if (table) {
const subcolumns = this.gridDisplay.getDisplayColumns(table, col.uniquePath);
this.addDisplayColumns(subcolumns);
}
}
}
}
getPrimaryKeyEqualCondition(row = null): Condition {
if (!row) row = this.config.formViewKeyRequested || this.config.formViewKey;
if (!row) return null;
@@ -236,4 +251,13 @@ export class TableFormViewDisplay extends FormViewDisplay {
columnName: col.columnName,
};
}
toggleExpandedColumn(uniqueName: string) {
this.gridDisplay.toggleExpandedColumn(uniqueName);
this.gridDisplay.reload();
}
isExpandedColumn(uniqueName: string) {
return this.gridDisplay.isExpandedColumn(uniqueName);
}
}

View File

@@ -7,6 +7,7 @@ import { filterName } from './filterName';
export class TableGridDisplay extends GridDisplay {
public table: TableInfo;
public addAllExpandedColumnsToSelected = false;
constructor(
public tableName: NamedObjectInfo,
@@ -205,7 +206,7 @@ export class TableGridDisplay extends GridDisplay {
displayedColumnInfo: DisplayedColumnInfo
) {
for (const column of columns) {
if (this.config.addedColumns.includes(column.uniqueName)) {
if (this.addAllExpandedColumnsToSelected || this.config.addedColumns.includes(column.uniqueName)) {
select.columns.push({
exprType: 'column',
columnName: column.columnName,