@datorama/core 22.8.1-rc.3 → 22.8.2-rc.2

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.
@@ -10092,7 +10092,7 @@ let GridQuery = class GridQuery extends Query {
10092
10092
  const storeSettings = this.getValue().settings;
10093
10093
  const settings = {
10094
10094
  gridAlignment: storeSettings.gridAlignment,
10095
- sort: this.getSort(),
10095
+ sort: this.getGridOptions().sortByStore ? this.getSavedSort() : this.getSortModel(),
10096
10096
  hiddenColumns,
10097
10097
  groupedColumns: groupedColumns.map(toColId),
10098
10098
  filter: this.getFilter(),
@@ -10106,30 +10106,31 @@ let GridQuery = class GridQuery extends Query {
10106
10106
  }
10107
10107
  return settings;
10108
10108
  }
10109
- getSort() {
10109
+ getSortModel() {
10110
10110
  return this.api.grid.getSortModel().pop();
10111
10111
  }
10112
- getExternalSort() {
10113
- const { sort, colId } = this.getSort() || {};
10114
- const column = this.api.columns.getColumn(colId);
10115
- const allColumns = this.api.columns.getAllGridColumns();
10116
- if (column) {
10117
- return { colId, sort, field: getColField(column.getColDef()), sortIndex: allColumns.indexOf(column) };
10118
- }
10119
- else {
10120
- const secondaryColumn = this.getSecondaryColumn(colId);
10121
- if (secondaryColumn) {
10122
- return {
10123
- colId,
10124
- sort,
10125
- field: getColField(secondaryColumn.getColDef()),
10126
- sortIndex: allColumns.indexOf(secondaryColumn)
10127
- };
10112
+ getSavedSort() {
10113
+ return this.getValue().settings.sort || this.getSortModel();
10114
+ }
10115
+ getSort(savedSort = this.getSavedSort()) {
10116
+ if (savedSort) {
10117
+ const { colId, sort, sortIndex } = savedSort;
10118
+ const column = this.api.columns.getColumn(colId);
10119
+ const allColumns = this.api.columns.getAllGridColumns();
10120
+ if (column) {
10121
+ const field = getColField(column.getColDef());
10122
+ return { colId, sort, field };
10123
+ }
10124
+ else {
10125
+ const secondaryColumn = this.getSecondaryColumn(colId);
10126
+ if (secondaryColumn) {
10127
+ const columnIndex = sortIndex || allColumns.indexOf(secondaryColumn);
10128
+ const field = getColField(secondaryColumn.getColDef());
10129
+ return { colId, sort, field, sortIndex: columnIndex };
10130
+ }
10128
10131
  }
10129
10132
  }
10130
- }
10131
- selectSort() {
10132
- return this.select(state => state.settings.sort);
10133
+ return { colId: null, sort: null };
10133
10134
  }
10134
10135
  /* @internal */
10135
10136
  _setApi(api, gridRef) {
@@ -11830,6 +11831,7 @@ let DatoGridColumnHeaderComponent = class DatoGridColumnHeaderComponent {
11830
11831
  const sortingOrder = this.column.getColDef() ? this.column.getColDef().sortingOrder : null;
11831
11832
  let sort;
11832
11833
  const currentSort = this.column.getSort();
11834
+ const colId = this.column.getColId();
11833
11835
  if (sortingOrder && sortingOrder.length > 0) {
11834
11836
  const currentSortIndex = sortingOrder.indexOf(currentSort);
11835
11837
  let newSortIndex;
@@ -11846,10 +11848,15 @@ let DatoGridColumnHeaderComponent = class DatoGridColumnHeaderComponent {
11846
11848
  }
11847
11849
  gridService._logEvent("Grids - Column Action" /* GRID_COLUMN_ACTION */, {
11848
11850
  action: 'Sort',
11849
- column: this.column.getColId()
11851
+ column: colId
11850
11852
  });
11851
11853
  gridQuery.isServerSide && gridService.setLoading(true);
11852
- this.params.setSort(sort);
11854
+ if (gridQuery.getGridOptions().sortByStore) {
11855
+ gridService.setSortByColumn(colId, sort);
11856
+ }
11857
+ else {
11858
+ this.params.setSort(sort);
11859
+ }
11853
11860
  });
11854
11861
  this.sortingInfo$ = gridQuery
11855
11862
  .waitForGrid(() => gridQuery.gridRef.sortChanged)
@@ -12715,6 +12722,10 @@ let GridService = class GridService {
12715
12722
  this.notifyFilterUpdate();
12716
12723
  }
12717
12724
  }
12725
+ setSortByColumn(colId, sort) {
12726
+ const sortToSet = this.gridQuery.getSort({ colId, sort });
12727
+ this.setGridSort(sortToSet);
12728
+ }
12718
12729
  setGridSort(gridSort) {
12719
12730
  if (gridSort && this.api && this.api.grid.getDisplayedRowCount() > 0) {
12720
12731
  const { colId, sort, sortIndex } = gridSort;
@@ -12728,11 +12739,11 @@ let GridService = class GridService {
12728
12739
  if (isPivotColId || valueColumn) {
12729
12740
  /** Column is pivot value column, sort by index */
12730
12741
  const columnByIndex = gridColumns[sortIndex];
12731
- const pivotValueColumn = columnByIndex && columnByIndex.getColDef().pivotValueColumn;
12732
- const pivotValueColumnId = pivotValueColumn && pivotValueColumn.getColId();
12733
- if (pivotValueColumnId === colId) {
12734
- sortToApply = { colId: columnByIndex.getColId(), sort };
12735
- }
12742
+ // const pivotValueColumn = columnByIndex && columnByIndex.getColDef().pivotValueColumn;
12743
+ // const pivotValueColumnId = pivotValueColumn && pivotValueColumn.getColId();
12744
+ // if (pivotValueColumnId === colId) {
12745
+ sortToApply = { colId: columnByIndex.getColId(), sort, sortIndex };
12746
+ // }
12736
12747
  }
12737
12748
  else {
12738
12749
  /** Sort by column id */
@@ -13819,7 +13830,7 @@ let DatoGridControllerComponent = class DatoGridControllerComponent {
13819
13830
  const data = this.getGridData();
13820
13831
  this.onGridChange.emit({
13821
13832
  filter: this.gridQuery.getExternalFilter(),
13822
- sort: this.gridQuery.getExternalSort(),
13833
+ sort: this.gridQuery.getSort(),
13823
13834
  type,
13824
13835
  data
13825
13836
  });
@@ -22715,7 +22726,7 @@ function fixNgLeaks() {
22715
22726
  };
22716
22727
  }
22717
22728
 
22718
- window.coreVersion = '22.8.1-rc.';
22729
+ window.coreVersion = '22.8.2-rc.';
22719
22730
 
22720
22731
  /**
22721
22732
  * @license