@datorama/core 22.6.3 → 22.7.0

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.
@@ -10112,26 +10112,26 @@ let GridQuery = class GridQuery extends Query {
10112
10112
  return settings;
10113
10113
  }
10114
10114
  getSort() {
10115
- if (this.gridRef.gridOptions.pivotMode) {
10116
- const { sort, colId } = this.api.grid.getSortModel().pop() || {};
10117
- const column = this.api.columns.getColumn(colId);
10118
- const allColumns = this.api.columns.getAllGridColumns();
10119
- if (column) {
10120
- return { colId, sort, field: getColField(column.getColDef()), sortIndex: allColumns.indexOf(column) };
10121
- }
10122
- else {
10123
- const secondaryColumn = this.getSecondaryColumn(colId);
10124
- if (secondaryColumn) {
10125
- return {
10126
- colId,
10127
- sort,
10128
- field: getColField(secondaryColumn.getColDef()),
10129
- sortIndex: allColumns.indexOf(secondaryColumn)
10130
- };
10131
- }
10115
+ return this.api.grid.getSortModel().pop();
10116
+ }
10117
+ getExternalSort() {
10118
+ const { sort, colId } = this.getSort() || {};
10119
+ const column = this.api.columns.getColumn(colId);
10120
+ const allColumns = this.api.columns.getAllGridColumns();
10121
+ if (column) {
10122
+ return { colId, sort, field: getColField(column.getColDef()), sortIndex: allColumns.indexOf(column) };
10123
+ }
10124
+ else {
10125
+ const secondaryColumn = this.getSecondaryColumn(colId);
10126
+ if (secondaryColumn) {
10127
+ return {
10128
+ colId,
10129
+ sort,
10130
+ field: getColField(secondaryColumn.getColDef()),
10131
+ sortIndex: allColumns.indexOf(secondaryColumn)
10132
+ };
10132
10133
  }
10133
10134
  }
10134
- return this.api.grid.getSortModel().pop();
10135
10135
  }
10136
10136
  selectSort() {
10137
10137
  return this.select(state => state.settings.sort);
@@ -12722,37 +12722,33 @@ let GridService = class GridService {
12722
12722
  }
12723
12723
  setGridSort(gridSort) {
12724
12724
  if (this.api && gridSort) {
12725
- const { sort, sortIndex, colId } = gridSort;
12725
+ const { colId, sort, sortIndex } = gridSort;
12726
+ let sortToApply = gridSort;
12726
12727
  if (!isNil(sortIndex)) {
12727
12728
  const gridColumns = this.api.columns.getAllGridColumns();
12728
12729
  if (gridColumns) {
12729
- const primaryColumns = this.api.columns.getPrimaryColumns();
12730
- const primaryColumn = primaryColumns.find(col => col.getColId() === colId);
12731
- if (primaryColumn) {
12732
- /** Column is no pivot value column */
12730
+ const secondaryColumns = this.api.columns.getSecondaryColumns();
12731
+ const secondaryColumn = secondaryColumns.find((col) => col.getColId() === colId);
12732
+ if (secondaryColumn) {
12733
+ /** Column is pivot value column, sort by index */
12734
+ const columnByIndex = gridColumns[sortIndex];
12735
+ if (columnByIndex) {
12736
+ sortToApply = { colId: columnByIndex.getColId(), sort };
12737
+ }
12738
+ }
12739
+ else {
12740
+ /** Sort by column id */
12733
12741
  const columnById = gridColumns.find((col) => {
12734
12742
  return (col.getColDef().showRowGroup || col.getColId()) === colId;
12735
12743
  });
12736
12744
  if (columnById) {
12737
- const sortToApply = { colId: columnById.getColId(), sort };
12738
- this.updateSettings({ sort: sortToApply });
12739
- this.api.grid.setSortModel([sortToApply]);
12740
- }
12741
- }
12742
- else {
12743
- const columnByIndex = gridColumns[sortIndex];
12744
- if (columnByIndex) {
12745
- const sortToApply = { colId: columnByIndex.getColId(), sort };
12746
- this.updateSettings({ sort: sortToApply });
12747
- this.api.grid.setSortModel([sortToApply]);
12745
+ sortToApply = { colId: columnById.getColId(), sort };
12748
12746
  }
12749
12747
  }
12750
12748
  }
12751
12749
  }
12752
- else {
12753
- this.updateSettings({ sort: gridSort });
12754
- this.api.grid.setSortModel([gridSort]);
12755
- }
12750
+ this.updateSettings({ sort: sortToApply });
12751
+ this.api.grid.setSortModel([sortToApply]);
12756
12752
  }
12757
12753
  }
12758
12754
  updateFilter(column, filter) {
@@ -13821,7 +13817,7 @@ let DatoGridControllerComponent = class DatoGridControllerComponent {
13821
13817
  const data = this.getGridData();
13822
13818
  this.onGridChange.emit({
13823
13819
  filter: this.gridQuery.getExternalFilter(),
13824
- sort: this.gridQuery.getSort(),
13820
+ sort: this.gridQuery.getExternalSort(),
13825
13821
  type,
13826
13822
  data
13827
13823
  });
@@ -22694,7 +22690,7 @@ function fixNgLeaks() {
22694
22690
  };
22695
22691
  }
22696
22692
 
22697
- window.coreVersion = '22.6.3';
22693
+ window.coreVersion = '22.7.0';
22698
22694
 
22699
22695
  /**
22700
22696
  * @license