dbgate-datalib 4.7.3 → 4.7.4-alpha.1
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.
- package/lib/CollectionGridDisplay.d.ts +1 -1
- package/lib/CollectionGridDisplay.js +2 -2
- package/lib/GridDisplay.d.ts +2 -2
- package/lib/GridDisplay.js +10 -5
- package/lib/TableFormViewDisplay.d.ts +9 -8
- package/lib/TableFormViewDisplay.js +9 -10
- package/lib/TableGridDisplay.d.ts +1 -1
- package/lib/TableGridDisplay.js +2 -2
- package/package.json +4 -4
|
@@ -4,5 +4,5 @@ import { GridConfig, GridCache } from './GridConfig';
|
|
|
4
4
|
export declare function analyseCollectionDisplayColumns(rows: any, display: any): any[];
|
|
5
5
|
export declare class CollectionGridDisplay extends GridDisplay {
|
|
6
6
|
collection: CollectionInfo;
|
|
7
|
-
constructor(collection: CollectionInfo, driver: EngineDriver, config: GridConfig, setConfig: ChangeConfigFunc, cache: GridCache, setCache: ChangeCacheFunc, loadedRows: any, changeSet: any);
|
|
7
|
+
constructor(collection: CollectionInfo, driver: EngineDriver, config: GridConfig, setConfig: ChangeConfigFunc, cache: GridCache, setCache: ChangeCacheFunc, loadedRows: any, changeSet: any, readOnly?: boolean);
|
|
8
8
|
}
|
|
@@ -89,7 +89,7 @@ function analyseCollectionDisplayColumns(rows, display) {
|
|
|
89
89
|
}
|
|
90
90
|
exports.analyseCollectionDisplayColumns = analyseCollectionDisplayColumns;
|
|
91
91
|
class CollectionGridDisplay extends GridDisplay_1.GridDisplay {
|
|
92
|
-
constructor(collection, driver, config, setConfig, cache, setCache, loadedRows, changeSet) {
|
|
92
|
+
constructor(collection, driver, config, setConfig, cache, setCache, loadedRows, changeSet, readOnly = false) {
|
|
93
93
|
super(config, setConfig, cache, setCache, driver);
|
|
94
94
|
this.collection = collection;
|
|
95
95
|
const changedDocs = lodash_1.default.compact(changeSet.updates.map(chs => chs.document));
|
|
@@ -97,7 +97,7 @@ class CollectionGridDisplay extends GridDisplay_1.GridDisplay {
|
|
|
97
97
|
this.columns = analyseCollectionDisplayColumns([...(loadedRows || []), ...changedDocs, ...insertedDocs], this);
|
|
98
98
|
this.filterable = true;
|
|
99
99
|
this.sortable = true;
|
|
100
|
-
this.editable =
|
|
100
|
+
this.editable = !readOnly;
|
|
101
101
|
this.supportsReload = true;
|
|
102
102
|
this.isDynamicStructure = true;
|
|
103
103
|
this.changeSetKeyFields = ['_id'];
|
package/lib/GridDisplay.d.ts
CHANGED
|
@@ -98,7 +98,7 @@ export declare abstract class GridDisplay {
|
|
|
98
98
|
processReferences(select: Select, displayedColumnInfo: DisplayedColumnInfo, options: any): void;
|
|
99
99
|
createSelectBase(name: NamedObjectInfo, columns: ColumnInfo[], options: any): Select;
|
|
100
100
|
getRowNumberOverSelect(select: Select, offset: number, count: number): Select;
|
|
101
|
-
getPageQuery(offset: number, count: number):
|
|
101
|
+
getPageQuery(offset: number, count: number): Select;
|
|
102
102
|
getExportQuery(postprocessSelect?: any): string;
|
|
103
103
|
getExportColumnMap(): {
|
|
104
104
|
dst: string;
|
|
@@ -106,7 +106,7 @@ export declare abstract class GridDisplay {
|
|
|
106
106
|
ignore: boolean;
|
|
107
107
|
}[];
|
|
108
108
|
resizeColumn(uniqueName: string, computedSize: number, diff: number): void;
|
|
109
|
-
getCountQuery():
|
|
109
|
+
getCountQuery(): Select;
|
|
110
110
|
compileFilters(): Condition;
|
|
111
111
|
switchToFormView(rowData: any): void;
|
|
112
112
|
switchToJsonView(): void;
|
package/lib/GridDisplay.js
CHANGED
|
@@ -329,7 +329,10 @@ class GridDisplay {
|
|
|
329
329
|
const orderColumnName = columns[0].columnName;
|
|
330
330
|
const select = {
|
|
331
331
|
commandType: 'select',
|
|
332
|
-
from: {
|
|
332
|
+
from: {
|
|
333
|
+
name: lodash_1.default.pick(name, ['schemaName', 'pureName']),
|
|
334
|
+
alias: 'basetbl',
|
|
335
|
+
},
|
|
333
336
|
columns: columns.map(col => (Object.assign({ exprType: 'column', alias: col.columnName, source: { alias: 'basetbl' } }, col))),
|
|
334
337
|
orderBy: [
|
|
335
338
|
{
|
|
@@ -408,8 +411,9 @@ class GridDisplay {
|
|
|
408
411
|
select = this.getRowNumberOverSelect(select, offset, count);
|
|
409
412
|
else if (this.dialect.limitSelect)
|
|
410
413
|
select.topRecords = count;
|
|
411
|
-
|
|
412
|
-
|
|
414
|
+
return select;
|
|
415
|
+
// const sql = treeToSql(this.driver, select, dumpSqlSelect);
|
|
416
|
+
// return sql;
|
|
413
417
|
}
|
|
414
418
|
getExportQuery(postprocessSelect = null) {
|
|
415
419
|
const select = this.createSelect({ isExport: true });
|
|
@@ -474,8 +478,9 @@ class GridDisplay {
|
|
|
474
478
|
},
|
|
475
479
|
];
|
|
476
480
|
}
|
|
477
|
-
|
|
478
|
-
|
|
481
|
+
return select;
|
|
482
|
+
// const sql = treeToSql(this.driver, select, dumpSqlSelect);
|
|
483
|
+
// return sql;
|
|
479
484
|
}
|
|
480
485
|
compileFilters() {
|
|
481
486
|
var _a;
|
|
@@ -2,26 +2,27 @@ import { FormViewDisplay } from './FormViewDisplay';
|
|
|
2
2
|
import { ChangeCacheFunc, DisplayColumn, ChangeConfigFunc } from './GridDisplay';
|
|
3
3
|
import { EngineDriver, NamedObjectInfo, DatabaseInfo } from 'dbgate-types';
|
|
4
4
|
import { GridConfig, GridCache } from './GridConfig';
|
|
5
|
-
import {
|
|
5
|
+
import { Condition } from 'dbgate-sqltree';
|
|
6
6
|
import { ChangeSetFieldDefinition, ChangeSetRowDefinition } from './ChangeSet';
|
|
7
7
|
import { DictionaryDescriptionFunc } from '.';
|
|
8
8
|
export declare class TableFormViewDisplay extends FormViewDisplay {
|
|
9
9
|
tableName: NamedObjectInfo;
|
|
10
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);
|
|
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
12
|
addDisplayColumns(columns: DisplayColumn[]): void;
|
|
13
13
|
getPrimaryKeyEqualCondition(row?: any): Condition;
|
|
14
14
|
getPrimaryKeyOperatorCondition(operator: any): Condition;
|
|
15
|
-
getSelect(): Select;
|
|
16
|
-
getCurrentRowQuery():
|
|
17
|
-
getCountSelect(): Select;
|
|
18
|
-
getCountQuery():
|
|
19
|
-
getBeforeCountQuery():
|
|
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
20
|
navigate(row: any): void;
|
|
21
21
|
isLoadedCurrentRow(row: any): boolean;
|
|
22
|
-
navigateRowQuery(commmand: 'begin' | 'previous' | 'next' | 'end'):
|
|
22
|
+
navigateRowQuery(commmand: 'begin' | 'previous' | 'next' | 'end'): import("dbgate-sqltree").Select;
|
|
23
23
|
getChangeSetRow(row: any): ChangeSetRowDefinition;
|
|
24
24
|
getChangeSetField(row: any, uniqueName: any): ChangeSetFieldDefinition;
|
|
25
25
|
toggleExpandedColumn(uniqueName: string, value?: boolean): void;
|
|
26
26
|
isExpandedColumn(uniqueName: string): boolean;
|
|
27
|
+
get editable(): boolean;
|
|
27
28
|
}
|
|
@@ -9,10 +9,10 @@ const dbgate_sqltree_1 = require("dbgate-sqltree");
|
|
|
9
9
|
const TableGridDisplay_1 = require("./TableGridDisplay");
|
|
10
10
|
const json_stable_stringify_1 = __importDefault(require("json-stable-stringify"));
|
|
11
11
|
class TableFormViewDisplay extends FormViewDisplay_1.FormViewDisplay {
|
|
12
|
-
constructor(tableName, driver, config, setConfig, cache, setCache, dbinfo, displayOptions, serverVersion, getDictionaryDescription = null) {
|
|
12
|
+
constructor(tableName, driver, config, setConfig, cache, setCache, dbinfo, displayOptions, serverVersion, getDictionaryDescription = null, isReadOnly = false) {
|
|
13
13
|
super(config, setConfig, cache, setCache, driver, dbinfo, serverVersion);
|
|
14
14
|
this.tableName = tableName;
|
|
15
|
-
this.gridDisplay = new TableGridDisplay_1.TableGridDisplay(tableName, driver, config, setConfig, cache, setCache, dbinfo, displayOptions, serverVersion, getDictionaryDescription);
|
|
15
|
+
this.gridDisplay = new TableGridDisplay_1.TableGridDisplay(tableName, driver, config, setConfig, cache, setCache, dbinfo, displayOptions, serverVersion, getDictionaryDescription, isReadOnly);
|
|
16
16
|
this.gridDisplay.addAllExpandedColumnsToSelected = true;
|
|
17
17
|
this.isLoadedCorrectly = this.gridDisplay.isLoadedCorrectly && !!this.driver;
|
|
18
18
|
this.columns = [];
|
|
@@ -125,8 +125,7 @@ class TableFormViewDisplay extends FormViewDisplay_1.FormViewDisplay {
|
|
|
125
125
|
if (!select)
|
|
126
126
|
return null;
|
|
127
127
|
select.where = (0, dbgate_sqltree_1.mergeConditions)(select.where, this.getPrimaryKeyEqualCondition());
|
|
128
|
-
|
|
129
|
-
return sql;
|
|
128
|
+
return select;
|
|
130
129
|
}
|
|
131
130
|
getCountSelect() {
|
|
132
131
|
const select = this.getSelect();
|
|
@@ -149,8 +148,7 @@ class TableFormViewDisplay extends FormViewDisplay_1.FormViewDisplay {
|
|
|
149
148
|
const select = this.getCountSelect();
|
|
150
149
|
if (!select)
|
|
151
150
|
return null;
|
|
152
|
-
|
|
153
|
-
return sql;
|
|
151
|
+
return select;
|
|
154
152
|
}
|
|
155
153
|
getBeforeCountQuery() {
|
|
156
154
|
if (!this.driver)
|
|
@@ -159,8 +157,7 @@ class TableFormViewDisplay extends FormViewDisplay_1.FormViewDisplay {
|
|
|
159
157
|
if (!select)
|
|
160
158
|
return null;
|
|
161
159
|
select.where = (0, dbgate_sqltree_1.mergeConditions)(select.where, this.getPrimaryKeyOperatorCondition('<'));
|
|
162
|
-
|
|
163
|
-
return sql;
|
|
160
|
+
return select;
|
|
164
161
|
}
|
|
165
162
|
navigate(row) {
|
|
166
163
|
const formViewKey = this.extractKey(row);
|
|
@@ -203,8 +200,7 @@ class TableFormViewDisplay extends FormViewDisplay_1.FormViewDisplay {
|
|
|
203
200
|
select.where = (0, dbgate_sqltree_1.mergeConditions)(select.where, this.getPrimaryKeyOperatorCondition('>'));
|
|
204
201
|
break;
|
|
205
202
|
}
|
|
206
|
-
|
|
207
|
-
return sql;
|
|
203
|
+
return select;
|
|
208
204
|
}
|
|
209
205
|
getChangeSetRow(row) {
|
|
210
206
|
if (!this.baseTable)
|
|
@@ -232,5 +228,8 @@ class TableFormViewDisplay extends FormViewDisplay_1.FormViewDisplay {
|
|
|
232
228
|
isExpandedColumn(uniqueName) {
|
|
233
229
|
return this.gridDisplay.isExpandedColumn(uniqueName);
|
|
234
230
|
}
|
|
231
|
+
get editable() {
|
|
232
|
+
return this.gridDisplay.editable;
|
|
233
|
+
}
|
|
235
234
|
}
|
|
236
235
|
exports.TableFormViewDisplay = TableFormViewDisplay;
|
|
@@ -15,7 +15,7 @@ export declare class TableGridDisplay extends GridDisplay {
|
|
|
15
15
|
table: TableInfo;
|
|
16
16
|
addAllExpandedColumnsToSelected: boolean;
|
|
17
17
|
hintBaseColumns: DisplayColumn[];
|
|
18
|
-
constructor(tableName: NamedObjectInfo, driver: EngineDriver, config: GridConfig, setConfig: ChangeConfigFunc, cache: GridCache, setCache: ChangeCacheFunc, dbinfo: DatabaseInfo, displayOptions: any, serverVersion: any, getDictionaryDescription?: DictionaryDescriptionFunc);
|
|
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
19
|
findTable({ schemaName, pureName }: {
|
|
20
20
|
schemaName?: any;
|
|
21
21
|
pureName: any;
|
package/lib/TableGridDisplay.js
CHANGED
|
@@ -4,7 +4,7 @@ exports.TableGridDisplay = void 0;
|
|
|
4
4
|
const dbgate_tools_1 = require("dbgate-tools");
|
|
5
5
|
const GridDisplay_1 = require("./GridDisplay");
|
|
6
6
|
class TableGridDisplay extends GridDisplay_1.GridDisplay {
|
|
7
|
-
constructor(tableName, driver, config, setConfig, cache, setCache, dbinfo, displayOptions, serverVersion, getDictionaryDescription = null) {
|
|
7
|
+
constructor(tableName, driver, config, setConfig, cache, setCache, dbinfo, displayOptions, serverVersion, getDictionaryDescription = null, isReadOnly = false) {
|
|
8
8
|
super(config, setConfig, cache, setCache, driver, dbinfo, serverVersion);
|
|
9
9
|
this.tableName = tableName;
|
|
10
10
|
this.displayOptions = displayOptions;
|
|
@@ -23,7 +23,7 @@ class TableGridDisplay extends GridDisplay_1.GridDisplay {
|
|
|
23
23
|
this.filterable = true;
|
|
24
24
|
this.sortable = true;
|
|
25
25
|
this.groupable = true;
|
|
26
|
-
this.editable =
|
|
26
|
+
this.editable = !isReadOnly;
|
|
27
27
|
this.supportsReload = true;
|
|
28
28
|
this.baseTable = this.table;
|
|
29
29
|
if (this.table && this.table.columns) {
|
package/package.json
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
{
|
|
2
|
-
"version": "4.7.
|
|
2
|
+
"version": "4.7.4-alpha.1",
|
|
3
3
|
"name": "dbgate-datalib",
|
|
4
4
|
"main": "lib/index.js",
|
|
5
5
|
"typings": "lib/index.d.ts",
|
|
@@ -11,11 +11,11 @@
|
|
|
11
11
|
"lib"
|
|
12
12
|
],
|
|
13
13
|
"dependencies": {
|
|
14
|
-
"dbgate-sqltree": "^4.7.
|
|
15
|
-
"dbgate-filterparser": "^4.7.
|
|
14
|
+
"dbgate-sqltree": "^4.7.4-alpha.1",
|
|
15
|
+
"dbgate-filterparser": "^4.7.4-alpha.1"
|
|
16
16
|
},
|
|
17
17
|
"devDependencies": {
|
|
18
|
-
"dbgate-types": "^4.7.
|
|
18
|
+
"dbgate-types": "^4.7.4-alpha.1",
|
|
19
19
|
"@types/node": "^13.7.0",
|
|
20
20
|
"typescript": "^4.4.3"
|
|
21
21
|
}
|