@genesislcap/grid-pro 14.70.4-es2021.1 → 14.70.4-test.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 { __decorate } from "tslib";
1
+ import { __awaiter, __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,7 +21,8 @@ export class ActionRenderer extends FoundationElement {
21
21
  return true;
22
22
  }
23
23
  isDisabled(data) {
24
- if (typeof this.params?.isDisabled === 'function') {
24
+ var _a;
25
+ if (typeof ((_a = this.params) === null || _a === void 0 ? void 0 : _a.isDisabled) === 'function') {
25
26
  try {
26
27
  return this.params.isDisabled(data);
27
28
  }
@@ -31,14 +32,17 @@ export class ActionRenderer extends FoundationElement {
31
32
  }
32
33
  return false;
33
34
  }
34
- async clickHandler() {
35
- this.pendingAction = true;
36
- await this.params.actionClick(this.params.data);
37
- this.pendingAction = false;
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
+ });
38
41
  }
39
42
  get dataTestId() {
43
+ var _a;
40
44
  if (this.params.dataTestId) {
41
- return this.params.dataTestId + (this.params.data[this.params.uniqueFieldName] ?? '');
45
+ return this.params.dataTestId + ((_a = this.params.data[this.params.uniqueFieldName]) !== null && _a !== void 0 ? _a : '');
42
46
  }
43
47
  return undefined;
44
48
  }
@@ -94,7 +98,7 @@ export const foundationGridProActionRenderer = ActionRenderer.compose({
94
98
  class="action-renderer"
95
99
  part="action-renderer"
96
100
  data-test-id="${(x) => x.dataTestId}"
97
- ?disabled=${(x) => x.pendingAction || x.isDisabled(x.params?.data)}
101
+ ?disabled=${(x) => { var _a; return x.pendingAction || x.isDisabled((_a = x.params) === null || _a === void 0 ? void 0 : _a.data); }}
98
102
  appearance="${(x) => x.params.appearance}"
99
103
  @click=${(x) => x.clickHandler()}">${(x) => x.params.actionName}</foundation-button>
100
104
  </div>`,
@@ -93,5 +93,5 @@ export const getActionsMenuDef = (actions, overrideDef = {}, customActionsOpener
93
93
  // },
94
94
  width: 150,
95
95
  };
96
- return { ...actionsMenuDef, ...overrideDef };
96
+ return Object.assign(Object.assign({}, 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) => x.params?.changeHandler(x.params)}"
48
- checked="${(x) => x.params?.value}"
49
- readonly="${(x) => x.params?.readonly}"
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; }}"
50
50
  ></${checkboxComponent}>
51
51
  `;
52
52
  };
@@ -16,10 +16,11 @@ export class SelectRenderer extends FoundationElement {
16
16
  };
17
17
  }
18
18
  init(params) {
19
+ var _a;
19
20
  if (!params)
20
21
  return;
21
22
  this.params = params;
22
- this.value = setValueWithAccessor(params.node?.data, params.accessor) || undefined;
23
+ this.value = setValueWithAccessor((_a = params.node) === null || _a === void 0 ? void 0 : _a.data, params.accessor) || undefined;
23
24
  }
24
25
  getGui() {
25
26
  return this;
@@ -24,12 +24,13 @@ export class AgTextFieldRenderer extends FoundationElement {
24
24
  };
25
25
  }
26
26
  init(params) {
27
+ var _a;
27
28
  if (!params)
28
29
  return;
29
30
  this.params = params;
30
31
  this.textValue =
31
32
  this.textValue === ''
32
- ? setValueWithAccessor(params?.node?.data, params.accessor)
33
+ ? setValueWithAccessor((_a = params === null || params === void 0 ? void 0 : params.node) === null || _a === void 0 ? void 0 : _a.data, params.accessor)
33
34
  : this.textValue;
34
35
  }
35
36
  getGui() {
@@ -1,4 +1,4 @@
1
- import { __decorate } from "tslib";
1
+ import { __awaiter, __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,88 +29,92 @@ export class StreamDatasource {
29
29
  this.rowId = options.rowId;
30
30
  this.pagination = options.pagination;
31
31
  }
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();
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
+ }
40
48
  }
41
- else if (Object.keys(toBeAppliedFilterModel).length > 0) {
42
- this.currentFilterModel = toBeAppliedFilterModel;
43
- this.resourceParams.CRITERIA_MATCH = this.buildCriteriaMatchFromFilters();
44
- this.restartSubscription();
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
+ }
45
70
  }
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);
71
+ if (this.moreRows && params.request.startRow >= this.maxRows) {
72
+ this.connect.getMoreRows(this.streamSourceRef);
84
73
  }
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);
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
+ });
114
118
  });
115
119
  }
116
120
  // TODO: SSRM Transactions - https://www.ag-grid.com/javascript-data-grid/server-side-model-updating-transactions/
@@ -158,10 +162,11 @@ export class StreamDatasource {
158
162
  }
159
163
  }
