mirror of
https://github.com/DeNNiiInc/dbgate.git
synced 2026-04-23 21:56:00 +00:00
form view cleanup
This commit is contained in:
@@ -1,120 +0,0 @@
|
|||||||
// import _ from 'lodash';
|
|
||||||
// import { GridConfig, GridCache, GridConfigColumns, createGridCache, GroupFunc } from './GridConfig';
|
|
||||||
// import type { TableInfo, EngineDriver, DatabaseInfo, SqlDialect } from 'dbgate-types';
|
|
||||||
// import { getFilterValueExpression } from 'dbgate-filterparser';
|
|
||||||
// import { ChangeCacheFunc, ChangeConfigFunc, DisplayColumn } from './GridDisplay';
|
|
||||||
|
|
||||||
// export class FormViewDisplay {
|
|
||||||
// isLoadedCorrectly = true;
|
|
||||||
// columns: DisplayColumn[];
|
|
||||||
// public baseTable: TableInfo;
|
|
||||||
// dialect: SqlDialect;
|
|
||||||
|
|
||||||
// constructor(
|
|
||||||
// public config: GridConfig,
|
|
||||||
// protected setConfig: ChangeConfigFunc,
|
|
||||||
// public cache: GridCache,
|
|
||||||
// protected setCache: ChangeCacheFunc,
|
|
||||||
// public driver?: EngineDriver,
|
|
||||||
// public dbinfo: DatabaseInfo = null,
|
|
||||||
// public serverVersion = null
|
|
||||||
// ) {
|
|
||||||
// this.dialect = (driver?.dialectByVersion && driver?.dialectByVersion(serverVersion)) || driver?.dialect;
|
|
||||||
// }
|
|
||||||
|
|
||||||
// addFilterColumn(column) {
|
|
||||||
// if (!column) return;
|
|
||||||
// this.setConfig(cfg => ({
|
|
||||||
// ...cfg,
|
|
||||||
// formFilterColumns: [...(cfg.formFilterColumns || []), column.uniqueName],
|
|
||||||
// }));
|
|
||||||
// }
|
|
||||||
|
|
||||||
// filterCellValue(column, rowData) {
|
|
||||||
// if (!column || !rowData) return;
|
|
||||||
// const value = rowData[column.uniqueName];
|
|
||||||
// const expr = getFilterValueExpression(value, column.dataType);
|
|
||||||
// if (expr) {
|
|
||||||
// this.setConfig(cfg => ({
|
|
||||||
// ...cfg,
|
|
||||||
// filters: {
|
|
||||||
// ...cfg.filters,
|
|
||||||
// [column.uniqueName]: expr,
|
|
||||||
// },
|
|
||||||
// addedColumns: cfg.addedColumns.includes(column.uniqueName)
|
|
||||||
// ? cfg.addedColumns
|
|
||||||
// : [...cfg.addedColumns, column.uniqueName],
|
|
||||||
// }));
|
|
||||||
// this.reload();
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
|
|
||||||
// setFilter(uniqueName, value) {
|
|
||||||
// this.setConfig(cfg => ({
|
|
||||||
// ...cfg,
|
|
||||||
// filters: {
|
|
||||||
// ...cfg.filters,
|
|
||||||
// [uniqueName]: value,
|
|
||||||
// },
|
|
||||||
// }));
|
|
||||||
// this.reload();
|
|
||||||
// }
|
|
||||||
|
|
||||||
// removeFilter(uniqueName) {
|
|
||||||
// const reloadRequired = !!this.config.filters[uniqueName];
|
|
||||||
// this.setConfig(cfg => ({
|
|
||||||
// ...cfg,
|
|
||||||
// formFilterColumns: (cfg.formFilterColumns || []).filter(x => x != uniqueName),
|
|
||||||
// filters: _.omit(cfg.filters || [], uniqueName),
|
|
||||||
// }));
|
|
||||||
// if (reloadRequired) this.reload();
|
|
||||||
// }
|
|
||||||
|
|
||||||
// reload() {
|
|
||||||
// this.setCache(cache => ({
|
|
||||||
// // ...cache,
|
|
||||||
// ...createGridCache(),
|
|
||||||
// refreshTime: new Date().getTime(),
|
|
||||||
// }));
|
|
||||||
// }
|
|
||||||
|
|
||||||
// getKeyValue(columnName) {
|
|
||||||
// const { formViewKey, formViewKeyRequested } = this.config;
|
|
||||||
// if (formViewKeyRequested && formViewKeyRequested[columnName]) return formViewKeyRequested[columnName];
|
|
||||||
// if (formViewKey && formViewKey[columnName]) return formViewKey[columnName];
|
|
||||||
// return null;
|
|
||||||
// }
|
|
||||||
|
|
||||||
// requestKeyValue(columnName, value) {
|
|
||||||
// if (this.getKeyValue(columnName) == value) return;
|
|
||||||
|
|
||||||
// this.setConfig(cfg => ({
|
|
||||||
// ...cfg,
|
|
||||||
// formViewKeyRequested: {
|
|
||||||
// ...cfg.formViewKey,
|
|
||||||
// ...cfg.formViewKeyRequested,
|
|
||||||
// [columnName]: value,
|
|
||||||
// },
|
|
||||||
// }));
|
|
||||||
// this.reload();
|
|
||||||
// }
|
|
||||||
|
|
||||||
// extractKey(row) {
|
|
||||||
// if (!row || !this.baseTable || !this.baseTable.primaryKey) {
|
|
||||||
// return null;
|
|
||||||
// }
|
|
||||||
// const formViewKey = _.pick(
|
|
||||||
// row,
|
|
||||||
// this.baseTable.primaryKey.columns.map(x => x.columnName)
|
|
||||||
// );
|
|
||||||
// return formViewKey;
|
|
||||||
// }
|
|
||||||
|
|
||||||
// cancelRequestKey(rowData) {
|
|
||||||
// this.setConfig(cfg => ({
|
|
||||||
// ...cfg,
|
|
||||||
// formViewKeyRequested: null,
|
|
||||||
// formViewKey: rowData ? this.extractKey(rowData) : cfg.formViewKey,
|
|
||||||
// }));
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
@@ -28,8 +28,6 @@ export interface GridConfig extends GridConfigColumns {
|
|||||||
reference?: GridReferenceDefinition;
|
reference?: GridReferenceDefinition;
|
||||||
isFormView?: boolean;
|
isFormView?: boolean;
|
||||||
formViewRecordNumber?: number;
|
formViewRecordNumber?: number;
|
||||||
// formViewKey?: { [uniqueName: string]: string };
|
|
||||||
// formViewKeyRequested?: { [uniqueName: string]: string };
|
|
||||||
formFilterColumns: string[];
|
formFilterColumns: string[];
|
||||||
formColumnFilterText?: string;
|
formColumnFilterText?: string;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -722,22 +722,10 @@ export abstract class GridDisplay {
|
|||||||
}
|
}
|
||||||
|
|
||||||
switchToFormView(rowIndex) {
|
switchToFormView(rowIndex) {
|
||||||
// if (!this.baseTable) return;
|
|
||||||
// const { primaryKey } = this.baseTable;
|
|
||||||
// if (!primaryKey) return;
|
|
||||||
// const { columns } = primaryKey;
|
|
||||||
|
|
||||||
this.setConfig(cfg => ({
|
this.setConfig(cfg => ({
|
||||||
...cfg,
|
...cfg,
|
||||||
isFormView: true,
|
isFormView: true,
|
||||||
formViewRecordNumber: rowIndex,
|
formViewRecordNumber: rowIndex,
|
||||||
// formViewKey: rowData
|
|
||||||
// ? _.pick(
|
|
||||||
// rowData,
|
|
||||||
// columns.map(x => x.columnName)
|
|
||||||
// )
|
|
||||||
// : null,
|
|
||||||
// formViewKeyRequested: null,
|
|
||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,272 +0,0 @@
|
|||||||
// import { FormViewDisplay } from './FormViewDisplay';
|
|
||||||
// import _ from 'lodash';
|
|
||||||
// import { ChangeCacheFunc, DisplayColumn, ChangeConfigFunc } from './GridDisplay';
|
|
||||||
// import type { EngineDriver, NamedObjectInfo, DatabaseInfo } from 'dbgate-types';
|
|
||||||
// import { GridConfig, GridCache } from './GridConfig';
|
|
||||||
// import { mergeConditions, Condition, OrderByExpression } from 'dbgate-sqltree';
|
|
||||||
// import { TableGridDisplay } from './TableGridDisplay';
|
|
||||||
// import stableStringify from 'json-stable-stringify';
|
|
||||||
// import { ChangeSetFieldDefinition, ChangeSetRowDefinition } from './ChangeSet';
|
|
||||||
// import { DictionaryDescriptionFunc } from '.';
|
|
||||||
|
|
||||||
// export class TableFormViewDisplay extends FormViewDisplay {
|
|
||||||
// // use utility functions from GridDisplay and publish result in FromViewDisplay interface
|
|
||||||
// private gridDisplay: TableGridDisplay;
|
|
||||||
|
|
||||||
// constructor(
|
|
||||||
// public tableName: NamedObjectInfo,
|
|
||||||
// driver: EngineDriver,
|
|
||||||
// config: GridConfig,
|
|
||||||
// setConfig: ChangeConfigFunc,
|
|
||||||
// cache: GridCache,
|
|
||||||
// setCache: ChangeCacheFunc,
|
|
||||||
// dbinfo: DatabaseInfo,
|
|
||||||
// displayOptions,
|
|
||||||
// serverVersion,
|
|
||||||
// getDictionaryDescription: DictionaryDescriptionFunc = null,
|
|
||||||
// isReadOnly = false
|
|
||||||
// ) {
|
|
||||||
// super(config, setConfig, cache, setCache, driver, dbinfo, serverVersion);
|
|
||||||
// this.gridDisplay = new TableGridDisplay(
|
|
||||||
// tableName,
|
|
||||||
// driver,
|
|
||||||
// config,
|
|
||||||
// setConfig,
|
|
||||||
// cache,
|
|
||||||
// setCache,
|
|
||||||
// dbinfo,
|
|
||||||
// displayOptions,
|
|
||||||
// serverVersion,
|
|
||||||
// getDictionaryDescription,
|
|
||||||
// isReadOnly
|
|
||||||
// );
|
|
||||||
// this.gridDisplay.addAllExpandedColumnsToSelected = true;
|
|
||||||
|
|
||||||
// this.isLoadedCorrectly = this.gridDisplay.isLoadedCorrectly && !!this.driver;
|
|
||||||
// this.columns = [];
|
|
||||||
// this.addDisplayColumns(this.gridDisplay.columns);
|
|
||||||
// this.baseTable = this.gridDisplay.baseTable;
|
|
||||||
// this.gridDisplay.hintBaseColumns = this.columns;
|
|
||||||
// }
|
|
||||||
|
|
||||||
// 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;
|
|
||||||
// const { primaryKey } = this.gridDisplay.baseTable;
|
|
||||||
// if (!primaryKey) return null;
|
|
||||||
// return {
|
|
||||||
// conditionType: 'and',
|
|
||||||
// conditions: primaryKey.columns.map(({ columnName }) => ({
|
|
||||||
// conditionType: 'binary',
|
|
||||||
// operator: '=',
|
|
||||||
// left: {
|
|
||||||
// exprType: 'column',
|
|
||||||
// columnName,
|
|
||||||
// source: {
|
|
||||||
// alias: 'basetbl',
|
|
||||||
// },
|
|
||||||
// },
|
|
||||||
// right: {
|
|
||||||
// exprType: 'value',
|
|
||||||
// value: row[columnName],
|
|
||||||
// },
|
|
||||||
// })),
|
|
||||||
// };
|
|
||||||
// }
|
|
||||||
|
|
||||||
// getPrimaryKeyOperatorCondition(operator): Condition {
|
|
||||||
// if (!this.config.formViewKey) return null;
|
|
||||||
// const conditions = [];
|
|
||||||
|
|
||||||
// const { primaryKey } = this.gridDisplay.baseTable;
|
|
||||||
// if (!primaryKey) return null;
|
|
||||||
// for (let index = 0; index < primaryKey.columns.length; index++) {
|
|
||||||
// conditions.push({
|
|
||||||
// conditionType: 'and',
|
|
||||||
// conditions: [
|
|
||||||
// ...primaryKey.columns.slice(0, index).map(({ columnName }) => ({
|
|
||||||
// conditionType: 'binary',
|
|
||||||
// operator: '=',
|
|
||||||
// left: {
|
|
||||||
// exprType: 'column',
|
|
||||||
// columnName,
|
|
||||||
// source: {
|
|
||||||
// alias: 'basetbl',
|
|
||||||
// },
|
|
||||||
// },
|
|
||||||
// right: {
|
|
||||||
// exprType: 'value',
|
|
||||||
// value: this.config.formViewKey[columnName],
|
|
||||||
// },
|
|
||||||
// })),
|
|
||||||
// ...primaryKey.columns.slice(index).map(({ columnName }) => ({
|
|
||||||
// conditionType: 'binary',
|
|
||||||
// operator: operator,
|
|
||||||
// left: {
|
|
||||||
// exprType: 'column',
|
|
||||||
// columnName,
|
|
||||||
// source: {
|
|
||||||
// alias: 'basetbl',
|
|
||||||
// },
|
|
||||||
// },
|
|
||||||
// right: {
|
|
||||||
// exprType: 'value',
|
|
||||||
// value: this.config.formViewKey[columnName],
|
|
||||||
// },
|
|
||||||
// })),
|
|
||||||
// ],
|
|
||||||
// });
|
|
||||||
// }
|
|
||||||
|
|
||||||
// if (conditions.length == 1) {
|
|
||||||
// return conditions[0];
|
|
||||||
// }
|
|
||||||
|
|
||||||
// return {
|
|
||||||
// conditionType: 'or',
|
|
||||||
// conditions,
|
|
||||||
// };
|
|
||||||
// }
|
|
||||||
|
|
||||||
// getSelect() {
|
|
||||||
// if (!this.driver) return null;
|
|
||||||
// const select = this.gridDisplay.createSelect();
|
|
||||||
// if (!select) return null;
|
|
||||||
// select.topRecords = 1;
|
|
||||||
// return select;
|
|
||||||
// }
|
|
||||||
|
|
||||||
// getCurrentRowQuery() {
|
|
||||||
// const select = this.getSelect();
|
|
||||||
// if (!select) return null;
|
|
||||||
|
|
||||||
// select.where = mergeConditions(select.where, this.getPrimaryKeyEqualCondition());
|
|
||||||
// return select;
|
|
||||||
// }
|
|
||||||
|
|
||||||
// getCountSelect() {
|
|
||||||
// const select = this.getSelect();
|
|
||||||
// if (!select) return null;
|
|
||||||
// select.orderBy = null;
|
|
||||||
// select.columns = [
|
|
||||||
// {
|
|
||||||
// exprType: 'raw',
|
|
||||||
// sql: 'COUNT(*)',
|
|
||||||
// alias: 'count',
|
|
||||||
// },
|
|
||||||
// ];
|
|
||||||
// select.topRecords = null;
|
|
||||||
// return select;
|
|
||||||
// }
|
|
||||||
|
|
||||||
// getCountQuery() {
|
|
||||||
// if (!this.driver) return null;
|
|
||||||
// const select = this.getCountSelect();
|
|
||||||
// if (!select) return null;
|
|
||||||
// return select;
|
|
||||||
// }
|
|
||||||
|
|
||||||
// getBeforeCountQuery() {
|
|
||||||
// if (!this.driver) return null;
|
|
||||||
// const select = this.getCountSelect();
|
|
||||||
// if (!select) return null;
|
|
||||||
// select.where = mergeConditions(select.where, this.getPrimaryKeyOperatorCondition('<'));
|
|
||||||
// return select;
|
|
||||||
// }
|
|
||||||
|
|
||||||
// navigate(row) {
|
|
||||||
// const formViewKey = this.extractKey(row);
|
|
||||||
// this.setConfig(cfg => ({
|
|
||||||
// ...cfg,
|
|
||||||
// formViewKey,
|
|
||||||
// }));
|
|
||||||
// }
|
|
||||||
|
|
||||||
// isLoadedCurrentRow(row) {
|
|
||||||
// if (!row) return false;
|
|
||||||
// const formViewKey = this.extractKey(row);
|
|
||||||
// return stableStringify(formViewKey) == stableStringify(this.config.formViewKey);
|
|
||||||
// }
|
|
||||||
|
|
||||||
// navigateRowQuery(commmand: 'begin' | 'previous' | 'next' | 'end') {
|
|
||||||
// if (!this.driver) return null;
|
|
||||||
// const select = this.gridDisplay.createSelect();
|
|
||||||
// if (!select) return null;
|
|
||||||
// const { primaryKey } = this.gridDisplay.baseTable;
|
|
||||||
|
|
||||||
// function getOrderBy(direction): OrderByExpression[] {
|
|
||||||
// return primaryKey.columns.map(({ columnName }) => ({
|
|
||||||
// exprType: 'column',
|
|
||||||
// columnName,
|
|
||||||
// direction,
|
|
||||||
// }));
|
|
||||||
// }
|
|
||||||
|
|
||||||
// select.topRecords = 1;
|
|
||||||
// switch (commmand) {
|
|
||||||
// case 'begin':
|
|
||||||
// select.orderBy = getOrderBy('ASC');
|
|
||||||
// break;
|
|
||||||
// case 'end':
|
|
||||||
// select.orderBy = getOrderBy('DESC');
|
|
||||||
// break;
|
|
||||||
// case 'previous':
|
|
||||||
// select.orderBy = getOrderBy('DESC');
|
|
||||||
// select.where = mergeConditions(select.where, this.getPrimaryKeyOperatorCondition('<'));
|
|
||||||
// break;
|
|
||||||
// case 'next':
|
|
||||||
// select.orderBy = getOrderBy('ASC');
|
|
||||||
// select.where = mergeConditions(select.where, this.getPrimaryKeyOperatorCondition('>'));
|
|
||||||
// break;
|
|
||||||
// }
|
|
||||||
|
|
||||||
// return select;
|
|
||||||
// }
|
|
||||||
|
|
||||||
// getChangeSetRow(row): ChangeSetRowDefinition {
|
|
||||||
// if (!this.baseTable) return null;
|
|
||||||
// return {
|
|
||||||
// pureName: this.baseTable.pureName,
|
|
||||||
// schemaName: this.baseTable.schemaName,
|
|
||||||
// condition: this.extractKey(row),
|
|
||||||
// };
|
|
||||||
// }
|
|
||||||
|
|
||||||
// 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 {
|
|
||||||
// ...this.getChangeSetRow(row),
|
|
||||||
// uniqueName: uniqueName,
|
|
||||||
// columnName: col.columnName,
|
|
||||||
// };
|
|
||||||
// }
|
|
||||||
|
|
||||||
// toggleExpandedColumn(uniqueName: string, value?: boolean) {
|
|
||||||
// this.gridDisplay.toggleExpandedColumn(uniqueName, value);
|
|
||||||
// this.gridDisplay.reload();
|
|
||||||
// }
|
|
||||||
|
|
||||||
// isExpandedColumn(uniqueName: string) {
|
|
||||||
// return this.gridDisplay.isExpandedColumn(uniqueName);
|
|
||||||
// }
|
|
||||||
|
|
||||||
// get editable() {
|
|
||||||
// return this.gridDisplay.editable;
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
@@ -1,96 +0,0 @@
|
|||||||
// import type { ChangeSet, ChangeSetRowDefinition } from 'dbgate-datalib';
|
|
||||||
// import {
|
|
||||||
// changeSetContainsChanges,
|
|
||||||
// changeSetInsertNewRow,
|
|
||||||
// createChangeSet,
|
|
||||||
// deleteChangeSetRows,
|
|
||||||
// findExistingChangeSetItem,
|
|
||||||
// getChangeSetInsertedRows,
|
|
||||||
// TableFormViewDisplay,
|
|
||||||
// revertChangeSetRowChanges,
|
|
||||||
// setChangeSetValue,
|
|
||||||
// } from 'dbgate-datalib';
|
|
||||||
// import Former from './Former';
|
|
||||||
|
|
||||||
// export default class ChangeSetFormer extends Former {
|
|
||||||
// public changeSet: ChangeSet;
|
|
||||||
// public setChangeSet: Function;
|
|
||||||
// private batchChangeSet: ChangeSet;
|
|
||||||
// public rowDefinition: ChangeSetRowDefinition;
|
|
||||||
// public rowStatus;
|
|
||||||
// public rowData: {};
|
|
||||||
|
|
||||||
// constructor(
|
|
||||||
// public sourceRow: any,
|
|
||||||
// public changeSetState,
|
|
||||||
// public dispatchChangeSet,
|
|
||||||
// public display: TableFormViewDisplay
|
|
||||||
// ) {
|
|
||||||
// super();
|
|
||||||
// this.changeSet = changeSetState && changeSetState.value;
|
|
||||||
// this.setChangeSet = value => dispatchChangeSet({ type: 'set', value });
|
|
||||||
// this.batchChangeSet = null;
|
|
||||||
// this.rowDefinition = display.getChangeSetRow(sourceRow);
|
|
||||||
// const [matchedField, matchedChangeSetItem] = findExistingChangeSetItem(this.changeSet, this.rowDefinition);
|
|
||||||
// this.rowData = matchedChangeSetItem ? { ...sourceRow, ...matchedChangeSetItem.fields } : sourceRow;
|
|
||||||
// let status = 'regular';
|
|
||||||
// if (matchedChangeSetItem && matchedField == 'updates') status = 'updated';
|
|
||||||
// if (matchedField == 'deletes') status = 'deleted';
|
|
||||||
// this.rowStatus = {
|
|
||||||
// status,
|
|
||||||
// modifiedFields:
|
|
||||||
// matchedChangeSetItem && matchedChangeSetItem.fields ? new Set(Object.keys(matchedChangeSetItem.fields)) : null,
|
|
||||||
// };
|
|
||||||
// }
|
|
||||||
|
|
||||||
// applyModification(changeSetReducer) {
|
|
||||||
// if (this.batchChangeSet) {
|
|
||||||
// this.batchChangeSet = changeSetReducer(this.batchChangeSet);
|
|
||||||
// } else {
|
|
||||||
// this.setChangeSet(changeSetReducer(this.changeSet));
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
|
|
||||||
// setCellValue(uniqueName: string, value: any) {
|
|
||||||
// const row = this.sourceRow;
|
|
||||||
// const definition = this.display.getChangeSetField(row, uniqueName);
|
|
||||||
// this.applyModification(chs => setChangeSetValue(chs, definition, value));
|
|
||||||
// }
|
|
||||||
|
|
||||||
// deleteRow(index: number) {
|
|
||||||
// this.applyModification(chs => deleteChangeSetRows(chs, this.rowDefinition));
|
|
||||||
// }
|
|
||||||
|
|
||||||
// beginUpdate() {
|
|
||||||
// this.batchChangeSet = this.changeSet;
|
|
||||||
// }
|
|
||||||
// endUpdate() {
|
|
||||||
// this.setChangeSet(this.batchChangeSet);
|
|
||||||
// this.batchChangeSet = null;
|
|
||||||
// }
|
|
||||||
|
|
||||||
// revertRowChanges() {
|
|
||||||
// this.applyModification(chs => revertChangeSetRowChanges(chs, this.rowDefinition));
|
|
||||||
// }
|
|
||||||
// revertAllChanges() {
|
|
||||||
// this.applyModification(chs => createChangeSet());
|
|
||||||
// }
|
|
||||||
// undo() {
|
|
||||||
// this.dispatchChangeSet({ type: 'undo' });
|
|
||||||
// }
|
|
||||||
// redo() {
|
|
||||||
// this.dispatchChangeSet({ type: 'redo' });
|
|
||||||
// }
|
|
||||||
// get editable() {
|
|
||||||
// return this.display.editable;
|
|
||||||
// }
|
|
||||||
// get canUndo() {
|
|
||||||
// return this.changeSetState.canUndo;
|
|
||||||
// }
|
|
||||||
// get canRedo() {
|
|
||||||
// return this.changeSetState.canRedo;
|
|
||||||
// }
|
|
||||||
// get containsChanges() {
|
|
||||||
// return changeSetContainsChanges(this.changeSet);
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
@@ -1,53 +0,0 @@
|
|||||||
// // export interface GriderRowStatus {
|
|
||||||
// // status: 'regular' | 'updated' | 'deleted' | 'inserted';
|
|
||||||
// // modifiedFields?: Set<string>;
|
|
||||||
// // insertedFields?: Set<string>;
|
|
||||||
// // deletedFields?: Set<string>;
|
|
||||||
// // }
|
|
||||||
|
|
||||||
// export default abstract class Former {
|
|
||||||
// public rowData: any;
|
|
||||||
|
|
||||||
// // getRowStatus(index): GriderRowStatus {
|
|
||||||
// // const res: GriderRowStatus = {
|
|
||||||
// // status: 'regular',
|
|
||||||
// // };
|
|
||||||
// // return res;
|
|
||||||
// // }
|
|
||||||
// beginUpdate() {}
|
|
||||||
// endUpdate() {}
|
|
||||||
// setCellValue(uniqueName: string, value: any) {}
|
|
||||||
// revertRowChanges() {}
|
|
||||||
// revertAllChanges() {}
|
|
||||||
// undo() {}
|
|
||||||
// redo() {}
|
|
||||||
// get editable() {
|
|
||||||
// return false;
|
|
||||||
// }
|
|
||||||
// get canInsert() {
|
|
||||||
// return false;
|
|
||||||
// }
|
|
||||||
// get allowSave() {
|
|
||||||
// return this.containsChanges;
|
|
||||||
// }
|
|
||||||
// get canUndo() {
|
|
||||||
// return false;
|
|
||||||
// }
|
|
||||||
// get canRedo() {
|
|
||||||
// return false;
|
|
||||||
// }
|
|
||||||
// get containsChanges() {
|
|
||||||
// return false;
|
|
||||||
// }
|
|
||||||
// get disableLoadNextPage() {
|
|
||||||
// return false;
|
|
||||||
// }
|
|
||||||
// get errors() {
|
|
||||||
// return null;
|
|
||||||
// }
|
|
||||||
// updateRow(changeObject) {
|
|
||||||
// for (const key of Object.keys(changeObject)) {
|
|
||||||
// this.setCellValue(key, changeObject[key]);
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
@@ -1,51 +0,0 @@
|
|||||||
<!-- <script lang="ts">
|
|
||||||
import ColumnLabel from '../elements/ColumnLabel.svelte';
|
|
||||||
import InlineButton from '../buttons/InlineButton.svelte';
|
|
||||||
|
|
||||||
import FontIcon from '../icons/FontIcon.svelte';
|
|
||||||
import keycodes from '../utility/keycodes';
|
|
||||||
|
|
||||||
export let column;
|
|
||||||
export let baseTable;
|
|
||||||
export let formDisplay;
|
|
||||||
|
|
||||||
let domEditor;
|
|
||||||
$: value = formDisplay.getKeyValue(column.columnName);
|
|
||||||
|
|
||||||
const applyFilter = () => {
|
|
||||||
formDisplay.requestKeyValue(column.columnName, domEditor.value);
|
|
||||||
};
|
|
||||||
|
|
||||||
const cancelFilter = () => {
|
|
||||||
formDisplay.cancelRequestKey();
|
|
||||||
formDisplay.reload();
|
|
||||||
};
|
|
||||||
|
|
||||||
const handleKeyDown = ev => {
|
|
||||||
if (ev.keyCode == keycodes.enter) {
|
|
||||||
applyFilter();
|
|
||||||
}
|
|
||||||
if (ev.keyCode == keycodes.escape) {
|
|
||||||
cancelFilter();
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
$: if (domEditor) domEditor.value = value;
|
|
||||||
</script>
|
|
||||||
|
|
||||||
<div class="m-1">
|
|
||||||
<div class="space-between">
|
|
||||||
<div>
|
|
||||||
<FontIcon icon="img primary-key" />
|
|
||||||
<ColumnLabel {...baseTable.columns.find(x => x.columnName == column.columnName)} />
|
|
||||||
</div>
|
|
||||||
{#if formDisplay.config.formViewKeyRequested}
|
|
||||||
<InlineButton square on:click={cancelFilter}>
|
|
||||||
<FontIcon icon="icon delete" />
|
|
||||||
</InlineButton>
|
|
||||||
{/if}
|
|
||||||
</div>
|
|
||||||
<div class="flex">
|
|
||||||
<input bind:this={domEditor} type="text" on:blur={applyFilter} on:keydown={handleKeyDown} />
|
|
||||||
</div>
|
|
||||||
</div> -->
|
|
||||||
@@ -36,13 +36,11 @@
|
|||||||
let isLoadedCount = false;
|
let isLoadedCount = false;
|
||||||
let loadedTime = new Date().getTime();
|
let loadedTime = new Date().getTime();
|
||||||
let allRowCount = null;
|
let allRowCount = null;
|
||||||
let rowCountBefore = null;
|
|
||||||
let errorMessage = null;
|
let errorMessage = null;
|
||||||
|
|
||||||
const handleLoadCurrentRow = async () => {
|
const handleLoadCurrentRow = async () => {
|
||||||
if (isLoadingData) return;
|
if (isLoadingData) return;
|
||||||
let newLoadedRow = false;
|
let newLoadedRow = false;
|
||||||
// if (_.isNumber(display.config.formViewRecordNumber)) {
|
|
||||||
isLoadingData = true;
|
isLoadingData = true;
|
||||||
const row = await loadRow($$props, display.getPageQuery(display.config.formViewRecordNumber || 0, 1));
|
const row = await loadRow($$props, display.getPageQuery(display.config.formViewRecordNumber || 0, 1));
|
||||||
isLoadingData = false;
|
isLoadingData = false;
|
||||||
@@ -50,13 +48,6 @@
|
|||||||
rowData = row;
|
rowData = row;
|
||||||
loadedTime = new Date().getTime();
|
loadedTime = new Date().getTime();
|
||||||
newLoadedRow = row;
|
newLoadedRow = row;
|
||||||
// }
|
|
||||||
// if (formDisplay.config.formViewKeyRequested && newLoadedRow) {
|
|
||||||
// formDisplay.cancelRequestKey(newLoadedRow);
|
|
||||||
// }
|
|
||||||
// if (!newLoadedRow && !formDisplay.config.formViewKeyRequested) {
|
|
||||||
// await handleNavigate('first');
|
|
||||||
// }
|
|
||||||
};
|
};
|
||||||
|
|
||||||
const handleLoadRowCount = async () => {
|
const handleLoadRowCount = async () => {
|
||||||
@@ -67,24 +58,10 @@
|
|||||||
isLoadedCount = true;
|
isLoadedCount = true;
|
||||||
isLoadingCount = false;
|
isLoadingCount = false;
|
||||||
allRowCount = countRow ? parseInt(countRow.count) : null;
|
allRowCount = countRow ? parseInt(countRow.count) : null;
|
||||||
// rowCountBefore = countBeforeRow ? parseInt(countBeforeRow.count) : null;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
const handleNavigate = async command => {
|
const handleNavigate = async command => {
|
||||||
display.formViewNavigate(command, allRowCount);
|
display.formViewNavigate(command, allRowCount);
|
||||||
|
|
||||||
// isLoadingData = true;
|
|
||||||
// const row = await loadRow($$props, formDisplay.navigateRowQuery(command));
|
|
||||||
// if (row) {
|
|
||||||
// formDisplay.navigate(row);
|
|
||||||
// }
|
|
||||||
// isLoadingData = false;
|
|
||||||
// isLoadedData = true;
|
|
||||||
// isLoadedCount = false;
|
|
||||||
// allRowCount = null;
|
|
||||||
// rowCountBefore = null;
|
|
||||||
// rowData = row;
|
|
||||||
// loadedTime = new Date().getTime();
|
|
||||||
};
|
};
|
||||||
|
|
||||||
export function reload() {
|
export function reload() {
|
||||||
@@ -95,7 +72,6 @@
|
|||||||
rowData = null;
|
rowData = null;
|
||||||
loadedTime = new Date().getTime();
|
loadedTime = new Date().getTime();
|
||||||
allRowCount = null;
|
allRowCount = null;
|
||||||
rowCountBefore = null;
|
|
||||||
errorMessage = null;
|
errorMessage = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user