@genesislcap/grid-pro 14.70.3 → 14.70.4-es2021.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.
@@ -1,4 +1,4 @@
1
- import { __awaiter, __decorate } from "tslib";
1
+ import { __decorate } from "tslib";
2
2
  import { css, html, observable } from '@microsoft/fast-element';
3
3
  import { DesignToken, FoundationElement } from '@microsoft/fast-foundation';
4
4
  import { logger } from '../utils';
@@ -21,8 +21,7 @@ export class ActionRenderer extends FoundationElement {
21
21
  return true;
22
22
  }
23
23
  isDisabled(data) {
24
- var _a;
25
- if (typeof ((_a = this.params) === null || _a === void 0 ? void 0 : _a.isDisabled) === 'function') {
24
+ if (typeof this.params?.isDisabled === 'function') {
26
25
  try {
27
26
  return this.params.isDisabled(data);
28
27
  }
@@ -32,17 +31,14 @@ export class ActionRenderer extends FoundationElement {
32
31
  }
33
32
  return false;
34
33
  }
35
- clickHandler() {
36
- return __awaiter(this, void 0, void 0, function* () {
37
- this.pendingAction = true;
38
- yield this.params.actionClick(this.params.data);
39
- this.pendingAction = false;
40
- });
34
+ async clickHandler() {
35
+ this.pendingAction = true;
36
+ await this.params.actionClick(this.params.data);
37
+ this.pendingAction = false;
41
38
  }
42
39
  get dataTestId() {
43
- var _a;
44
40
  if (this.params.dataTestId) {
45
- return this.params.dataTestId + ((_a = this.params.data[this.params.uniqueFieldName]) !== null && _a !== void 0 ? _a : '');
41
+ return this.params.dataTestId + (this.params.data[this.params.uniqueFieldName] ?? '');
46
42
  }
47
43
  return undefined;
48
44
  }
@@ -98,7 +94,7 @@ export const foundationGridProActionRenderer = ActionRenderer.compose({
98
94
  class="action-renderer"
99
95
  part="action-renderer"
100
96
  data-test-id="${(x) => x.dataTestId}"
101
- ?disabled=${(x) => { var _a; return x.pendingAction || x.isDisabled((_a = x.params) === null || _a === void 0 ? void 0 : _a.data); }}
97
+ ?disabled=${(x) => x.pendingAction || x.isDisabled(x.params?.data)}
102
98
  appearance="${(x) => x.params.appearance}"
103
99
  @click=${(x) => x.clickHandler()}">${(x) => x.params.actionName}</foundation-button>
104
100
  </div>`,
@@ -93,5 +93,5 @@ export const getActionsMenuDef = (actions, overrideDef = {}, customActionsOpener
93
93
  // },
94
94
  width: 150,
95
95
  };
96
- return Object.assign(Object.assign({}, actionsMenuDef), overrideDef);
96
+ return { ...actionsMenuDef, ...overrideDef };
97
97
  };
@@ -44,9 +44,9 @@ export const getAgBooleanRendererTemplate = (designSystem = 'foundation') => {
44
44
  const checkboxComponent = `${designSystem}-checkbox`;
45
45
  return html `
46
46
  <${checkboxComponent}
47
- @change="${(x) => { var _a; return (_a = x.params) === null || _a === void 0 ? void 0 : _a.changeHandler(x.params); }}"
48
- checked="${(x) => { var _a; return (_a = x.params) === null || _a === void 0 ? void 0 : _a.value; }}"
49
- readonly="${(x) => { var _a; return (_a = x.params) === null || _a === void 0 ? void 0 : _a.readonly; }}"
47
+ @change="${(x) => x.params?.changeHandler(x.params)}"
48
+ checked="${(x) => x.params?.value}"
49
+ readonly="${(x) => x.params?.readonly}"
50
50
  ></${checkboxComponent}>
51
51
  `;
52
52
  };
@@ -16,11 +16,10 @@ export class SelectRenderer extends FoundationElement {
16
16
  };
17
17
  }
18
18
  init(params) {
19
- var _a;
20
19
  if (!params)
21
20
  return;
22
21
  this.params = params;
23
- this.value = setValueWithAccessor((_a = params.node) === null || _a === void 0 ? void 0 : _a.data, params.accessor) || undefined;
22
+ this.value = setValueWithAccessor(params.node?.data, params.accessor) || undefined;
24
23
  }
25
24
  getGui() {
26
25
  return this;
@@ -24,13 +24,12 @@ export class AgTextFieldRenderer extends FoundationElement {
24
24
  };
25
25
  }
26
26
  init(params) {
27
- var _a;
28
27
  if (!params)
29
28
  return;
30
29
  this.params = params;
31
30
  this.textValue =
32
31
  this.textValue === ''
33
- ? setValueWithAccessor((_a = params === null || params === void 0 ? void 0 : params.node) === null || _a === void 0 ? void 0 : _a.data, params.accessor)
32
+ ? setValueWithAccessor(params?.node?.data, params.accessor)
34
33
  : this.textValue;
35
34
  }
36
35
  getGui() {
@@ -1,4 +1,4 @@
1
- import { __awaiter, __decorate } from "tslib";
1
+ import { __decorate } from "tslib";
2
2
  import { Connect, dataServerResultFilter, DatasourceDefaults, extractFieldDefinitions, FieldTypeEnum, MessageType, normaliseCriteria, toFieldMetadata, } from '@genesislcap/foundation-comms';
3
3
  import { LifecycleMixin } from '@genesislcap/foundation-utils';
4
4
  import { attr, customElement, DOM } from '@microsoft/fast-element';
@@ -29,92 +29,88 @@ export class StreamDatasource {
29
29
  this.rowId = options.rowId;
30
30
  this.pagination = options.pagination;
31
31
  }
32
- getRows(params) {
33
- var _a;
34
- return __awaiter(this, void 0, void 0, function* () {
35
- const toBeAppliedFilterModel = params.request.filterModel;
36
- if (JSON.stringify(toBeAppliedFilterModel) !== JSON.stringify(this.currentFilterModel) ||
37
- Object.keys(toBeAppliedFilterModel).length > 0) {
38
- if (Object.keys(toBeAppliedFilterModel).length === 0 && this.currentFilterModel) {
39
- this.currentFilterModel = null;
40
- this.resourceParams.CRITERIA_MATCH = this.originalCriteriaMatch;
41
- this.restartSubscription();
42
- }
43
- else if (Object.keys(toBeAppliedFilterModel).length > 0) {
44
- this.currentFilterModel = toBeAppliedFilterModel;
45
- this.resourceParams.CRITERIA_MATCH = this.buildCriteriaMatchFromFilters();
46
- this.restartSubscription();
47
- }
32
+ async getRows(params) {
33
+ const toBeAppliedFilterModel = params.request.filterModel;
34
+ if (JSON.stringify(toBeAppliedFilterModel) !== JSON.stringify(this.currentFilterModel) ||
35
+ Object.keys(toBeAppliedFilterModel).length > 0) {
36
+ if (Object.keys(toBeAppliedFilterModel).length === 0 && this.currentFilterModel) {
37
+ this.currentFilterModel = null;
38
+ this.resourceParams.CRITERIA_MATCH = this.originalCriteriaMatch;
39
+ this.restartSubscription();
48
40
  }
49
- const toBeAppliedSortModel = params.request.sortModel;
50
- if (toBeAppliedSortModel.length !== ((_a = this.currentSortModel) === null || _a === void 0 ? void 0 : _a.length) ||
51
- toBeAppliedSortModel.length > 0) {
52
- if (toBeAppliedSortModel.length === 0 && this.currentSortModel) {
53
- this.currentSortModel = null;
54
- this.resourceParams.ORDER_BY = null;
55
- this.resourceParams.REVERSE = null;
56
- this.restartSubscription();
57
- }
58
- else if (toBeAppliedSortModel.length > 0) {
59
- this.currentSortModel = toBeAppliedSortModel;
60
- const coldIdBeingSorted = this.currentSortModel[0].colId; // Not allowing multiple sorts by user
61
- const sortTypeBeingApplied = this.currentSortModel[0].sort;
62
- const orderByAndToBeSortedColIds = this.getOrderByAndToBeSortedColIds(this.resourceIndexes, coldIdBeingSorted);
63
- orderByAndToBeSortedColIds.toBeSorted.forEach((colId) => {
64
- this.currentSortModel.push({ sort: sortTypeBeingApplied, colId });
65
- });
66
- this.resourceParams.ORDER_BY = orderByAndToBeSortedColIds.orderBy;
67
- this.resourceParams.REVERSE = sortTypeBeingApplied === 'desc' ? true : false;
68
- this.restartSubscription();
69
- }
41
+ else if (Object.keys(toBeAppliedFilterModel).length > 0) {
42
+ this.currentFilterModel = toBeAppliedFilterModel;
43
+ this.resourceParams.CRITERIA_MATCH = this.buildCriteriaMatchFromFilters();
44
+ this.restartSubscription();
70
45
  }
71
- if (this.moreRows && params.request.startRow >= this.maxRows) {
72
- this.connect.getMoreRows(this.streamSourceRef);
46
+ }
47
+ const toBeAppliedSortModel = params.request.sortModel;
48
+ if (toBeAppliedSortModel.length !== this.currentSortModel?.length ||
49
+ toBeAppliedSortModel.length > 0) {
50
+ if (toBeAppliedSortModel.length === 0 && this.currentSortModel) {
51
+ this.currentSortModel = null;
52
+ this.resourceParams.ORDER_BY = null;
53
+ this.resourceParams.REVERSE = null;
54
+ this.restartSubscription();
55
+ }
56
+ else if (toBeAppliedSortModel.length > 0) {
57
+ this.currentSortModel = toBeAppliedSortModel;
58
+ const coldIdBeingSorted = this.currentSortModel[0].colId; // Not allowing multiple sorts by user
59
+ const sortTypeBeingApplied = this.currentSortModel[0].sort;
60
+ const orderByAndToBeSortedColIds = this.getOrderByAndToBeSortedColIds(this.resourceIndexes, coldIdBeingSorted);
61
+ orderByAndToBeSortedColIds.toBeSorted.forEach((colId) => {
62
+ this.currentSortModel.push({ sort: sortTypeBeingApplied, colId });
63
+ });
64
+ this.resourceParams.ORDER_BY = orderByAndToBeSortedColIds.orderBy;
65
+ this.resourceParams.REVERSE = sortTypeBeingApplied === 'desc' ? true : false;
66
+ this.restartSubscription();
67
+ }
68
+ }
69
+ if (this.moreRows && params.request.startRow >= this.maxRows) {
70
+ this.connect.getMoreRows(this.streamSourceRef);
71
+ }
72
+ // TODO: take(1) is temporary, won't have to do this once SSRM Transactions are implemented
73
+ this.dataserverStream.pipe(take(1)).subscribe((result) => {
74
+ const messageType = result.MESSAGE_TYPE;
75
+ if (messageType &&
76
+ (messageType === MessageType.LOGOFF_ACK || messageType === MessageType.MSG_NACK)) {
77
+ params.fail();
78
+ return;
79
+ }
80
+ this.moreRows = result.MORE_ROWS;
81
+ if (result.ROW) {
82
+ const nextMessage = dataServerResultFilter(result);
83
+ this.handleInitialStreamLoad(nextMessage);
73
84
  }
74
- // TODO: take(1) is temporary, won't have to do this once SSRM Transactions are implemented
75
- this.dataserverStream.pipe(take(1)).subscribe((result) => {
76
- var _a, _b;
77
- const messageType = result.MESSAGE_TYPE;
78
- if (messageType &&
79
- (messageType === MessageType.LOGOFF_ACK || messageType === MessageType.MSG_NACK)) {
80
- params.fail();
81
- return;
82
- }
83
- this.moreRows = result.MORE_ROWS;
84
- if (result.ROW) {
85
- const nextMessage = dataServerResultFilter(result);
86
- this.handleInitialStreamLoad(nextMessage);
87
- }
88
- // TODO: SSRM Transactions - https://www.ag-grid.com/javascript-data-grid/server-side-model-updating-transactions/
89
- // if (messageType === MessageType.QUERY_UPDATE) {
90
- // if (result.ROW) {
91
- // const nextMessage = dataServerResultFilter(result);
92
- // this.agTransaction = { add: [], remove: [], update: [] };
93
- // this.handleStreamInserts(nextMessage.inserts);
94
- // this.handleStreamDeletes(nextMessage.deletes);
95
- // this.handleStreamUpdates(nextMessage.updates);
96
- // params.api.applyServerSideTransactionAsync(this.agTransaction);
97
- // }
98
- // }
99
- this.lastSequenceId = result.SEQUENCE_ID;
100
- if (this.lastSequenceId === 1) {
101
- this.streamSourceRef = result.SOURCE_REF;
102
- this.rowCount = (_a = result.ROWS_COUNT) !== null && _a !== void 0 ? _a : this.rowData.size;
103
- }
104
- this.calculatedRowsCount += (_b = this.rowData.size) !== null && _b !== void 0 ? _b : 0;
105
- const successRowData = { rowData: Array.from(this.rowData.values()) };
106
- if (this.pagination) {
107
- successRowData.rowCount = Math.min(this.rowCount, this.maxView);
108
- }
109
- if (params.request.endRow > this.maxView ||
110
- params.request.endRow > this.calculatedRowsCount) {
111
- successRowData.rowCount = this.calculatedRowsCount;
112
- }
113
- else if (params.request.endRow === this.rowCount) {
114
- successRowData.rowCount = this.rowCount;
115
- }
116
- params.success(successRowData);
117
- });
85
+ // TODO: SSRM Transactions - https://www.ag-grid.com/javascript-data-grid/server-side-model-updating-transactions/
86
+ // if (messageType === MessageType.QUERY_UPDATE) {
87
+ // if (result.ROW) {
88
+ // const nextMessage = dataServerResultFilter(result);
89
+ // this.agTransaction = { add: [], remove: [], update: [] };
90
+ // this.handleStreamInserts(nextMessage.inserts);
91
+ // this.handleStreamDeletes(nextMessage.deletes);
92
+ // this.handleStreamUpdates(nextMessage.updates);
93
+ // params.api.applyServerSideTransactionAsync(this.agTransaction);
94
+ // }
95
+ // }
96
+ this.lastSequenceId = result.SEQUENCE_ID;
97
+ if (this.lastSequenceId === 1) {
98
+ this.streamSourceRef = result.SOURCE_REF;
99
+ this.rowCount = result.ROWS_COUNT ?? this.rowData.size;
100
+ }
101
+ this.calculatedRowsCount += this.rowData.size ?? 0;
102
+ const successRowData = { rowData: Array.from(this.rowData.values()) };
103
+ if (this.pagination) {
104
+ successRowData.rowCount = Math.min(this.rowCount, this.maxView);
105
+ }
106
+ if (params.request.endRow > this.maxView ||
107
+ params.request.endRow > this.calculatedRowsCount) {
108
+ successRowData.rowCount = this.calculatedRowsCount;
109
+ }
110
+ else if (params.request.endRow === this.rowCount) {
111
+ successRowData.rowCount = this.rowCount;
112
+ }
113
+ params.success(successRowData);
118
114
  });
119
115
  }
120
116
  // TODO: SSRM Transactions - https://www.ag-grid.com/javascript-data-grid/server-side-model-updating-transactions/
@@ -162,11 +158,10 @@ export class StreamDatasource {
162
158
  }
163
159
  }
164
160
  handleInitialStreamLoad(result) {
165
- var _a;
166
161
  if (!result)
167
162
  return;
168
163
  const rows = new Map();
169
- (_a = result.inserts) === null || _a === void 0 ? void 0 : _a.forEach((insertData) => {
164
+ result.inserts?.forEach((insertData) => {
170
165
  rows.set(insertData.ROW_REF, insertData);
171
166
  });
172
167
  this.rowData = rows;
@@ -279,8 +274,8 @@ let GridProGenesisDatasourceNext = class GridProGenesisDatasourceNext extends Li
279
274
  onFilterChanged: (params) => { },
280
275
  onSortChanged: (params) => { }, // TODO: confirm FUI-512
281
276
  };
282
- this.agGrid.addEventListener('onGridReady', () => __awaiter(this, void 0, void 0, function* () {
283
- const meta = yield this.connect
277
+ this.agGrid.addEventListener('onGridReady', async () => {
278
+ const meta = await this.connect
284
279
  .getMetadata(this.resourceName)
285
280
  .catch((e) => logger.error(e));
286
281
  if (!meta)
@@ -290,7 +285,7 @@ let GridProGenesisDatasourceNext = class GridProGenesisDatasourceNext extends Li
290
285
  const fieldMetadata = toFieldMetadata(this.originalFieldDef);
291
286
  const agColumnDefs = this.getAgColumnDefs(fieldMetadata);
292
287
  this.agGrid.gridApi.setColumnDefs(agColumnDefs);
293
- const dataserverStream = yield this.createDataserverStream();
288
+ const dataserverStream = await this.createDataserverStream();
294
289
  this.dataserverStream = new StreamDatasource({
295
290
  stream: dataserverStream,
296
291
  resourceName: this.resourceName,
@@ -303,7 +298,7 @@ let GridProGenesisDatasourceNext = class GridProGenesisDatasourceNext extends Li
303
298
  pagination: this.pagination,
304
299
  });
305
300
  this.agGrid.gridApi.setServerSideDatasource(this.dataserverStream);
306
- }), { once: true });
301
+ }, { once: true });
307
302
  return;
308
303
  }
309
304
  logger.warn(`Application not connected, falling back to local columnDefs/rowData`);
@@ -322,17 +317,16 @@ let GridProGenesisDatasourceNext = class GridProGenesisDatasourceNext extends Li
322
317
  return this.parentElement;
323
318
  }
324
319
  clearRowData() {
325
- var _a, _b, _c, _d;
326
- (_b = (_a = this.agGrid) === null || _a === void 0 ? void 0 : _a.gridApi) === null || _b === void 0 ? void 0 : _b.setColumnDefs([]);
320
+ this.agGrid?.gridApi?.setColumnDefs([]);
327
321
  const agTransaction = { remove: [] };
328
- (_c = this.agGrid.gridApi) === null || _c === void 0 ? void 0 : _c.forEachNode((node) => {
322
+ this.agGrid.gridApi?.forEachNode((node) => {
329
323
  agTransaction.remove.push(node.data);
330
324
  });
331
- (_d = this.agGrid.gridApi) === null || _d === void 0 ? void 0 : _d.applyServerSideTransaction(agTransaction);
325
+ this.agGrid.gridApi?.applyServerSideTransaction(agTransaction);
332
326
  }
333
327
  getResourceIndexes(avaialbleIndexes) {
334
328
  const resourceIndexesMap = new Map();
335
- avaialbleIndexes === null || avaialbleIndexes === void 0 ? void 0 : avaialbleIndexes.forEach((index) => {
329
+ avaialbleIndexes?.forEach((index) => {
336
330
  resourceIndexesMap.set(index.NAME, index.FIELDS.split(' '));
337
331
  });
338
332
  return resourceIndexesMap;
@@ -359,16 +353,13 @@ let GridProGenesisDatasourceNext = class GridProGenesisDatasourceNext extends Li
359
353
  logger.debug('Getting configured params:', params);
360
354
  return params;
361
355
  }
362
- createDataserverStream(existingParams = null) {
363
- return __awaiter(this, void 0, void 0, function* () {
364
- const streamOnMessage = (message) => logger.debug(message);
365
- const onError = (error) => logger.error(error);
366
- return this.connect.stream(this.resourceName, streamOnMessage, onError, existingParams !== null && existingParams !== void 0 ? existingParams : this.params);
367
- });
356
+ async createDataserverStream(existingParams = null) {
357
+ const streamOnMessage = (message) => logger.debug(message);
358
+ const onError = (error) => logger.error(error);
359
+ return this.connect.stream(this.resourceName, streamOnMessage, onError, existingParams ?? this.params);
368
360
  }
369
361
  getAgColumnDefs(fieldsMetadata) {
370
- const colDefsFromGenesisData = fieldsMetadata === null || fieldsMetadata === void 0 ? void 0 : fieldsMetadata.flatMap((field) => {
371
- var _a;
362
+ const colDefsFromGenesisData = fieldsMetadata?.flatMap((field) => {
372
363
  const cellConfigs = {};
373
364
  cellConfigs.filterParams = getFilterParamsByFieldType(field.type);
374
365
  switch (field.type) {
@@ -386,14 +377,21 @@ let GridProGenesisDatasourceNext = class GridProGenesisDatasourceNext extends Li
386
377
  default:
387
378
  break;
388
379
  }
389
- const templateColDef = (_a = this.agGrid.gridApi) === null || _a === void 0 ? void 0 : _a.getColumnDef(field.name);
380
+ const templateColDef = this.agGrid.gridApi?.getColumnDef(field.name);
390
381
  if (this.agGrid.onlyTemplateColDefs && !templateColDef) {
391
382
  return [];
392
383
  }
393
384
  if (this.fields && !this.fields.includes(field.name)) {
394
385
  return [];
395
386
  }
396
- return Object.assign(Object.assign({ field: field.name, type: getColumnType(field.type), filter: getFilterByFieldType(field.type), sortable: [].concat(...this.indexes.values()).includes(field.name) }, cellConfigs), templateColDef);
387
+ return {
388
+ field: field.name,
389
+ type: getColumnType(field.type),
390
+ filter: getFilterByFieldType(field.type),
391
+ sortable: [].concat(...this.indexes.values()).includes(field.name),
392
+ ...cellConfigs,
393
+ ...templateColDef,
394
+ };
397
395
  });
398
396
  const colDefsMergedWithTemplateDefs = this.agGrid.applyTemplateDefinitions(colDefsFromGenesisData);
399
397
  return colDefsMergedWithTemplateDefs;