@datorama/core 22.7.2 → 22.8.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.
@@ -10097,7 +10097,7 @@ let GridQuery = class GridQuery extends Query {
10097
10097
  const storeSettings = this.getValue().settings;
10098
10098
  const settings = {
10099
10099
  gridAlignment: storeSettings.gridAlignment,
10100
- sort: this.getSort(),
10100
+ sort: this.getGridOptions().sortByStore ? this.getSavedSort() : this.getSortModel(),
10101
10101
  hiddenColumns,
10102
10102
  groupedColumns: groupedColumns.map(toColId),
10103
10103
  filter: this.getFilter(),
@@ -10111,30 +10111,31 @@ let GridQuery = class GridQuery extends Query {
10111
10111
  }
10112
10112
  return settings;
10113
10113
  }
10114
- getSort() {
10114
+ getSortModel() {
10115
10115
  return this.api.grid.getSortModel().pop();
10116
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
- };
10117
+ getSavedSort() {
10118
+ return this.getValue().settings.sort || this.getSortModel();
10119
+ }
10120
+ getSort(savedSort = this.getSavedSort()) {
10121
+ if (savedSort) {
10122
+ const { colId, sort, sortIndex } = savedSort;
10123
+ const column = this.api.columns.getColumn(colId);
10124
+ const allColumns = this.api.columns.getAllGridColumns();
10125
+ if (column) {
10126
+ const field = getColField(column.getColDef());
10127
+ return { colId, sort, field };
10128
+ }
10129
+ else {
10130
+ const secondaryColumn = this.getSecondaryColumn(colId);
10131
+ if (secondaryColumn) {
10132
+ const columnIndex = sortIndex || allColumns.indexOf(secondaryColumn);
10133
+ const field = getColField(secondaryColumn.getColDef());
10134
+ return { colId, sort, field, sortIndex: columnIndex };
10135
+ }
10133
10136
  }
10134
10137
  }
10135
- }
10136
- selectSort() {
10137
- return this.select(state => state.settings.sort);
10138
+ return { colId: null, sort: null };
10138
10139
  }
10139
10140
  /* @internal */
10140
10141
  _setApi(api, gridRef) {
@@ -11835,6 +11836,7 @@ let DatoGridColumnHeaderComponent = class DatoGridColumnHeaderComponent {
11835
11836
  const sortingOrder = this.column.getColDef() ? this.column.getColDef().sortingOrder : null;
11836
11837
  let sort;
11837
11838
  const currentSort = this.column.getSort();
11839
+ const colId = this.column.getColId();
11838
11840
  if (sortingOrder && sortingOrder.length > 0) {
11839
11841
  const currentSortIndex = sortingOrder.indexOf(currentSort);
11840
11842
  let newSortIndex;
@@ -11851,10 +11853,15 @@ let DatoGridColumnHeaderComponent = class DatoGridColumnHeaderComponent {
11851
11853
  }
11852
11854
  gridService._logEvent("Grids - Column Action" /* GRID_COLUMN_ACTION */, {
11853
11855
  action: 'Sort',
11854
- column: this.column.getColId()
11856
+ column: colId
11855
11857
  });
11856
11858
  gridQuery.isServerSide && gridService.setLoading(true);
11857
- this.params.setSort(sort);
11859
+ if (gridQuery.getGridOptions().sortByStore) {
11860
+ gridService.setSortByColumn(colId, sort);
11861
+ }
11862
+ else {
11863
+ this.params.setSort(sort);
11864
+ }
11858
11865
  });
11859
11866
  this.sortingInfo$ = gridQuery
11860
11867
  .waitForGrid(() => gridQuery.gridRef.sortChanged)
@@ -12720,6 +12727,10 @@ let GridService = class GridService {
12720
12727
  this.notifyFilterUpdate();
12721
12728
  }
12722
12729
  }
12730
+ setSortByColumn(colId, sort) {
12731
+ const sortToSet = this.gridQuery.getSort({ colId, sort });
12732
+ this.setGridSort(sortToSet);
12733
+ }
12723
12734
  setGridSort(gridSort) {
12724
12735
  if (gridSort && this.api && this.api.grid.getDisplayedRowCount() > 0) {
12725
12736
  const { colId, sort, sortIndex } = gridSort;
@@ -12733,11 +12744,7 @@ let GridService = class GridService {
12733
12744
  if (isPivotColId || valueColumn) {
12734
12745
  /** Column is pivot value column, sort by index */
12735
12746
  const columnByIndex = gridColumns[sortIndex];
12736
- const pivotValueColumn = columnByIndex && columnByIndex.getColDef().pivotValueColumn;
12737
- const pivotValueColumnId = pivotValueColumn && pivotValueColumn.getColId();
12738
- if (pivotValueColumnId === colId) {
12739
- sortToApply = { colId: columnByIndex.getColId(), sort };
12740
- }
12747
+ sortToApply = { colId: columnByIndex.getColId(), sort, sortIndex };
12741
12748
  }
12742
12749
  else {
12743
12750
  /** Sort by column id */
@@ -13820,7 +13827,7 @@ let DatoGridControllerComponent = class DatoGridControllerComponent {
13820
13827
  const data = this.getGridData();
13821
13828
  this.onGridChange.emit({
13822
13829
  filter: this.gridQuery.getExternalFilter(),
13823
- sort: this.gridQuery.getExternalSort(),
13830
+ sort: this.gridQuery.getSort(),
13824
13831
  type,
13825
13832
  data
13826
13833
  });
@@ -22693,7 +22700,7 @@ function fixNgLeaks() {
22693
22700
  };
22694
22701
  }
22695
22702
 
22696
- window.coreVersion = '22.7.2';
22703
+ window.coreVersion = '22.8.0';
22697
22704
 
22698
22705
  /**
22699
22706
  * @license