dbgate-datalib 4.4.3 → 4.4.4

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.
@@ -1,6 +1,10 @@
1
1
  "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
2
5
  Object.defineProperty(exports, "__esModule", { value: true });
3
6
  exports.FreeTableGridDisplay = void 0;
7
+ const lodash_1 = __importDefault(require("lodash"));
4
8
  const GridDisplay_1 = require("./GridDisplay");
5
9
  const _1 = require(".");
6
10
  class FreeTableGridDisplay extends GridDisplay_1.GridDisplay {
@@ -16,7 +20,7 @@ class FreeTableGridDisplay extends GridDisplay_1.GridDisplay {
16
20
  }
17
21
  getDisplayColumns(model) {
18
22
  var _a, _b, _c;
19
- return (((_c = (_b = (_a = model === null || model === void 0 ? void 0 : model.structure) === null || _a === void 0 ? void 0 : _a.columns) === null || _b === void 0 ? void 0 : _b.map(col => this.getDisplayColumn(col))) === null || _c === void 0 ? void 0 : _c.map(col => (Object.assign(Object.assign({}, col), { isChecked: this.isColumnChecked(col) })))) || []);
23
+ return lodash_1.default.uniqBy(((_c = (_b = (_a = model === null || model === void 0 ? void 0 : model.structure) === null || _a === void 0 ? void 0 : _a.columns) === null || _b === void 0 ? void 0 : _b.map(col => this.getDisplayColumn(col))) === null || _c === void 0 ? void 0 : _c.map(col => (Object.assign(Object.assign({}, col), { isChecked: this.isColumnChecked(col) })))) || [], col => col.uniqueName);
20
24
  }
21
25
  getDisplayColumn(col) {
22
26
  const uniquePath = [col.columnName];
@@ -1,5 +1,5 @@
1
1
  import { GridConfig, GridCache, GridConfigColumns, GroupFunc } from './GridConfig';
2
- import { ForeignKeyInfo, TableInfo, ColumnInfo, EngineDriver, NamedObjectInfo, DatabaseInfo, CollectionInfo, SqlDialect } from 'dbgate-types';
2
+ import { ForeignKeyInfo, TableInfo, ColumnInfo, EngineDriver, NamedObjectInfo, DatabaseInfo, CollectionInfo, SqlDialect, ViewInfo } from 'dbgate-types';
3
3
  import { ChangeSetFieldDefinition, ChangeSetRowDefinition } from './ChangeSet';
4
4
  import { Select, Condition } from 'dbgate-sqltree';
5
5
  export interface DisplayColumn {
@@ -40,8 +40,11 @@ export declare abstract class GridDisplay {
40
40
  dialect: SqlDialect;
41
41
  columns: DisplayColumn[];
42
42
  baseTable?: TableInfo;
43
+ baseView?: ViewInfo;
43
44
  baseCollection?: CollectionInfo;
45
+ get baseTableOrSimilar(): NamedObjectInfo;
44
46
  get baseTableOrCollection(): NamedObjectInfo;
47
+ get baseTableOrView(): TableInfo | ViewInfo;
45
48
  changeSetKeyFields: string[];
46
49
  sortable: boolean;
47
50
  groupable: boolean;
@@ -29,9 +29,15 @@ class GridDisplay {
29
29
  this.isDynamicStructure = false;
30
30
  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);
31
31
  }
32
+ get baseTableOrSimilar() {
33
+ return this.baseTable || this.baseCollection || this.baseView;
34
+ }
32
35
  get baseTableOrCollection() {
33
36
  return this.baseTable || this.baseCollection;
34
37
  }
38
+ get baseTableOrView() {
39
+ return this.baseTable || this.baseView;
40
+ }
35
41
  setColumnVisibility(uniquePath, isVisible) {
36
42
  const uniqueName = uniquePath.join('.');
37
43
  if (uniquePath.length == 1) {
@@ -252,10 +258,11 @@ class GridDisplay {
252
258
  this.reload();
253
259
  }
254
260
  getGrouping(uniqueName) {
261
+ var _a, _b;
255
262
  if (this.isGrouped) {
256
263
  if (this.config.grouping[uniqueName])
257
264
  return this.config.grouping[uniqueName];
258
- const column = this.baseTable.columns.find(x => x.columnName == uniqueName);
265
+ const column = (_b = (_a = (this.baseTable || this.baseView)) === null || _a === void 0 ? void 0 : _a.columns) === null || _b === void 0 ? void 0 : _b.find(x => x.columnName == uniqueName);
259
266
  if ((0, dbgate_tools_2.isTypeLogical)(column === null || column === void 0 ? void 0 : column.dataType))
260
267
  return 'COUNT DISTINCT';
261
268
  if (column === null || column === void 0 ? void 0 : column.autoIncrement)
@@ -288,21 +295,21 @@ class GridDisplay {
288
295
  const col = this.columns.find(x => x.uniqueName == uniqueName);
289
296
  if (!col)
290
297
  return null;
291
- const baseTableOrCollection = this.baseTableOrCollection;
292
- if (!baseTableOrCollection)
298
+ const baseObj = this.baseTableOrSimilar;
299
+ if (!baseObj)
293
300
  return null;
294
- if (baseTableOrCollection.pureName != col.pureName || baseTableOrCollection.schemaName != col.schemaName) {
301
+ if (baseObj.pureName != col.pureName || baseObj.schemaName != col.schemaName) {
295
302
  return null;
296
303
  }
297
304
  return Object.assign(Object.assign({}, this.getChangeSetRow(row, insertedRowIndex)), { uniqueName: uniqueName, columnName: col.columnName });
298
305
  }
299
306
  getChangeSetRow(row, insertedRowIndex) {
300
- const baseTableOrCollection = this.baseTableOrCollection;
301
- if (!baseTableOrCollection)
307
+ const baseObj = this.baseTableOrSimilar;
308
+ if (!baseObj)
302
309
  return null;
303
310
  return {
304
- pureName: baseTableOrCollection.pureName,
305
- schemaName: baseTableOrCollection.schemaName,
311
+ pureName: baseObj.pureName,
312
+ schemaName: baseObj.schemaName,
306
313
  insertedRowIndex,
307
314
  condition: insertedRowIndex == null ? this.getChangeSetCondition(row) : null,
308
315
  };
@@ -1,6 +1,10 @@
1
1
  "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
2
5
  Object.defineProperty(exports, "__esModule", { value: true });
3
6
  exports.JslGridDisplay = void 0;
7
+ const lodash_1 = __importDefault(require("lodash"));
4
8
  const GridDisplay_1 = require("./GridDisplay");
5
9
  const CollectionGridDisplay_1 = require("./CollectionGridDisplay");
6
10
  class JslGridDisplay extends GridDisplay_1.GridDisplay {
@@ -9,7 +13,7 @@ class JslGridDisplay extends GridDisplay_1.GridDisplay {
9
13
  super(config, setConfig, cache, setCache, null);
10
14
  this.filterable = true;
11
15
  if (structure.columns) {
12
- this.columns = (_a = structure.columns
16
+ this.columns = lodash_1.default.uniqBy((_a = structure.columns
13
17
  .map(col => ({
14
18
  columnName: col.columnName,
15
19
  headerText: col.columnName,
@@ -19,7 +23,7 @@ class JslGridDisplay extends GridDisplay_1.GridDisplay {
19
23
  autoIncrement: col.autoIncrement,
20
24
  pureName: null,
21
25
  schemaName: null,
22
- }))) === null || _a === void 0 ? void 0 : _a.map(col => (Object.assign(Object.assign({}, col), { isChecked: this.isColumnChecked(col) })));
26
+ }))) === null || _a === void 0 ? void 0 : _a.map(col => (Object.assign(Object.assign({}, col), { isChecked: this.isColumnChecked(col) }))), col => col.uniqueName);
23
27
  }
24
28
  if (structure.__isDynamicStructure) {
25
29
  this.columns = (0, CollectionGridDisplay_1.analyseCollectionDisplayColumns)(rows, this);
@@ -9,9 +9,10 @@ class ViewGridDisplay extends GridDisplay_1.GridDisplay {
9
9
  this.columns = this.getDisplayColumns(view);
10
10
  this.filterable = true;
11
11
  this.sortable = true;
12
- this.groupable = true;
12
+ this.groupable = false;
13
13
  this.editable = false;
14
14
  this.supportsReload = true;
15
+ this.baseView = view;
15
16
  }
16
17
  getDisplayColumns(view) {
17
18
  var _a, _b;
package/package.json CHANGED
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "4.4.3",
2
+ "version": "4.4.4",
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.4.3",
15
- "dbgate-filterparser": "^4.4.3"
14
+ "dbgate-sqltree": "^4.4.4",
15
+ "dbgate-filterparser": "^4.4.4"
16
16
  },
17
17
  "devDependencies": {
18
- "dbgate-types": "^4.4.3",
18
+ "dbgate-types": "^4.4.4",
19
19
  "@types/node": "^13.7.0",
20
20
  "typescript": "^4.4.3"
21
21
  }