@datorama/core 22.6.2 → 22.7.1

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,34 @@ 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 */
12733
- const columnById = gridColumns.find((col) => {
12734
- return col.getColDef().showRowGroup || col.getColId() === colId;
12735
- });
12736
- if (columnById) {
12737
- const sortToApply = { colId: columnById.getColId(), sort };
12738
- this.updateSettings({ sort: sortToApply });
12739
- this.api.grid.setSortModel([sortToApply]);
12730
+ const valueColumns = this.api.columns.getValueColumns();
12731
+ const valueColumn = valueColumns.find((col) => col.getColId() === colId);
12732
+ const isPivotColId = colId.startsWith('pivot');
12733
+ if (isPivotColId || valueColumn) {
12734
+ /** Column is pivot value column, sort by index */
12735
+ const columnByIndex = gridColumns[sortIndex];
12736
+ if (columnByIndex) {
12737
+ sortToApply = { colId: columnByIndex.getColId(), sort };
12740
12738
  }
12741
12739
  }
12742
12740
  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]);
12741
+ /** Sort by column id */
12742
+ const columnById = gridColumns.find((col) => {
12743
+ return (col.getColDef().showRowGroup || col.getColId()) === colId;
12744
+ });
12745
+ if (columnById) {
12746
+ sortToApply = { colId: columnById.getColId(), sort };
12748
12747
  }
12749
12748
  }
12750
12749
  }
12751
12750
  }
12752
- else {
12753
- this.updateSettings({ sort: gridSort });
12754
- this.api.grid.setSortModel([gridSort]);
12755
- }
12751
+ this.updateSettings({ sort: sortToApply });
12752
+ this.api.grid.setSortModel([sortToApply]);
12756
12753
  }
12757
12754
  }
12758
12755
  updateFilter(column, filter) {
@@ -13821,7 +13818,7 @@ let DatoGridControllerComponent = class DatoGridControllerComponent {
13821
13818
  const data = this.getGridData();
13822
13819
  this.onGridChange.emit({
13823
13820
  filter: this.gridQuery.getExternalFilter(),
13824
- sort: this.gridQuery.getSort(),
13821
+ sort: this.gridQuery.getExternalSort(),
13825
13822
  type,
13826
13823
  data
13827
13824
  });
@@ -22694,7 +22691,7 @@ function fixNgLeaks() {
22694
22691
  };
22695
22692
  }
22696
22693
 
22697
- window.coreVersion = '22.6.2';
22694
+ window.coreVersion = '22.7.1';
22698
22695
 
22699
22696
  /**
22700
22697
  * @license