@datorama/core 22.2.2 → 22.2.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.
@@ -10099,13 +10099,19 @@ let GridQuery = class GridQuery extends Query {
10099
10099
  if (this.gridRef.gridOptions.pivotMode) {
10100
10100
  const { sort, colId } = this.api.grid.getSortModel().pop() || {};
10101
10101
  const column = this.api.columns.getColumn(colId);
10102
+ const allColumns = this.api.columns.getAllGridColumns();
10102
10103
  if (column) {
10103
- return { colId, sort, colField: getColField(column.getColDef()) };
10104
+ return { colId, sort, field: getColField(column.getColDef()), sortIndex: allColumns.indexOf(column) };
10104
10105
  }
10105
10106
  else {
10106
10107
  const secondaryColumn = this.getSecondaryColumn(colId);
10107
10108
  if (secondaryColumn) {
10108
- return { colId, sort, colField: getColField(secondaryColumn.getColDef()) };
10109
+ return {
10110
+ colId,
10111
+ sort,
10112
+ field: getColField(secondaryColumn.getColDef()),
10113
+ sortIndex: allColumns.indexOf(secondaryColumn)
10114
+ };
10109
10115
  }
10110
10116
  }
10111
10117
  }
@@ -12675,35 +12681,32 @@ let GridService = class GridService {
12675
12681
  }
12676
12682
  setGridFilters(filters) {
12677
12683
  if (this.api && filters) {
12678
- for (const { filter } of filters) {
12679
- const column = this.api.columns.getColumn(filter.colId);
12680
- if (column) {
12681
- this.setColumnFilter(column, filter, false);
12682
- }
12683
- else {
12684
- const secondaryColumn = this.gridQuery.getSecondaryColumn(filter.colId);
12685
- if (secondaryColumn) {
12686
- this.setColumnFilter(secondaryColumn, filter, false);
12687
- }
12688
- }
12684
+ let appliedFilter = {};
12685
+ for (const { filter, field } of filters) {
12686
+ appliedFilter = Object.assign(Object.assign({}, appliedFilter), { [field]: filter });
12689
12687
  }
12688
+ this.updateSettings({ filter: appliedFilter });
12690
12689
  this.api.grid.onFilterChanged();
12691
12690
  }
12692
12691
  }
12693
12692
  setGridSort(gridSort) {
12694
12693
  if (this.api && gridSort) {
12695
- const { colId, sort } = gridSort;
12696
- const column = this.api.columns.getColumn(colId);
12697
- if (column) {
12698
- column.setSort(sort);
12694
+ const { sort, sortIndex } = gridSort;
12695
+ if (!isNil(sortIndex)) {
12696
+ const columns = this.api.columns.getAllGridColumns();
12697
+ if (columns) {
12698
+ const column = columns[sortIndex];
12699
+ if (column) {
12700
+ const sortToApply = { colId: column.getColId(), sort };
12701
+ this.updateSettings({ sort: sortToApply });
12702
+ this.api.grid.setSortModel([sortToApply]);
12703
+ }
12704
+ }
12699
12705
  }
12700
12706
  else {
12701
- const secondaryColumn = this.gridQuery.getSecondaryColumn(colId);
12702
- if (secondaryColumn) {
12703
- secondaryColumn.setSort(sort);
12704
- }
12707
+ this.updateSettings({ sort: gridSort });
12708
+ this.api.grid.setSortModel([gridSort]);
12705
12709
  }
12706
- this.api.grid.onSortChanged();
12707
12710
  }
12708
12711
  }
12709
12712
  updateFilter(column, filter) {
@@ -13723,12 +13726,6 @@ let DatoGridControllerComponent = class DatoGridControllerComponent {
13723
13726
  setGridSort(sort) {
13724
13727
  this.gridService.setGridSort(sort);
13725
13728
  }
13726
- onFilterChanged() {
13727
- return this.gridQuery.filterChanged();
13728
- }
13729
- onSortChanged() {
13730
- return this.gridQuery.selectSort();
13731
- }
13732
13729
  getGridIcons() {
13733
13730
  const moveColumnIcon = `<span class="da-grid-icon pointer d-flex column-move">${this.iconRegistry.getSvg('move-column')}</span>`;
13734
13731
  return {
@@ -13767,8 +13764,8 @@ let DatoGridControllerComponent = class DatoGridControllerComponent {
13767
13764
  });
13768
13765
  }
13769
13766
  listenToGridEvents(agGrid) {
13770
- const { columnVisible, sortChanged, columnRowGroupChanged, columnPinned, dragStopped } = agGrid;
13771
- merge$1(columnVisible, sortChanged, columnRowGroupChanged, columnPinned, dragStopped)
13767
+ const { columnVisible, sortChanged, columnRowGroupChanged, columnPinned, dragStopped, filterChanged } = agGrid;
13768
+ merge$1(columnVisible, sortChanged, columnRowGroupChanged, columnPinned, dragStopped, filterChanged)
13772
13769
  .pipe(
13773
13770
  /* Skip the initial sorting event fired by the grid when adding rows */
13774
13771
  skip(1), untilDestroyed(this))
@@ -13776,10 +13773,8 @@ let DatoGridControllerComponent = class DatoGridControllerComponent {
13776
13773
  const settingsDiff = this.gridService.getSettingsDiff();
13777
13774
  this.gridService.updateSettings(settingsDiff);
13778
13775
  const data = this.getGridData();
13779
- this.onGridChange.emit({
13780
- type,
13781
- data
13782
- });
13776
+ this.onGridChange.emit(Object.assign(Object.assign({}, settingsDiff), { type,
13777
+ data }));
13783
13778
  });
13784
13779
  }
13785
13780
  listenToStoreSettingsChanges() {
@@ -22649,7 +22644,7 @@ function fixNgLeaks() {
22649
22644
  };
22650
22645
  }
22651
22646
 
22652
- window.coreVersion = '22.2.2';
22647
+ window.coreVersion = '22.2.4';
22653
22648
 
22654
22649
  /**
22655
22650
  * @license