dbgate-datalib 5.2.1 → 5.2.2-alpha.12

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -30,12 +30,7 @@ export interface GridConfig extends GridConfigColumns {
30
30
  childConfig?: GridConfig;
31
31
  reference?: GridReferenceDefinition;
32
32
  isFormView?: boolean;
33
- formViewKey?: {
34
- [uniqueName: string]: string;
35
- };
36
- formViewKeyRequested?: {
37
- [uniqueName: string]: string;
38
- };
33
+ formViewRecordNumber?: number;
39
34
  formFilterColumns: string[];
40
35
  formColumnFilterText?: string;
41
36
  }
@@ -40,6 +40,7 @@ export declare abstract class GridDisplay {
40
40
  constructor(config: GridConfig, setConfig: ChangeConfigFunc, cache: GridCache, setCache: ChangeCacheFunc, driver?: EngineDriver, dbinfo?: DatabaseInfo, serverVersion?: any);
41
41
  dialect: SqlDialect;
42
42
  columns: DisplayColumn[];
43
+ formColumns: DisplayColumn[];
43
44
  baseTable?: TableInfo;
44
45
  baseView?: ViewInfo;
45
46
  baseCollection?: CollectionInfo;
@@ -115,7 +116,8 @@ export declare abstract class GridDisplay {
115
116
  resizeColumn(uniqueName: string, computedSize: number, diff: number): void;
116
117
  getCountQuery(): Select;
117
118
  compileFilters(): Condition;
118
- switchToFormView(rowData: any): void;
119
+ switchToFormView(rowIndex: any): void;
119
120
  switchToJsonView(): void;
121
+ formViewNavigate(command: any, allRowCount: any): void;
120
122
  }
121
123
  export declare function reloadDataCacheFunc(cache: GridCache): GridCache;
@@ -19,6 +19,7 @@ class GridDisplay {
19
19
  this.driver = driver;
20
20
  this.dbinfo = dbinfo;
21
21
  this.serverVersion = serverVersion;
22
+ this.formColumns = [];
22
23
  this.changeSetKeyFields = null;
23
24
  this.sortable = false;
24
25
  this.groupable = false;
@@ -237,7 +238,7 @@ class GridDisplay {
237
238
  return this.config.filters[uniqueName];
238
239
  }
239
240
  setFilter(uniqueName, value) {
240
- this.setConfig(cfg => (Object.assign(Object.assign({}, cfg), { filters: Object.assign(Object.assign({}, cfg.filters), { [uniqueName]: value }) })));
241
+ this.setConfig(cfg => (Object.assign(Object.assign({}, cfg), { filters: Object.assign(Object.assign({}, cfg.filters), { [uniqueName]: value }), formViewRecordNumber: 0 })));
241
242
  this.reload();
242
243
  }
243
244
  showFilter(uniqueName) {
@@ -248,7 +249,7 @@ class GridDisplay {
248
249
  });
249
250
  }
250
251
  removeFilter(uniqueName) {
251
- this.setConfig(cfg => (Object.assign(Object.assign({}, cfg), { filters: lodash_1.default.omit(cfg.filters, [uniqueName]) })));
252
+ this.setConfig(cfg => (Object.assign(Object.assign({}, cfg), { filters: lodash_1.default.omit(cfg.filters, [uniqueName]), formFilterColumns: (cfg.formFilterColumns || []).filter(x => x != uniqueName) })));
252
253
  this.reload();
253
254
  }
254
255
  setFilters(dct) {
@@ -555,20 +556,29 @@ class GridDisplay {
555
556
  conditions,
556
557
  };
557
558
  }
558
- switchToFormView(rowData) {
559
- if (!this.baseTable)
560
- return;
561
- const { primaryKey } = this.baseTable;
562
- if (!primaryKey)
563
- return;
564
- const { columns } = primaryKey;
565
- this.setConfig(cfg => (Object.assign(Object.assign({}, cfg), { isFormView: true, formViewKey: rowData
566
- ? lodash_1.default.pick(rowData, columns.map(x => x.columnName))
567
- : null, formViewKeyRequested: null })));
559
+ switchToFormView(rowIndex) {
560
+ this.setConfig(cfg => (Object.assign(Object.assign({}, cfg), { isFormView: true, formViewRecordNumber: rowIndex })));
568
561
  }
569
562
  switchToJsonView() {
570
563
  this.setConfig(cfg => (Object.assign(Object.assign({}, cfg), { isJsonView: true })));
571
564
  }
565
+ formViewNavigate(command, allRowCount) {
566
+ switch (command) {
567
+ case 'begin':
568
+ this.setConfig(cfg => (Object.assign(Object.assign({}, cfg), { formViewRecordNumber: 0 })));
569
+ break;
570
+ case 'previous':
571
+ this.setConfig(cfg => (Object.assign(Object.assign({}, cfg), { formViewRecordNumber: Math.max((cfg.formViewRecordNumber || 0) - 1, 0) })));
572
+ break;
573
+ case 'next':
574
+ this.setConfig(cfg => (Object.assign(Object.assign({}, cfg), { formViewRecordNumber: Math.max((cfg.formViewRecordNumber || 0) + 1, 0) })));
575
+ break;
576
+ case 'end':
577
+ this.setConfig(cfg => (Object.assign(Object.assign({}, cfg), { formViewRecordNumber: Math.max(allRowCount - 1, 0) })));
578
+ break;
579
+ }
580
+ this.reload();
581
+ }
572
582
  }
573
583
  exports.GridDisplay = GridDisplay;
574
584
  function reloadDataCacheFunc(cache) {
@@ -33,6 +33,7 @@ class JslGridDisplay extends GridDisplay_1.GridDisplay {
33
33
  }
34
34
  if (!this.columns)
35
35
  this.columns = [];
36
+ this.formColumns = this.columns;
36
37
  }
37
38
  }
