@adaptabletools/adaptable-cjs 22.0.2 → 22.0.4

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.
@@ -4,14 +4,14 @@ exports.RowFormInternalApi = void 0;
4
4
  const ApiBase_1 = require("../Implementation/ApiBase");
5
5
  class RowFormInternalApi extends ApiBase_1.ApiBase {
6
6
  // Row Form Methods
7
- buildRowEditForm(rowNode) {
7
+ async buildRowEditForm(rowNode) {
8
8
  return this.buildRowForm('rowEdited', rowNode);
9
9
  }
10
- buildRowCreateForm(clonedRowNode) {
10
+ async buildRowCreateForm(clonedRowNode) {
11
11
  return this.buildRowForm('rowCreated', clonedRowNode);
12
12
  }
13
- buildRowForm(type, rowNode) {
14
- const formFields = this.buildRowFormFields(type, rowNode);
13
+ async buildRowForm(type, rowNode) {
14
+ const formFields = await this.buildRowFormFields(type, rowNode);
15
15
  const formButtons = this.buidRowFormButtons(type, rowNode, formFields);
16
16
  const formTitle = this.getFormTitle(type, rowNode);
17
17
  const formDescription = this.getFormDescription(type, rowNode);
@@ -107,7 +107,7 @@ class RowFormInternalApi extends ApiBase_1.ApiBase {
107
107
  dataToSave[this.getOptions().primaryKey] = pkValue;
108
108
  return dataToSave;
109
109
  }
110
- buildRowFormFields(rowFormType, rowNode) {
110
+ async buildRowFormFields(rowFormType, rowNode) {
111
111
  const relevantColumns = this.getColumnApi()
112
112
  .getUIAvailableColumns()
113
113
  .filter((column) => {
@@ -115,7 +115,7 @@ class RowFormInternalApi extends ApiBase_1.ApiBase {
115
115
  return !!rowNode || this.isCellEditable(column, rowNode);
116
116
  })
117
117
  .filter((column) => this.showColumnInRowForm(column, rowFormType));
118
- return relevantColumns.map((column) => this.buildRowFormField(rowFormType, column, rowNode));
118
+ return Promise.all(relevantColumns.map((column) => this.buildRowFormField(rowFormType, column, rowNode)));
119
119
  }
120
120
  showColumnInRowForm(adaptableColumn, rowFormType) {
121
121
  if (adaptableColumn.isActionColumn) {
@@ -138,9 +138,9 @@ class RowFormInternalApi extends ApiBase_1.ApiBase {
138
138
  const gridCell = this.getGridApi().getGridCellFromRowNode(rowNode, column.columnId);
139
139
  return this.getGridApi().isCellEditable(gridCell);
140
140
  }
141
- buildRowFormField(type, column, rowNode) {
141
+ async buildRowFormField(type, column, rowNode) {
142
142
  const isCellEditable = this.isCellEditable(column, rowNode);
143
- const fieldValueOptions = this.getFieldValueOptions(column, rowNode);
143
+ const fieldValueOptions = await this.getFieldValueOptions(column, rowNode);
144
144
  const fieldType = isCellEditable
145
145
  ? !!fieldValueOptions?.length
146
146
  ? 'select'
@@ -186,21 +186,25 @@ class RowFormInternalApi extends ApiBase_1.ApiBase {
186
186
  return 'text';
187
187
  }
188
188
  }
189
- getFieldValueOptions(column, rowNode) {
189
+ async getFieldValueOptions(column, rowNode) {
190
190
  const shouldShowSelectCellEditor = this.getUserInterfaceApi().internalApi.shouldShowSelectCellEditor(column);
191
191
  if (!shouldShowSelectCellEditor) {
192
192
  return;
193
193
  }
194
- const returnValues = this.getGridApi().internalApi.getDistinctDisplayValuesForColumnOld(column.columnId);
195
- // FIXME add support for asynchronous custom select cell editor values
196
- // it involves refactoring the AdaptableForm & adaptableFormComponent
197
- // await this.getSelectCellEditorValuesForColumn(
198
- // column,
199
- // gridCell
200
- // );
201
- return returnValues?.map((value) => ({
202
- value,
203
- label: value,
194
+ const gridCell = rowNode
195
+ ? this.getGridApi().getGridCellFromRowNode(rowNode, column.columnId)
196
+ : undefined;
197
+ const valueOptions = await this.getGridApi().internalApi.getDistinctEditDisplayValuesForColumn({
198
+ columnId: column.columnId,
199
+ gridCell,
200
+ currentSearchValue: '',
201
+ });
202
+ if (!valueOptions?.length) {
203
+ return;
204
+ }
205
+ return valueOptions.map((opt) => ({
206
+ value: opt.value,
207
+ label: opt.label ?? String(opt.value),
204
208
  }));
205
209
  }
206
210
  }
@@ -6,16 +6,16 @@ export interface RowFormApi {
6
6
  * Open edit dialog for row with the given primary key value
7
7
  * @param primaryKey - the primary key of the edited row
8
8
  */
9
- displayEditRowForm(primaryKey: any): void;
9
+ displayEditRowForm(primaryKey: any): Promise<void>;
10
10
  /**
11
11
  * Open create dialog for a new row
12
12
  */
13
- displayCreateRowForm(): void;
13
+ displayCreateRowForm(): Promise<void>;
14
14
  /**
15
15
  * Open create dialog for cloning an existing row
16
16
  * @param primaryKey - Primary Key of the duplicated row
17
17
  */
18
- displayCloneRowForm(primaryKey?: any): void;
18
+ displayCloneRowForm(primaryKey?: any): Promise<void>;
19
19
  /**
20
20
  * Deletes row from grid (with event fired) - note: no visible Row Form is displayed
21
21
  * @param primaryKey - Primary Key of the deleted row
@@ -15,7 +15,7 @@ import { AdaptablePersistentState, AdaptableState } from '../AdaptableState/Adap
15
15
  import { FreeTextColumnState } from '../AdaptableState/FreeTextColumnState';
16
16
  import { ToolPanelState } from '../AdaptableState/ToolPanelState';
17
17
  import { AdaptableModule, AdaptableStateKey } from '../AdaptableState/Common/Types';
18
- import { AdaptableFilterState, AdaptableSortState, ChartingState, FlashingCellState, InitialState, NamedQueryState, NoteState, PredefinedConfig, ScheduleState, StatusBarState, StyledColumnState } from '../types';
18
+ import { AdaptableFilterState, AdaptableSortState, ChartingState, FlashingCellState, InitialState, NamedQueryState, NoteState, ScheduleState, StatusBarState, StyledColumnState } from '../types';
19
19
  /**
20
20
  * Range of functions to access Initial and Full Adaptable State
21
21
  */
@@ -33,18 +33,10 @@ export interface StateApi {
33
33
  flushCurrentState?: boolean;
34
34
  progressIndicatorLabel?: string;
35
35
  }): Promise<void>;
36
- /**
37
- * @deprecated use `getInitialState()` instead
38
- */
39
- getPredefinedConfig(): PredefinedConfig | any;
40
36
  /**
41
37
  * Returns the Initial Adaptable State
42
38
  */
43
39
  getInitialState(): InitialState | any;
44
- /**
45
- * @deprecated use `reloadInitialState()` instead
46
- */
47
- reloadPredefinedConfig(newPredefinedConfig?: PredefinedConfig): void;
48
40
  /**
49
41
  * Reloads existing (or supplied) Initial State; clears persistent state by calling `StateOptions.clearState`
50
42
  * @param newInitialState optional new InitialState to load
@@ -219,6 +219,7 @@ export declare class AdaptableAgGrid implements IAdaptable {
219
219
  private getCleanValue;
220
220
  getNormalisedValueFromRawValue(rawValue: any, column: AdaptableColumn): string | number | boolean | Date | unknown;
221
221
  private __updateColumnModelAndRefreshGrid_already_called;
222
+ private __forceUpdateColumnModel;
222
223
  updateColumnModelAndRefreshGrid(): void;
223
224
  _updateColumnModelAndRefreshGridNow(): void;
224
225
  redrawBody(): void;
@@ -2233,10 +2233,12 @@ class AdaptableAgGrid {
2233
2233
  return rawValue;
2234
2234
  }
2235
2235
  __updateColumnModelAndRefreshGrid_already_called = false;
2236
+ __forceUpdateColumnModel = false;
2236
2237
  updateColumnModelAndRefreshGrid() {
2237
- if (this.__updateColumnModelAndRefreshGrid_already_called) {
2238
+ if (this.__updateColumnModelAndRefreshGrid_already_called && !this.__forceUpdateColumnModel) {
2238
2239
  return;
2239
2240
  }
2241
+ this.__forceUpdateColumnModel = false;
2240
2242
  try {
2241
2243
  this._updateColumnModelAndRefreshGridNow();
2242
2244
  this.__updateColumnModelAndRefreshGrid_already_called = true;
@@ -4285,6 +4287,10 @@ class AdaptableAgGrid {
4285
4287
  // this setGridOption call will also trigger layout.onColumnDefsChanged()
4286
4288
  // which will in turn call updateColumnModelAndRefreshGrid
4287
4289
  this.agGridAdapter.setGridOption('columnDefs', columnDefs);
4290
+ // the setGridOption call above already triggered updateColumnModelAndRefreshGrid,
4291
+ // setting the dedup guard. We force the next call so that the column model
4292
+ // is re-derived after the layout store has been updated.
4293
+ this.__forceUpdateColumnModel = true;
4288
4294
  // this is needed here for when we call setAdaptableStateKey
4289
4295
  // and pass a new config
4290
4296
  this.updateLayoutInManagerAfterStoreHasChanged();
package/src/env.js CHANGED
@@ -2,6 +2,6 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.default = {
4
4
  NEXT_PUBLIC_INFINITE_TABLE_LICENSE_KEY: "StartDate=2021-06-29|EndDate=2030-01-01|Owner=Adaptable|Type=distribution|TS=1624971462479|C=137829811,1004007071,2756196225,1839832928,3994409405,636616862" || '',
5
- PUBLISH_TIMESTAMP: 1773153919389 || Date.now(),
6
- VERSION: "22.0.2" || '--current-version--',
5
+ PUBLISH_TIMESTAMP: 1773747307753 || Date.now(),
6
+ VERSION: "22.0.4" || '--current-version--',
7
7
  };
@@ -29,6 +29,10 @@ function destructurePivotColumnId(colDef, currentModel, logWarning) {
29
29
  const pivotColumnIds = pivotColsTxt.split('-');
30
30
  const pivotKeys = pivotKeysTxt.split('-');
31
31
  const pivotColumnId = pivotColumnIds[pivotKeys.length - 1];
32
+ if (aggregationColumnId !== '' && !currentModel.aggColIds.includes(aggregationColumnId)) {
33
+ logWarning(`Unknown aggregation column: ${aggregationColumnId}`);
34
+ return '!unknown!';
35
+ }
32
36
  return {
33
37
  pivotColumnIds,
34
38
  pivotKeys,
@@ -55,16 +59,18 @@ function destructurePivotColumnId(colDef, currentModel, logWarning) {
55
59
  return {
56
60
  pivotColumnIds,
57
61
  pivotKeys,
58
- pivotColumnId: pivotColumnIds[pivotKeys.length],
62
+ pivotColumnId: pivotColumnIds[pivotKeys.length - 1],
59
63
  };
60
64
  }
61
- // For regular pivot columns, work backwards to find aggregation column
62
- const parts = withoutPrefix.split('_');
63
- const lastPart = parts[parts.length - 1];
64
- // Find the longest matching aggregation column id from the end
65
- const aggregationColumnId = currentModel.aggColIds.find((aggId) => lastPart.endsWith(aggId));
65
+ // For regular pivot columns, work backwards to find aggregation column.
66
+ // Check if the full string ends with _${aggColId} rather than splitting by _,
67
+ // since agg column IDs may themselves contain underscores (e.g. github_stars).
68
+ // Sort by length descending so the longest match wins.
69
+ const aggregationColumnId = [...currentModel.aggColIds]
70
+ .sort((a, b) => b.length - a.length)
71
+ .find((aggId) => withoutPrefix.endsWith('_' + aggId));
66
72
  if (!aggregationColumnId) {
67
- logWarning(`Could not identify aggregation column in: ${lastPart}`);
73
+ logWarning(`Could not identify aggregation column in: ${withoutPrefix}`);
68
74
  return '!unknown!';
69
75
  }
70
76
  // Remove aggregation part and get pivot columns
@@ -1282,10 +1282,22 @@ class LayoutManager extends LMEmitter_1.LMEmitter {
1282
1282
  this.computeColumnSorts(layout, columnState);
1283
1283
  this.computePinnedColumns(layout, columnState);
1284
1284
  this.computePivotAggregations(layout, columnState);
1285
- // Add pivot result columns to the state for ordering (will be applied with applyOrder: true later)
1285
+ // Add pivot result columns to the state for ordering (will be applied with applyOrder: true later).
1286
+ // Some pivot result columns may already be in the state (e.g. added by computeColumnSorts),
1287
+ // so remove them first and re-add all pivot result columns in the persisted order,
1288
+ // merging any existing state (like sort info) back in.
1286
1289
  if (Array.isArray(layout.PivotResultColumnsOrder)) {
1290
+ const pivotResultColumnsOrderSet = new Set(layout.PivotResultColumnsOrder);
1291
+ const existingPivotResultState = {};
1292
+ columnState.state = columnState.state.filter((colState) => {
1293
+ if (pivotResultColumnsOrderSet.has(colState.colId)) {
1294
+ existingPivotResultState[colState.colId] = colState;
1295
+ return false;
1296
+ }
1297
+ return true;
1298
+ });
1287
1299
  layout.PivotResultColumnsOrder.forEach((colId) => {
1288
- columnState.state.push({ colId });
1300
+ columnState.state.push(existingPivotResultState[colId] || { colId });
1289
1301
  });
1290
1302
  }
1291
1303
  return columnState;
@@ -4239,6 +4239,24 @@ export declare const ADAPTABLE_METAMODEL: {
4239
4239
  defVal: string;
4240
4240
  }[];
4241
4241
  };
4242
+ IPushPullConfig: {
4243
+ name: string;
4244
+ kind: string;
4245
+ desc: string;
4246
+ props: ({
4247
+ name: string;
4248
+ kind: string;
4249
+ desc: string;
4250
+ isOpt?: undefined;
4251
+ defVal?: undefined;
4252
+ } | {
4253
+ name: string;
4254
+ kind: string;
4255
+ desc: string;
4256
+ isOpt: boolean;
4257
+ defVal: string;
4258
+ })[];
4259
+ };
4242
4260
  IPushPullDomain: {
4243
4261
  name: string;
4244
4262
  kind: string;
@@ -4259,12 +4277,21 @@ export declare const ADAPTABLE_METAMODEL: {
4259
4277
  desc: string;
4260
4278
  isOpt: boolean;
4261
4279
  defVal: string;
4280
+ ref?: undefined;
4262
4281
  } | {
4263
4282
  name: string;
4264
4283
  kind: string;
4265
4284
  desc: string;
4266
4285
  isOpt: boolean;
4286
+ ref: string;
4267
4287
  defVal?: undefined;
4288
+ } | {
4289
+ name: string;
4290
+ kind: string;
4291
+ desc: string;
4292
+ isOpt: boolean;
4293
+ defVal?: undefined;
4294
+ ref?: undefined;
4268
4295
  })[];
4269
4296
  };
4270
4297
  IPushPullReport: {
@@ -4904,24 +4931,6 @@ export declare const ADAPTABLE_METAMODEL: {
4904
4931
  kind: string;
4905
4932
  desc: string;
4906
4933
  };
4907
- PredefinedConfig: {
4908
- name: string;
4909
- kind: string;
4910
- desc: string;
4911
- props: ({
4912
- name: string;
4913
- kind: string;
4914
- desc: string;
4915
- isOpt: boolean;
4916
- ref: string;
4917
- } | {
4918
- name: string;
4919
- kind: string;
4920
- desc: string;
4921
- ref: string;
4922
- isOpt?: undefined;
4923
- })[];
4924
- };
4925
4934
  PredicateDefHandlerContext: {
4926
4935
  name: string;
4927
4936
  kind: string;