@datorama/core 22.2.2 → 22.2.6

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
  }
@@ -10133,16 +10139,18 @@ let GridQuery = class GridQuery extends Query {
10133
10139
  selectFilter() {
10134
10140
  return this.select(state => state.settings.filter);
10135
10141
  }
10136
- filterChanged() {
10137
- return this.selectFilter().pipe(map$1(filter => {
10138
- return Object.keys(filter).reduce((filters, field) => {
10139
- const datoFilter = filter[field];
10140
- if (datoFilter) {
10141
- filters.push({ field, filter: datoFilter });
10142
+ getExternalFilter() {
10143
+ const gridFilters = this.getFilter();
10144
+ if (gridFilters) {
10145
+ return Object.keys(gridFilters).reduce((filters, field) => {
10146
+ const filter = gridFilters[field];
10147
+ if (filter) {
10148
+ filters.push({ field, filter });
10142
10149
  }
10143
10150
  return filters;
10144
10151
  }, []);
10145
- }));
10152
+ }
10153
+ return [];
10146
10154
  }
10147
10155
  getSearchTerm() {
10148
10156
  return this.getValue().settings.searchTerm;
@@ -12675,35 +12683,32 @@ let GridService = class GridService {
12675
12683
  }
12676
12684
  setGridFilters(filters) {
12677
12685
  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
- }
12686
+ let appliedFilter = {};
12687
+ for (const { filter, field } of filters) {
12688
+ appliedFilter[field] = filter;
12689
12689
  }
12690
+ this.updateSettings({ filter: appliedFilter });
12690
12691
  this.api.grid.onFilterChanged();
12691
12692
  }
12692
12693
  }
12693
12694
  setGridSort(gridSort) {
12694
12695
  if (this.api && gridSort) {
12695
- const { colId, sort } = gridSort;
12696
- const column = this.api.columns.getColumn(colId);
12697
- if (column) {
12698
- column.setSort(sort);
12696
+ const { sort, sortIndex } = gridSort;
12697
+ if (!isNil(sortIndex)) {
12698
+ const columns = this.api.columns.getAllGridColumns();
12699
+ if (columns) {
12700
+ const column = columns[sortIndex];
12701
+ if (column) {
12702
+ const sortToApply = { colId: column.getColId(), sort };
12703
+ this.updateSettings({ sort: sortToApply });
12704
+ this.api.grid.setSortModel([sortToApply]);
12705
+ }
12706
+ }
12699
12707
  }
12700
12708
  else {
12701
- const secondaryColumn = this.gridQuery.getSecondaryColumn(colId);
12702
- if (secondaryColumn) {
12703
- secondaryColumn.setSort(sort);
12704
- }
12709
+ this.updateSettings({ sort: gridSort });
12710
+ this.api.grid.setSortModel([gridSort]);
12705
12711
  }
12706
- this.api.grid.onSortChanged();
12707
12712
  }
12708
12713
  }
12709
12714
  updateFilter(column, filter) {
@@ -13723,12 +13728,6 @@ let DatoGridControllerComponent = class DatoGridControllerComponent {
13723
13728
  setGridSort(sort) {
13724
13729
  this.gridService.setGridSort(sort);
13725
13730
  }
13726
- onFilterChanged() {
13727
- return this.gridQuery.filterChanged();
13728
- }
13729
- onSortChanged() {
13730
- return this.gridQuery.selectSort();
13731
- }
13732
13731
  getGridIcons() {
13733
13732
  const moveColumnIcon = `<span class="da-grid-icon pointer d-flex column-move">${this.iconRegistry.getSvg('move-column')}</span>`;
13734
13733
  return {
@@ -13767,8 +13766,8 @@ let DatoGridControllerComponent = class DatoGridControllerComponent {
13767
13766
  });
13768
13767
  }
13769
13768
  listenToGridEvents(agGrid) {
13770
- const { columnVisible, sortChanged, columnRowGroupChanged, columnPinned, dragStopped } = agGrid;
13771
- merge$1(columnVisible, sortChanged, columnRowGroupChanged, columnPinned, dragStopped)
13769
+ const { columnVisible, sortChanged, columnRowGroupChanged, columnPinned, dragStopped, filterChanged } = agGrid;
13770
+ merge$1(columnVisible, sortChanged, columnRowGroupChanged, columnPinned, dragStopped, filterChanged)
13772
13771
  .pipe(
13773
13772
  /* Skip the initial sorting event fired by the grid when adding rows */
13774
13773
  skip(1), untilDestroyed(this))
@@ -13777,6 +13776,8 @@ let DatoGridControllerComponent = class DatoGridControllerComponent {
13777
13776
  this.gridService.updateSettings(settingsDiff);
13778
13777
  const data = this.getGridData();
13779
13778
  this.onGridChange.emit({
13779
+ filter: this.gridQuery.getExternalFilter(),
13780
+ sort: this.gridQuery.getSort(),
13780
13781
  type,
13781
13782
  data
13782
13783
  });
@@ -22649,7 +22650,7 @@ function fixNgLeaks() {
22649
22650
  };
22650
22651
  }
22651
22652
 
22652
- window.coreVersion = '22.2.2';
22653
+ window.coreVersion = '22.2.6';
22653
22654
 
22654
22655
  /**
22655
22656
  * @license