inline editing

This commit is contained in:
Jan Prochazka
2020-03-22 16:58:32 +01:00
parent 606074ca7d
commit f79e729126
11 changed files with 209 additions and 11 deletions

View File

@@ -4,6 +4,7 @@ import { ForeignKeyInfo, TableInfo, ColumnInfo, DbType } from '@dbgate/types';
import { parseFilter, getFilterType } from '@dbgate/filterparser';
import { filterName } from './filterName';
import { Select, Expression } from '@dbgate/sqltree';
import { ChangeSetFieldDefinition } from './ChangeSet';
export interface DisplayColumn {
schemaName: string;
@@ -47,6 +48,8 @@ export abstract class GridDisplay {
) {}
abstract getPageQuery(offset: number, count: number): string;
columns: DisplayColumn[];
baseTable?: TableInfo;
changeSetKeyFields: string[] = null;
setColumnVisibility(uniquePath: string[], isVisible: boolean) {
const uniqueName = uniquePath.join('.');
if (uniquePath.length == 1) {
@@ -350,4 +353,23 @@ export abstract class GridDisplay {
});
this.reload();
}
getChangeSetCondition(row) {
if (!this.changeSetKeyFields) return null;
return _.pick(row, this.changeSetKeyFields);
}
getChangeSetField(row, uniqueName): ChangeSetFieldDefinition {
const col = this.columns.find(x => x.uniqueName == uniqueName);
if (!col) return null;
if (!this.baseTable) return null;
if (this.baseTable.pureName != col.pureName || this.baseTable.schemaName != col.schemaName) return null;
return {
pureName: col.pureName,
schemaName: col.schemaName,
uniqueName: uniqueName,
columnName: col.columnName,
condition: this.getChangeSetCondition(row),
};
}
}