38
39
  exports.JslGridDisplay = JslGridDisplay;
@@ -16,6 +16,7 @@ export declare class TableGridDisplay extends GridDisplay {
16
16
  addAllExpandedColumnsToSelected: boolean;
17
17
  hintBaseColumns: DisplayColumn[];
18
18
  constructor(tableName: NamedObjectInfo, driver: EngineDriver, config: GridConfig, setConfig: ChangeConfigFunc, cache: GridCache, setCache: ChangeCacheFunc, dbinfo: DatabaseInfo, displayOptions: any, serverVersion: any, getDictionaryDescription?: DictionaryDescriptionFunc, isReadOnly?: boolean);
19
+ addFormDisplayColumns(columns: any): void;
19
20
  findTable({ schemaName, pureName }: {
20
21
  schemaName?: any;
21
22
  pureName: any;
@@ -20,6 +20,7 @@ class TableGridDisplay extends GridDisplay_1.GridDisplay {
20
20
  }
21
21
  }
22
22
  this.columns = this.getDisplayColumns(this.table, []);
23
+ this.addFormDisplayColumns(this.getDisplayColumns(this.table, []));
23
24
  this.filterable = true;
24
25
  this.sortable = true;
25
26
  this.groupable = true;
@@ -31,6 +32,22 @@ class TableGridDisplay extends GridDisplay_1.GridDisplay {
31
32
  ? this.table.primaryKey.columns.map(x => x.columnName)
32
33
  : this.table.columns.map(x => x.columnName);
33
34
  }
35
+ if (this.config.isFormView) {
36
+ this.addAllExpandedColumnsToSelected = true;
37
+ this.hintBaseColumns = this.formColumns;
38
+ }
39
+ }
40
+ addFormDisplayColumns(columns) {
41
+ for (const col of columns) {
42
+ this.formColumns.push(col);
43
+ if (this.isExpandedColumn(col.uniqueName)) {
44
+ const table = this.getFkTarget(col);
45
+ if (table) {
46
+ const subcolumns = this.getDisplayColumns(table, col.uniquePath);
47
+ this.addFormDisplayColumns(subcolumns);
48
+ }
49
+ }
50
+ }
34
51
  }
35
52
  findTable({ schemaName = undefined, pureName }) {
36
53
  return (this.dbinfo &&
@@ -7,6 +7,7 @@ class ViewGridDisplay extends GridDisplay_1.GridDisplay {
7
7
  super(config, setConfig, cache, setCache, driver, serverVersion);
8
8
  this.view = view;
9
9
  this.columns = this.getDisplayColumns(view);
10
+ this.formColumns = this.columns;
10
11
  this.filterable = true;
11
12
  this.sortable = true;
12
13
  this.groupable = false;
package/lib/index.d.ts CHANGED
@@ -10,8 +10,6 @@ export * from './FreeTableGridDisplay';
10
10
  export * from './FreeTableModel';
11
11
  export * from './MacroDefinition';
12
12
  export * from './runMacro';
13
- export * from './FormViewDisplay';
14
- export * from './TableFormViewDisplay';
15
13
  export * from './CollectionGridDisplay';
16
14
  export * from './deleteCascade';
17
15
  export * from './PerspectiveDisplay';
package/lib/index.js CHANGED
@@ -26,8 +26,8 @@ __exportStar(require("./FreeTableGridDisplay"), exports);
26
26
  __exportStar(require("./FreeTableModel"), exports);
27
27
  __exportStar(require("./MacroDefinition"), exports);
28
28
  __exportStar(require("./runMacro"), exports);
29
- __exportStar(require("./FormViewDisplay"), exports);
30
- __exportStar(require("./TableFormViewDisplay"), exports);
29
+ // export * from './FormViewDisplay';
30
+ // export * from './TableFormViewDisplay';
31
31
  __exportStar(require("./CollectionGridDisplay"), exports);
32
32
  __exportStar(require("./deleteCascade"), exports);
33
33
  __exportStar(require("./PerspectiveDisplay"), exports);
package/package.json CHANGED
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "5.2.1",
2
+ "version": "5.2.2-alpha.12",
3
3
  "name": "dbgate-datalib",
4
4
  "main": "lib/index.js",
5
5
  "typings": "lib/index.d.ts",
@@ -13,12 +13,12 @@
13
13
  "lib"
14
14
  ],
15
15
  "dependencies": {
16
- "dbgate-sqltree": "^5.2.1",
17
- "dbgate-tools": "^5.2.1",
18
- "dbgate-filterparser": "^5.2.1"
16
+ "dbgate-sqltree": "^5.2.2-alpha.12",
17
+ "dbgate-tools": "^5.2.2-alpha.12",
18
+ "dbgate-filterparser": "^5.2.2-alpha.12"
19
19
  },
20
20
  "devDependencies": {
21
- "dbgate-types": "^5.2.1",
21
+ "dbgate-types": "^5.2.2-alpha.12",
22
22
  "@types/node": "^13.7.0",
23
23
  "jest": "^28.1.3",
24
24
  "ts-jest": "^28.0.7",
@@ -1,26 +0,0 @@
1
- import { GridConfig, GridCache } from './GridConfig';
2
- import type { TableInfo, EngineDriver, DatabaseInfo, SqlDialect } from 'dbgate-types';
3
- import { ChangeCacheFunc, ChangeConfigFunc, DisplayColumn } from './GridDisplay';
4
- export declare class FormViewDisplay {
5
- config: GridConfig;
6
- protected setConfig: ChangeConfigFunc;
7
- cache: GridCache;
8
- protected setCache: ChangeCacheFunc;
9
- driver?: EngineDriver;
10
- dbinfo: DatabaseInfo;
11
- serverVersion: any;
12
- isLoadedCorrectly: boolean;
13
- columns: DisplayColumn[];
14
- baseTable: TableInfo;
15
- dialect: SqlDialect;
16
- constructor(config: GridConfig, setConfig: ChangeConfigFunc, cache: GridCache, setCache: ChangeCacheFunc, driver?: EngineDriver, dbinfo?: DatabaseInfo, serverVersion?: any);
17
- addFilterColumn(column: any): void;
18
- filterCellValue(column: any, rowData: any): void;
19
- setFilter(uniqueName: any, value: any): void;
20
- removeFilter(uniqueName: any): void;
21
- reload(): void;
22
- getKeyValue(columnName: any): string;
23
- requestKeyValue(columnName: any, value: any): void;
24
- extractKey(row: any): Pick<any, string>;
25
- cancelRequestKey(rowData: any): void;
26
- }
@@ -1,77 +0,0 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.FormViewDisplay = void 0;
7
- const lodash_1 = __importDefault(require("lodash"));
8
- const GridConfig_1 = require("./GridConfig");
9
- const dbgate_filterparser_1 = require("dbgate-filterparser");
10
- class FormViewDisplay {
11
- constructor(config, setConfig, cache, setCache, driver, dbinfo = null, serverVersion = null) {
12
- this.config = config;
13
- this.setConfig = setConfig;
14
- this.cache = cache;
15
- this.setCache = setCache;
16
- this.driver = driver;
17
- this.dbinfo = dbinfo;
18
- this.serverVersion = serverVersion;
19
- this.isLoadedCorrectly = true;
20
- this.dialect = ((driver === null || driver === void 0 ? void 0 : driver.dialectByVersion) && (driver === null || driver === void 0 ? void 0 : driver.dialectByVersion(serverVersion))) || (driver === null || driver === void 0 ? void 0 : driver.dialect);
21
- }
22
- addFilterColumn(column) {
23
- if (!column)
24
- return;
25
- this.setConfig(cfg => (Object.assign(Object.assign({}, cfg), { formFilterColumns: [...(cfg.formFilterColumns || []), column.uniqueName] })));
26
- }
27
- filterCellValue(column, rowData) {
28
- if (!column || !rowData)
29
- return;
30
- const value = rowData[column.uniqueName];
31
- const expr = (0, dbgate_filterparser_1.getFilterValueExpression)(value, column.dataType);
32
- if (expr) {
33
- this.setConfig(cfg => (Object.assign(Object.assign({}, cfg), { filters: Object.assign(Object.assign({}, cfg.filters), { [column.uniqueName]: expr }), addedColumns: cfg.addedColumns.includes(column.uniqueName)
34
- ? cfg.addedColumns
35
- : [...cfg.addedColumns, column.uniqueName] })));
36
- this.reload();
37
- }
38
- }
39
- setFilter(uniqueName, value) {
40
- this.setConfig(cfg => (Object.assign(Object.assign({}, cfg), { filters: Object.assign(Object.assign({}, cfg.filters), { [uniqueName]: value }) })));
41
- this.reload();
42
- }
43
- removeFilter(uniqueName) {
44
- const reloadRequired = !!this.config.filters[uniqueName];
45
- this.setConfig(cfg => (Object.assign(Object.assign({}, cfg), { formFilterColumns: (cfg.formFilterColumns || []).filter(x => x != uniqueName), filters: lodash_1.default.omit(cfg.filters || [], uniqueName) })));
46
- if (reloadRequired)
47
- this.reload();
48
- }
49
- reload() {
50
- this.setCache(cache => (Object.assign(Object.assign({}, (0, GridConfig_1.createGridCache)()), { refreshTime: new Date().getTime() })));
51
- }
52
- getKeyValue(columnName) {
53
- const { formViewKey, formViewKeyRequested } = this.config;
54
- if (formViewKeyRequested && formViewKeyRequested[columnName])
55
- return formViewKeyRequested[columnName];
56
- if (formViewKey && formViewKey[columnName])
57
- return formViewKey[columnName];
58
- return null;
59
- }
60
- requestKeyValue(columnName, value) {
61
- if (this.getKeyValue(columnName) == value)
62
- return;
63
- this.setConfig(cfg => (Object.assign(Object.assign({}, cfg), { formViewKeyRequested: Object.assign(Object.assign(Object.assign({}, cfg.formViewKey), cfg.formViewKeyRequested), { [columnName]: value }) })));
64
- this.reload();
65
- }
66
- extractKey(row) {
67
- if (!row || !this.baseTable || !this.baseTable.primaryKey) {
68
- return null;
69
- }
70
- const formViewKey = lodash_1.default.pick(row, this.baseTable.primaryKey.columns.map(x => x.columnName));
71
- return formViewKey;
72
- }
73
- cancelRequestKey(rowData) {
74
- this.setConfig(cfg => (Object.assign(Object.assign({}, cfg), { formViewKeyRequested: null, formViewKey: rowData ? this.extractKey(rowData) : cfg.formViewKey })));
75
- }
76
- }
77
- exports.FormViewDisplay = FormViewDisplay;
@@ -1,28 +0,0 @@
1
- import { FormViewDisplay } from './FormViewDisplay';
2
- import { ChangeCacheFunc, DisplayColumn, ChangeConfigFunc } from './GridDisplay';
3
- import type { EngineDriver, NamedObjectInfo, DatabaseInfo } from 'dbgate-types';
4
- import { GridConfig, GridCache } from './GridConfig';
5
- import { Condition } from 'dbgate-sqltree';
6
- import { ChangeSetFieldDefinition, ChangeSetRowDefinition } from './ChangeSet';
7
- import { DictionaryDescriptionFunc } from '.';
8
- export declare class TableFormViewDisplay extends FormViewDisplay {
9
- tableName: NamedObjectInfo;
10
- private gridDisplay;
11
- constructor(tableName: NamedObjectInfo, driver: EngineDriver, config: GridConfig, setConfig: ChangeConfigFunc, cache: GridCache, setCache: ChangeCacheFunc, dbinfo: DatabaseInfo, displayOptions: any, serverVersion: any, getDictionaryDescription?: DictionaryDescriptionFunc, isReadOnly?: boolean);
12
- addDisplayColumns(columns: DisplayColumn[]): void;
13
- getPrimaryKeyEqualCondition(row?: any): Condition;
14
- getPrimaryKeyOperatorCondition(operator: any): Condition;
15
- getSelect(): import("dbgate-sqltree").Select;
16
- getCurrentRowQuery(): import("dbgate-sqltree").Select;
17
- getCountSelect(): import("dbgate-sqltree").Select;
18
- getCountQuery(): import("dbgate-sqltree").Select;
19
- getBeforeCountQuery(): import("dbgate-sqltree").Select;
20
- navigate(row: any): void;
21
- isLoadedCurrentRow(row: any): boolean;
22
- navigateRowQuery(commmand: 'begin' | 'previous' | 'next' | 'end'): import("dbgate-sqltree").Select;
23
- getChangeSetRow(row: any): ChangeSetRowDefinition;
24
- getChangeSetField(row: any, uniqueName: any): ChangeSetFieldDefinition;
25
- toggleExpandedColumn(uniqueName: string, value?: boolean): void;
26
- isExpandedColumn(uniqueName: string): boolean;
27
- get editable(): boolean;
28
- }
@@ -1,235 +0,0 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.TableFormViewDisplay = void 0;
7
- const FormViewDisplay_1 = require("./FormViewDisplay");
8
- const dbgate_sqltree_1 = require("dbgate-sqltree");
9
- const TableGridDisplay_1 = require("./TableGridDisplay");
10
- const json_stable_stringify_1 = __importDefault(require("json-stable-stringify"));
11
- class TableFormViewDisplay extends FormViewDisplay_1.FormViewDisplay {
12
- constructor(tableName, driver, config, setConfig, cache, setCache, dbinfo, displayOptions, serverVersion, getDictionaryDescription = null, isReadOnly = false) {
13
- super(config, setConfig, cache, setCache, driver, dbinfo, serverVersion);
14
- this.tableName = tableName;
15
- this.gridDisplay = new TableGridDisplay_1.TableGridDisplay(tableName, driver, config, setConfig, cache, setCache, dbinfo, displayOptions, serverVersion, getDictionaryDescription, isReadOnly);
16
- this.gridDisplay.addAllExpandedColumnsToSelected = true;
17
- this.isLoadedCorrectly = this.gridDisplay.isLoadedCorrectly && !!this.driver;
18
- this.columns = [];
19
- this.addDisplayColumns(this.gridDisplay.columns);
20
- this.baseTable = this.gridDisplay.baseTable;
21
- this.gridDisplay.hintBaseColumns = this.columns;
22
- }
23
- addDisplayColumns(columns) {
24
- for (const col of columns) {
25
- this.columns.push(col);
26
- if (this.gridDisplay.isExpandedColumn(col.uniqueName)) {
27
- const table = this.gridDisplay.getFkTarget(col);
28
- if (table) {
29
- const subcolumns = this.gridDisplay.getDisplayColumns(table, col.uniquePath);
30
- this.addDisplayColumns(subcolumns);
31
- }
32
- }
33
- }
34
- }
35
- getPrimaryKeyEqualCondition(row = null) {
36
- if (!row)
37
- row = this.config.formViewKeyRequested || this.config.formViewKey;
38
- if (!row)
39
- return null;
40
- const { primaryKey } = this.gridDisplay.baseTable;
41
- if (!primaryKey)
42
- return null;
43
- return {
44
- conditionType: 'and',
45
- conditions: primaryKey.columns.map(({ columnName }) => ({
46
- conditionType: 'binary',
47
- operator: '=',
48
- left: {
49
- exprType: 'column',
50
- columnName,
51
- source: {
52
- alias: 'basetbl',
53
- },
54
- },
55
- right: {
56
- exprType: 'value',
57
- value: row[columnName],
58
- },
59
- })),
60
- };
61
- }
62
- getPrimaryKeyOperatorCondition(operator) {
63
- if (!this.config.formViewKey)
64
- return null;
65
- const conditions = [];
66
- const { primaryKey } = this.gridDisplay.baseTable;
67
- if (!primaryKey)
68
- return null;
69
- for (let index = 0; index < primaryKey.columns.length; index++) {
70
- conditions.push({
71
- conditionType: 'and',
72
- conditions: [
73
- ...primaryKey.columns.slice(0, index).map(({ columnName }) => ({
74
- conditionType: 'binary',
75
- operator: '=',
76
- left: {
77
- exprType: 'column',
78
- columnName,
79
- source: {
80
- alias: 'basetbl',
81
- },
82
- },
83
- right: {
84
- exprType: 'value',
85
- value: this.config.formViewKey[columnName],
86
- },
87
- })),
88
- ...primaryKey.columns.slice(index).map(({ columnName }) => ({
89
- conditionType: 'binary',
90
- operator: operator,
91
- left: {
92
- exprType: 'column',
93
- columnName,
94
- source: {
95
- alias: 'basetbl',
96
- },
97
- },
98
- right: {
99
- exprType: 'value',
100
- value: this.config.formViewKey[columnName],
101
- },
102
- })),
103
- ],
104
- });
105
- }
106
- if (conditions.length == 1) {
107
- return conditions[0];
108
- }
109
- return {
110
- conditionType: 'or',
111
- conditions,
112
- };
113
- }
114
- getSelect() {
115
- if (!this.driver)
116
- return null;
117
- const select = this.gridDisplay.createSelect();
118
- if (!select)
119
- return null;
120
- select.topRecords = 1;
121
- return select;
122
- }
123
- getCurrentRowQuery() {
124
- const select = this.getSelect();
125
- if (!select)
126
- return null;
127
- select.where = (0, dbgate_sqltree_1.mergeConditions)(select.where, this.getPrimaryKeyEqualCondition());
128
- return select;
129
- }
130
- getCountSelect() {
131
- const select = this.getSelect();
132
- if (!select)
133
- return null;
134
- select.orderBy = null;
135
- select.columns = [
136
- {
137
- exprType: 'raw',
138
- sql: 'COUNT(*)',
139
- alias: 'count',
140
- },
141
- ];
142
- select.topRecords = null;
143
- return select;
144
- }
145
- getCountQuery() {
146
- if (!this.driver)
147
- return null;
148
- const select = this.getCountSelect();
149
- if (!select)
150
- return null;
151
- return select;
152
- }
153
- getBeforeCountQuery() {
154
- if (!this.driver)
155
- return null;
156
- const select = this.getCountSelect();
157
- if (!select)
158
- return null;
159
- select.where = (0, dbgate_sqltree_1.mergeConditions)(select.where, this.getPrimaryKeyOperatorCondition('<'));
160
- return select;
161
- }
162
- navigate(row) {
163
- const formViewKey = this.extractKey(row);
164
- this.setConfig(cfg => (Object.assign(Object.assign({}, cfg), { formViewKey })));
165
- }
166
- isLoadedCurrentRow(row) {
167
- if (!row)
168
- return false;
169
- const formViewKey = this.extractKey(row);
170
- return (0, json_stable_stringify_1.default)(formViewKey) == (0, json_stable_stringify_1.default)(this.config.formViewKey);
171
- }
172
- navigateRowQuery(commmand) {
173
- if (!this.driver)
174
- return null;
175
- const select = this.gridDisplay.createSelect();
176
- if (!select)
177
- return null;
178
- const { primaryKey } = this.gridDisplay.baseTable;
179
- function getOrderBy(direction) {
180
- return primaryKey.columns.map(({ columnName }) => ({
181
- exprType: 'column',
182
- columnName,
183
- direction,
184
- }));
185
- }
186
- select.topRecords = 1;
187
- switch (commmand) {
188
- case 'begin':
189
- select.orderBy = getOrderBy('ASC');
190
- break;
191
- case 'end':
192
- select.orderBy = getOrderBy('DESC');
193
- break;
194
- case 'previous':
195
- select.orderBy = getOrderBy('DESC');
196
- select.where = (0, dbgate_sqltree_1.mergeConditions)(select.where, this.getPrimaryKeyOperatorCondition('<'));
197
- break;
198
- case 'next':
199
- select.orderBy = getOrderBy('ASC');
200
- select.where = (0, dbgate_sqltree_1.mergeConditions)(select.where, this.getPrimaryKeyOperatorCondition('>'));
201
- break;
202
- }
203
- return select;
204
- }
205
- getChangeSetRow(row) {
206
- if (!this.baseTable)
207
- return null;
208
- return {
209
- pureName: this.baseTable.pureName,
210
- schemaName: this.baseTable.schemaName,
211
- condition: this.extractKey(row),
212
- };
213
- }
214
- getChangeSetField(row, uniqueName) {
215
- const col = this.columns.find(x => x.uniqueName == uniqueName);
216
- if (!col)
217
- return null;
218
- if (!this.baseTable)
219
- return null;
220
- if (this.baseTable.pureName != col.pureName || this.baseTable.schemaName != col.schemaName)
221
- return null;
222
- return Object.assign(Object.assign({}, this.getChangeSetRow(row)), { uniqueName: uniqueName, columnName: col.columnName });
223
- }
224
- toggleExpandedColumn(uniqueName, value) {
225
- this.gridDisplay.toggleExpandedColumn(uniqueName, value);
226
- this.gridDisplay.reload();
227
- }
228
- isExpandedColumn(uniqueName) {
229
- return this.gridDisplay.isExpandedColumn(uniqueName);
230
- }
231
- get editable() {
232
- return this.gridDisplay.editable;
233
- }
234
- }
235
- exports.TableFormViewDisplay = TableFormViewDisplay;