@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';
@@ -648,6 +648,7 @@ function getValidatorCellRendererSelector(component, fallback) {
648
648
  return fallback;
649
649
  };
650
650
  }
651
+ let rowNodeId = -1;
651
652
  /**
652
653
  * A service that provides default styling and behavior for agGrids in SKY UX SPAs.
653
654
  */
@@ -796,6 +797,20 @@ let SkyAgGridService = class SkyAgGridService {
796
797
  'sky-ag-grid-cell-renderer-currency-validator': SkyAgGridCellRendererCurrencyValidatorComponent,
797
798
  'sky-ag-grid-cell-renderer-validator-tooltip': SkyAgGridCellRendererValidatorTooltipComponent
798
799
  },
800
+ getRowNodeId(data) {
801
+ if ('id' in data && data.id !== undefined) {
802
+ return `${data.id}`;
803
+ }
804
+ return `${rowNodeId--}`;
805
+ },
806
+ getRowClass: (params) => {
807
+ if (params.node.id) {
808
+ return `sky-ag-grid-row-${params.node.id}`;
809
+ }
810
+ else {
811
+ return undefined;
812
+ }
813
+ },
799
814
  headerHeight: ((_d = (_c = this.currentTheme) === null || _c === void 0 ? void 0 : _c.theme) === null || _d === void 0 ? void 0 : _d.name) === 'modern' ? 60 : 37,
800
815
  icons: {
801
816
  sortDescending: this.getIconTemplate('caret-down'),
@@ -1209,13 +1224,28 @@ let SkyAgGridDataManagerAdapterDirective = class SkyAgGridDataManagerAdapterDire
1209
1224
  agGrid.api.sizeColumnsToFit();
1210
1225
  });
1211
1226
  agGrid.columnMoved
1227
+ .pipe(takeUntil(this.ngUnsubscribe), filter((event) => ![
1228
+ 'gridInitializing',
1229
+ 'uiColumnResized',
1230
+ 'uiColumnDragged',
1231
+ 'api'
1232
+ ].includes(event.source)))
1233
+ .subscribe((value) => {
1234
+ this.updateColumnsInCurrentDataState(value.columnApi);
1235
+ });
1236
+ let currentColumns;
1237
+ agGrid.dragStarted
1212
1238
  .pipe(takeUntil(this.ngUnsubscribe))
1213
- .subscribe((event) => {
1214
- let columnOrder = agGrid.columnApi.getAllDisplayedVirtualColumns().map(col => col.getColDef().colId);
1215
- if (event.source !== 'api') {
1216
- const viewState = this.currentDataState.getViewStateById(this.viewConfig.id);
1217
- viewState.displayedColumnIds = columnOrder;
1218
- this.dataManagerSvc.updateDataState(this.currentDataState.addOrUpdateView(this.viewConfig.id, viewState), this.viewConfig.id);
1239
+ .subscribe((value) => {
1240
+ currentColumns = this.getColumnOrder(value.columnApi);
1241
+ });
1242
+ agGrid.dragStopped
1243
+ .pipe(takeUntil(this.ngUnsubscribe))
1244
+ .subscribe((value) => {
1245
+ const newColumns = this.getColumnOrder(value.columnApi);
1246
+ const hasChanged = currentColumns.findIndex((colId, i) => colId !== newColumns[i]);
1247
+ if (hasChanged > -1) {
1248
+ this.updateColumnsInCurrentDataState(value.columnApi);
1219
1249
  }
1220
1250
  });
1221
1251
  agGrid.rowSelected
@@ -1259,6 +1289,17 @@ let SkyAgGridDataManagerAdapterDirective = class SkyAgGridDataManagerAdapterDire
1259
1289
  this.dataManagerSvc.updateDataState(this.currentDataState, this.viewConfig.id);
1260
1290
  });
1261
1291
  }
1292
+ updateColumnsInCurrentDataState(columnApi) {
1293
+ const columnOrder = this.getColumnOrder(columnApi);
1294
+ const viewState = this.currentDataState.getViewStateById(this.viewConfig.id);
1295
+ viewState.displayedColumnIds = columnOrder;
1296
+ this.dataManagerSvc.updateDataState(this.currentDataState.addOrUpdateView(this.viewConfig.id, viewState), this.viewConfig.id);
1297
+ }
1298
+ getColumnOrder(columnApi) {
1299
+ return columnApi
1300
+ .getAllDisplayedVirtualColumns()
1301
+ .map((col) => col.getColDef().colId);
1302
+ }
1262
1303
  displayColumns(dataState) {
1263
1304
  const agGrid = this.currentAgGrid;
1264
1305
  const viewState = dataState.getViewStateById(this.viewConfig.id);
@@ -1342,7 +1383,7 @@ let SkyAgGridCellValidatorTooltipComponent = class SkyAgGridCellValidatorTooltip
1342
1383
  hideIndicator() {
1343
1384
  this.zone.run(() => {
1344
1385
  this.indicatorShouldShow = false;
1345
- this.changeDetector.markForCheck();
1386
+ this.changeDetector.detectChanges();
1346
1387
  });
1347
1388
  }
1348
1389
  hidePopover() {
@@ -1351,7 +1392,7 @@ let SkyAgGridCellValidatorTooltipComponent = class SkyAgGridCellValidatorTooltip
1351
1392
  showIndicator() {
1352
1393
  this.zone.run(() => {
1353
1394
  this.indicatorShouldShow = true;
1354
- this.changeDetector.markForCheck();
1395
+ this.changeDetector.detectChanges();
1355
1396
  });
1356
1397
  }
1357
1398
  showPopover() {
@@ -1600,7 +1641,10 @@ let SkyAgGridRowDeleteDirective = class SkyAgGridRowDeleteDirective {
1600
1641
  return this.rowDeleteConfigs.find(rowDelete => rowDelete.id === row.id);
1601
1642
  }
1602
1643
  affixToRow(affixer, id) {
1603
- let rowElement = this.elementRef.nativeElement.querySelector('[row-id="' + id + '"] div[aria-colindex="1"]');
1644
+ let rowElement = this.elementRef.nativeElement.querySelector(`
1645
+ [row-id="${id}"] div[aria-colindex="1"],
1646
+ .ag-row.sky-ag-grid-row-${id} div[aria-colindex="1"]
1647
+ `);
1604
1648
  // This covers cases where AG Grid places the column index on an inner element (such as with the `enableCellTextSelection` option)
1605
1649
  // This appears to have been fixed by AG Grid in version 24 and so it is not testable after that version.
1606
1650
  /* istanbul ignore if */