160
164
  handleInitialStreamLoad(result) {
165
+ var _a;
161
166
  if (!result)
162
167
  return;
163
168
  const rows = new Map();
164
- result.inserts?.forEach((insertData) => {
169
+ (_a = result.inserts) === null || _a === void 0 ? void 0 : _a.forEach((insertData) => {
165
170
  rows.set(insertData.ROW_REF, insertData);
166
171
  });
167
172
  this.rowData = rows;
@@ -274,8 +279,8 @@ let GridProGenesisDatasourceNext = class GridProGenesisDatasourceNext extends Li
274
279
  onFilterChanged: (params) => { },
275
280
  onSortChanged: (params) => { }, // TODO: confirm FUI-512
276
281
  };
277
- this.agGrid.addEventListener('onGridReady', async () => {
278
- const meta = await this.connect
282
+ this.agGrid.addEventListener('onGridReady', () => __awaiter(this, void 0, void 0, function* () {
283
+ const meta = yield this.connect
279
284
  .getMetadata(this.resourceName)
280
285
  .catch((e) => logger.error(e));
281
286
  if (!meta)
@@ -285,7 +290,7 @@ let GridProGenesisDatasourceNext = class GridProGenesisDatasourceNext extends Li
285
290
  const fieldMetadata = toFieldMetadata(this.originalFieldDef);
286
291
  const agColumnDefs = this.getAgColumnDefs(fieldMetadata);
287
292
  this.agGrid.gridApi.setColumnDefs(agColumnDefs);
288
- const dataserverStream = await this.createDataserverStream();
293
+ const dataserverStream = yield this.createDataserverStream();
289
294
  this.dataserverStream = new StreamDatasource({
290
295
  stream: dataserverStream,
291
296
  resourceName: this.resourceName,
@@ -298,7 +303,7 @@ let GridProGenesisDatasourceNext = class GridProGenesisDatasourceNext extends Li
298
303
  pagination: this.pagination,
299
304
  });
300
305
  this.agGrid.gridApi.setServerSideDatasource(this.dataserverStream);
301
- }, { once: true });
306
+ }), { once: true });
302
307
  return;
303
308
  }
304
309
  logger.warn(`Application not connected, falling back to local columnDefs/rowData`);
@@ -317,16 +322,17 @@ let GridProGenesisDatasourceNext = class GridProGenesisDatasourceNext extends Li
317
322
  return this.parentElement;
318
323
  }
319
324
  clearRowData() {
320
- this.agGrid?.gridApi?.setColumnDefs([]);
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([]);
321
327
  const agTransaction = { remove: [] };
322
- this.agGrid.gridApi?.forEachNode((node) => {
328
+ (_c = this.agGrid.gridApi) === null || _c === void 0 ? void 0 : _c.forEachNode((node) => {
323
329
  agTransaction.remove.push(node.data);
324
330
  });
325
- this.agGrid.gridApi?.applyServerSideTransaction(agTransaction);
331
+ (_d = this.agGrid.gridApi) === null || _d === void 0 ? void 0 : _d.applyServerSideTransaction(agTransaction);
326
332
  }
327
333
  getResourceIndexes(avaialbleIndexes) {
328
334
  const resourceIndexesMap = new Map();
329
- avaialbleIndexes?.forEach((index) => {
335
+ avaialbleIndexes === null || avaialbleIndexes === void 0 ? void 0 : avaialbleIndexes.forEach((index) => {
330
336
  resourceIndexesMap.set(index.NAME, index.FIELDS.split(' '));
331
337
  });
332
338
  return resourceIndexesMap;
@@ -353,13 +359,16 @@ let GridProGenesisDatasourceNext = class GridProGenesisDatasourceNext extends Li
353
359
  logger.debug('Getting configured params:', params);
354
360
  return params;
355
361
  }
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);
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
+ });
360
368
  }
361
369
  getAgColumnDefs(fieldsMetadata) {
362
- const colDefsFromGenesisData = fieldsMetadata?.flatMap((field) => {
370
+ const colDefsFromGenesisData = fieldsMetadata === null || fieldsMetadata === void 0 ? void 0 : fieldsMetadata.flatMap((field) => {
371
+ var _a;
363
372
  const cellConfigs = {};
364
373
  cellConfigs.filterParams = getFilterParamsByFieldType(field.type);
365
374
  switch (field.type) {
@@ -377,21 +386,14 @@ let GridProGenesisDatasourceNext = class GridProGenesisDatasourceNext extends Li
377
386
  default:
378
387
  break;
379
388
  }
380
- const templateColDef = this.agGrid.gridApi?.getColumnDef(field.name);
389
+ const templateColDef = (_a = this.agGrid.gridApi) === null || _a === void 0 ? void 0 : _a.getColumnDef(field.name);
381
390
  if (this.agGrid.onlyTemplateColDefs && !templateColDef) {
382
391
  return [];
383
392
  }
384
393
  if (this.fields && !this.fields.includes(field.name)) {
385
394
  return [];
386
395
  }
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
- };
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);
395
397
  });
396
398
  const colDefsMergedWithTemplateDefs = this.agGrid.applyTemplateDefinitions(colDefsFromGenesisData);
397
399
  return colDefsMergedWithTemplateDefs;