@skyux/ag-grid 4.12.0 → 4.12.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.
@@ -7,7 +7,7 @@ import { SkyDataManagerService, SkyDataManagerModule } from '@skyux/data-manager
7
7
  import { SkyInlineDeleteModule } from '@skyux/layout';
8
8
  import { SkyLibResourcesService, getStringForLocale, SKY_LIB_RESOURCES_PROVIDERS, SkyI18nModule } from '@skyux/i18n';
9
9
  import { Subject } from 'rxjs';
10
- import { takeUntil } from 'rxjs/operators';
10
+ import { takeUntil, filter } from 'rxjs/operators';
11
11
  import { SkyThemeService } from '@skyux/theme';
12
12
  import { PopupComponent, RowNode, Events } from 'ag-grid-community';
13
13
  import { FormGroup, FormControl, FormsModule, ReactiveFormsModule } from '@angular/forms';
@@ -680,6 +680,7 @@ function getValidatorCellRendererSelector(component, fallback) {
680
680
  return fallback;
681
681
  };
682
682
  }
683
+ var rowNodeId = -1;
683
684
  /**
684
685
  * A service that provides default styling and behavior for agGrids in SKY UX SPAs.
685
686
  */
@@ -831,6 +832,20 @@ var SkyAgGridService = /** @class */ (function () {
831
832
  'sky-ag-grid-cell-renderer-currency-validator': SkyAgGridCellRendererCurrencyValidatorComponent,
832
833
  'sky-ag-grid-cell-renderer-validator-tooltip': SkyAgGridCellRendererValidatorTooltipComponent
833
834
  },
835
+ getRowNodeId: function (data) {
836
+ if ('id' in data && data.id !== undefined) {
837
+ return "" + data.id;
838
+ }
839
+ return "" + rowNodeId--;
840
+ },
841
+ getRowClass: function (params) {
842
+ if (params.node.id) {
843
+ return "sky-ag-grid-row-" + params.node.id;
844
+ }
845
+ else {
846
+ return undefined;
847
+ }
848
+ },
834
849
  headerHeight: ((_p = (_o = this.currentTheme) === null || _o === void 0 ? void 0 : _o.theme) === null || _p === void 0 ? void 0 : _p.name) === 'modern' ? 60 : 37,
835
850
  icons: {
836
851
  sortDescending: this.getIconTemplate('caret-down'),
@@ -1283,13 +1298,30 @@ var SkyAgGridDataManagerAdapterDirective = /** @class */ (function () {
1283
1298
  agGrid.api.sizeColumnsToFit();
1284
1299
  });
1285
1300
  agGrid.columnMoved
1301
+ .pipe(takeUntil(this.ngUnsubscribe), filter(function (event) {
1302
+ return ![
1303
+ 'gridInitializing',
1304
+ 'uiColumnResized',
1305
+ 'uiColumnDragged',
1306
+ 'api'
1307
+ ].includes(event.source);
1308
+ }))
1309
+ .subscribe(function (value) {
1310
+ _this.updateColumnsInCurrentDataState(value.columnApi);
1311
+ });
1312
+ var currentColumns;
1313
+ agGrid.dragStarted
1286
1314
  .pipe(takeUntil(this.ngUnsubscribe))
1287
- .subscribe(function (event) {
1288
- var columnOrder = agGrid.columnApi.getAllDisplayedVirtualColumns().map(function (col) { return col.getColDef().colId; });
1289
- if (event.source !== 'api') {
1290
- var viewState = _this.currentDataState.getViewStateById(_this.viewConfig.id);
1291
- viewState.displayedColumnIds = columnOrder;
1292
- _this.dataManagerSvc.updateDataState(_this.currentDataState.addOrUpdateView(_this.viewConfig.id, viewState), _this.viewConfig.id);
1315
+ .subscribe(function (value) {
1316
+ currentColumns = _this.getColumnOrder(value.columnApi);
1317
+ });
1318
+ agGrid.dragStopped
1319
+ .pipe(takeUntil(this.ngUnsubscribe))
1320
+ .subscribe(function (value) {
1321
+ var newColumns = _this.getColumnOrder(value.columnApi);
1322
+ var hasChanged = currentColumns.findIndex(function (colId, i) { return colId !== newColumns[i]; });
1323
+ if (hasChanged > -1) {
1324
+ _this.updateColumnsInCurrentDataState(value.columnApi);
1293
1325
  }
1294
1326
  });
1295
1327
  agGrid.rowSelected
@@ -1333,6 +1365,17 @@ var SkyAgGridDataManagerAdapterDirective = /** @class */ (function () {
1333
1365
  _this.dataManagerSvc.updateDataState(_this.currentDataState, _this.viewConfig.id);
1334
1366
  });
1335
1367
  };
1368
+ SkyAgGridDataManagerAdapterDirective.prototype.updateColumnsInCurrentDataState = function (columnApi) {
1369
+ var columnOrder = this.getColumnOrder(columnApi);
1370
+ var viewState = this.currentDataState.getViewStateById(this.viewConfig.id);
1371
+ viewState.displayedColumnIds = columnOrder;
1372
+ this.dataManagerSvc.updateDataState(this.currentDataState.addOrUpdateView(this.viewConfig.id, viewState), this.viewConfig.id);
1373
+ };
1374
+ SkyAgGridDataManagerAdapterDirective.prototype.getColumnOrder = function (columnApi) {
1375
+ return columnApi
1376
+ .getAllDisplayedVirtualColumns()
1377
+ .map(function (col) { return col.getColDef().colId; });
1378
+ };
1336
1379
  SkyAgGridDataManagerAdapterDirective.prototype.displayColumns = function (dataState) {
1337
1380
  var e_1, _a;
1338
1381
  var agGrid = this.currentAgGrid;
@@ -1434,7 +1477,7 @@ var SkyAgGridCellValidatorTooltipComponent = /** @class */ (function () {
1434
1477
  var _this = this;
1435
1478
  this.zone.run(function () {
1436
1479
  _this.indicatorShouldShow = false;
1437
- _this.changeDetector.markForCheck();
1480
+ _this.changeDetector.detectChanges();
1438
1481
  });
1439
1482
  };
1440
1483
  SkyAgGridCellValidatorTooltipComponent.prototype.hidePopover = function () {
@@ -1444,7 +1487,7 @@ var SkyAgGridCellValidatorTooltipComponent = /** @class */ (function () {
1444
1487
  var _this = this;
1445
1488
  this.zone.run(function () {
1446
1489
  _this.indicatorShouldShow = true;
1447
- _this.changeDetector.markForCheck();
1490
+ _this.changeDetector.detectChanges();
1448
1491
  });
1449
1492
  };
1450
1493
  SkyAgGridCellValidatorTooltipComponent.prototype.showPopover = function () {
@@ -1723,7 +1766,7 @@ var SkyAgGridRowDeleteDirective = /** @class */ (function () {
1723
1766
  return this.rowDeleteConfigs.find(function (rowDelete) { return rowDelete.id === row.id; });
1724
1767
  };
1725
1768
  SkyAgGridRowDeleteDirective.prototype.affixToRow = function (affixer, id) {
1726
- var rowElement = this.elementRef.nativeElement.querySelector('[row-id="' + id + '"] div[aria-colindex="1"]');
1769
+ var rowElement = this.elementRef.nativeElement.querySelector("\n [row-id=\"" + id + "\"] div[aria-colindex=\"1\"],\n .ag-row.sky-ag-grid-row-" + id + " div[aria-colindex=\"1\"]\n ");
1727
1770
  // This covers cases where AG Grid places the column index on an inner element (such as with the `enableCellTextSelection` option)
1728
1771
  // This appears to have been fixed by AG Grid in version 24 and so it is not testable after that version.
1729
1772
  /* istanbul ignore if */