dbgate-datalib 5.0.2 → 5.0.3
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 +4 -0
- package/lib/GridDisplay.js +16 -0
- 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>;
|
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
|
}
|
package/package.json
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
{
|
|
2
|
-
"version": "5.0.
|
|
2
|
+
"version": "5.0.3",
|
|
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.3",
|
|
15
|
+
"dbgate-filterparser": "^5.0.3"
|
|
16
16
|
},
|
|
17
17
|
"devDependencies": {
|
|
18
|
-
"dbgate-types": "^5.0.
|
|
18
|
+
"dbgate-types": "^5.0.3",
|
|
19
19
|
"@types/node": "^13.7.0",
|
|
20
20
|
"typescript": "^4.4.3"
|
|
21
21
|
}
|