dbgate-datalib 5.0.2 → 5.0.4-alpha.7
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/ChangeSet.js +32 -19
- package/lib/GridDisplay.d.ts +5 -0
- package/lib/GridDisplay.js +27 -1
- package/lib/TableGridDisplay.js +1 -6
- package/package.json +4 -4
package/lib/ChangeSet.js
CHANGED
|
@@ -183,27 +183,40 @@ function changeSetInsertToSql(item, dbinfo = null) {
|
|
|
183
183
|
];
|
|
184
184
|
}
|
|
185
185
|
function extractChangeSetCondition(item, alias) {
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
name: {
|
|
196
|
-
pureName: item.pureName,
|
|
197
|
-
schemaName: item.schemaName,
|
|
198
|
-
},
|
|
199
|
-
alias,
|
|
186
|
+
function getColumnCondition(columnName) {
|
|
187
|
+
const value = item.condition[columnName];
|
|
188
|
+
const expr = {
|
|
189
|
+
exprType: 'column',
|
|
190
|
+
columnName,
|
|
191
|
+
source: {
|
|
192
|
+
name: {
|
|
193
|
+
pureName: item.pureName,
|
|
194
|
+
schemaName: item.schemaName,
|
|
200
195
|
},
|
|
196
|
+
alias,
|
|
201
197
|
},
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
198
|
+
};
|
|
199
|
+
if (value == null) {
|
|
200
|
+
return {
|
|
201
|
+
conditionType: 'isNull',
|
|
202
|
+
expr,
|
|
203
|
+
};
|
|
204
|
+
}
|
|
205
|
+
else {
|
|
206
|
+
return {
|
|
207
|
+
conditionType: 'binary',
|
|
208
|
+
operator: '=',
|
|
209
|
+
left: expr,
|
|
210
|
+
right: {
|
|
211
|
+
exprType: 'value',
|
|
212
|
+
value,
|
|
213
|
+
},
|
|
214
|
+
};
|
|
215
|
+
}
|
|
216
|
+
}
|
|
217
|
+
return {
|
|
218
|
+
conditionType: 'and',
|
|
219
|
+
conditions: lodash_1.default.keys(item.condition).map(columnName => getColumnCondition(columnName)),
|
|
207
220
|
};
|
|
208
221
|
}
|
|
209
222
|
exports.extractChangeSetCondition = extractChangeSetCondition;
|
package/lib/GridDisplay.d.ts
CHANGED
|
@@ -85,10 +85,14 @@ export declare abstract class GridDisplay {
|
|
|
85
85
|
removeFilter(uniqueName: any): void;
|
|
86
86
|
setFilters(dct: any): void;
|
|
87
87
|
setSort(uniqueName: any, order: any): void;
|
|
88
|
+
addToSort(uniqueName: any, order: any): void;
|
|
89
|
+
clearSort(): void;
|
|
88
90
|
setGrouping(uniqueName: any, groupFunc: GroupFunc): void;
|
|
89
91
|
getGrouping(uniqueName: any): GroupFunc;
|
|
90
92
|
clearGrouping(): void;
|
|
91
93
|
getSortOrder(uniqueName: any): "ASC" | "DESC";
|
|
94
|
+
getSortOrderIndex(uniqueName: any): number;
|
|
95
|
+
isSortDefined(): boolean;
|
|
92
96
|
get filterCount(): number;
|
|
93
97
|
clearFilters(): void;
|
|
94
98
|
getChangeSetCondition(row: any): Pick<any, string>;
|
|
@@ -96,6 +100,7 @@ export declare abstract class GridDisplay {
|
|
|
96
100
|
getChangeSetRow(row: any, insertedRowIndex: any): ChangeSetRowDefinition;
|
|
97
101
|
createSelect(options?: {}): Select;
|
|
98
102
|
processReferences(select: Select, displayedColumnInfo: DisplayedColumnInfo, options: any): void;
|
|
103
|
+
createColumnExpression(col: any, source: any, alias?: any): any;
|
|
99
104
|
createSelectBase(name: NamedObjectInfo, columns: ColumnInfo[], options: any): Select;
|
|
100
105
|
getRowNumberOverSelect(select: Select, offset: number, count: number): Select;
|
|
101
106
|
getPageQuery(offset: number, count: number): Select;
|
package/lib/GridDisplay.js
CHANGED
|
@@ -257,6 +257,14 @@ class GridDisplay {
|
|
|
257
257
|
this.setConfig(cfg => (Object.assign(Object.assign({}, cfg), { sort: [{ uniqueName, order }] })));
|
|
258
258
|
this.reload();
|
|
259
259
|
}
|
|
260
|
+
addToSort(uniqueName, order) {
|
|
261
|
+
this.setConfig(cfg => (Object.assign(Object.assign({}, cfg), { sort: [...(cfg.sort || []), { uniqueName, order }] })));
|
|
262
|
+
this.reload();
|
|
263
|
+
}
|
|
264
|
+
clearSort() {
|
|
265
|
+
this.setConfig(cfg => (Object.assign(Object.assign({}, cfg), { sort: [] })));
|
|
266
|
+
this.reload();
|
|
267
|
+
}
|
|
260
268
|
setGrouping(uniqueName, groupFunc) {
|
|
261
269
|
this.setConfig(cfg => (Object.assign(Object.assign({}, cfg), { grouping: groupFunc
|
|
262
270
|
? Object.assign(Object.assign({}, cfg.grouping), { [uniqueName]: groupFunc }) : lodash_1.default.omitBy(cfg.grouping, (v, k) => k == uniqueName) })));
|
|
@@ -284,6 +292,14 @@ class GridDisplay {
|
|
|
284
292
|
var _a;
|
|
285
293
|
return (_a = this.config.sort.find(x => x.uniqueName == uniqueName)) === null || _a === void 0 ? void 0 : _a.order;
|
|
286
294
|
}
|
|
295
|
+
getSortOrderIndex(uniqueName) {
|
|
296
|
+
if (this.config.sort.length <= 1)
|
|
297
|
+
return -1;
|
|
298
|
+
return lodash_1.default.findIndex(this.config.sort, x => x.uniqueName == uniqueName);
|
|
299
|
+
}
|
|
300
|
+
isSortDefined() {
|
|
301
|
+
return (this.config.sort || []).length > 0;
|
|
302
|
+
}
|
|
287
303
|
get filterCount() {
|
|
288
304
|
return lodash_1.default.compact(lodash_1.default.values(this.config.filters)).length;
|
|
289
305
|
}
|
|
@@ -323,6 +339,16 @@ class GridDisplay {
|
|
|
323
339
|
return null;
|
|
324
340
|
}
|
|
325
341
|
processReferences(select, displayedColumnInfo, options) { }
|
|
342
|
+
createColumnExpression(col, source, alias) {
|
|
343
|
+
let expr = null;
|
|
344
|
+
if (this.dialect.createColumnViewExpression) {
|
|
345
|
+
expr = this.dialect.createColumnViewExpression(col.columnName, col.dataType, source, alias);
|
|
346
|
+
if (expr) {
|
|
347
|
+
return expr;
|
|
348
|
+
}
|
|
349
|
+
}
|
|
350
|
+
return Object.assign({ exprType: 'column', alias: alias || col.columnName, source }, col);
|
|
351
|
+
}
|
|
326
352
|
createSelectBase(name, columns, options) {
|
|
327
353
|
if (!columns)
|
|
328
354
|
return null;
|
|
@@ -333,7 +359,7 @@ class GridDisplay {
|
|
|
333
359
|
name: lodash_1.default.pick(name, ['schemaName', 'pureName']),
|
|
334
360
|
alias: 'basetbl',
|
|
335
361
|
},
|
|
336
|
-
columns: columns.map(col =>
|
|
362
|
+
columns: columns.map(col => this.createColumnExpression(col, { alias: 'basetbl' })),
|
|
337
363
|
orderBy: [
|
|
338
364
|
{
|
|
339
365
|
exprType: 'column',
|
package/lib/TableGridDisplay.js
CHANGED
|
@@ -188,12 +188,7 @@ class TableGridDisplay extends GridDisplay_1.GridDisplay {
|
|
|
188
188
|
addAddedColumnsToSelect(select, columns, parentAlias, displayedColumnInfo) {
|
|
189
189
|
for (const column of columns) {
|
|
190
190
|
if (this.addAllExpandedColumnsToSelected || this.config.addedColumns.includes(column.uniqueName)) {
|
|
191
|
-
select.columns.push({
|
|
192
|
-
exprType: 'column',
|
|
193
|
-
columnName: column.columnName,
|
|
194
|
-
alias: column.uniqueName,
|
|
195
|
-
source: { name: column, alias: parentAlias },
|
|
196
|
-
});
|
|
191
|
+
select.columns.push(this.createColumnExpression(column, { name: column, alias: parentAlias }, column.uniqueName));
|
|
197
192
|
displayedColumnInfo[column.uniqueName] = Object.assign(Object.assign({}, column), { sourceAlias: parentAlias });
|
|
198
193
|
}
|
|
199
194
|
}
|
package/package.json
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
{
|
|
2
|
-
"version": "5.0.
|
|
2
|
+
"version": "5.0.4-alpha.7",
|
|
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": "^5.0.
|
|
15
|
-
"dbgate-filterparser": "^5.0.
|
|
14
|
+
"dbgate-sqltree": "^5.0.4-alpha.7",
|
|
15
|
+
"dbgate-filterparser": "^5.0.4-alpha.7"
|
|
16
16
|
},
|
|
17
17
|
"devDependencies": {
|
|
18
|
-
"dbgate-types": "^5.0.
|
|
18
|
+
"dbgate-types": "^5.0.4-alpha.7",
|
|
19
19
|
"@types/node": "^13.7.0",
|
|
20
20
|
"typescript": "^4.4.3"
|
|
21
21
|
}
|