@adaptabletools/adaptable 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.
@@ -1,14 +1,14 @@
1
1
  import { ApiBase } from '../Implementation/ApiBase';
2
2
  export class RowFormInternalApi extends ApiBase {
3
3
  // Row Form Methods
4
- buildRowEditForm(rowNode) {
4
+ async buildRowEditForm(rowNode) {
5
5
  return this.buildRowForm('rowEdited', rowNode);
6
6
  }
7
- buildRowCreateForm(clonedRowNode) {
7
+ async buildRowCreateForm(clonedRowNode) {
8
8
  return this.buildRowForm('rowCreated', clonedRowNode);
9
9
  }
10
- buildRowForm(type, rowNode) {
11
- const formFields = this.buildRowFormFields(type, rowNode);
10
+ async buildRowForm(type, rowNode) {
11
+ const formFields = await this.buildRowFormFields(type, rowNode);
12
12
  const formButtons = this.buidRowFormButtons(type, rowNode, formFields);
13
13
  const formTitle = this.getFormTitle(type, rowNode);
14
14
  const formDescription = this.getFormDescription(type, rowNode);
@@ -104,7 +104,7 @@ export class RowFormInternalApi extends ApiBase {
104
104
  dataToSave[this.getOptions().primaryKey] = pkValue;
105
105
  return dataToSave;
106
106
  }
107
- buildRowFormFields(rowFormType, rowNode) {
107
+ async buildRowFormFields(rowFormType, rowNode) {
108
108
  const relevantColumns = this.getColumnApi()
109
109
  .getUIAvailableColumns()
110
110
  .filter((column) => {
@@ -112,7 +112,7 @@ export class RowFormInternalApi extends ApiBase {
112
112
  return !!rowNode || this.isCellEditable(column, rowNode);
113
113
  })
114
114
  .filter((column) => this.showColumnInRowForm(column, rowFormType));
115
- return relevantColumns.map((column) => this.buildRowFormField(rowFormType, column, rowNode));
115
+ return Promise.all(relevantColumns.map((column) => this.buildRowFormField(rowFormType, column, rowNode)));
116
116
  }
117
117
  showColumnInRowForm(adaptableColumn, rowFormType) {
118
118
  if (adaptableColumn.isActionColumn) {
@@ -135,9 +135,9 @@ export class RowFormInternalApi extends ApiBase {
135
135
  const gridCell = this.getGridApi().getGridCellFromRowNode(rowNode, column.columnId);
136
136
  return this.getGridApi().isCellEditable(gridCell);
137
137
  }
138
- buildRowFormField(type, column, rowNode) {
138
+ async buildRowFormField(type, column, rowNode) {
139
139
  const isCellEditable = this.isCellEditable(column, rowNode);
140
- const fieldValueOptions = this.getFieldValueOptions(column, rowNode);
140
+ const fieldValueOptions = await this.getFieldValueOptions(column, rowNode);
141
141
  const fieldType = isCellEditable
142
142
  ? !!fieldValueOptions?.length
143
143
  ? 'select'
@@ -183,21 +183,25 @@ export class RowFormInternalApi extends ApiBase {
183
183
  return 'text';
184
184
  }
185
185
  }
186
- getFieldValueOptions(column, rowNode) {
186
+ async getFieldValueOptions(column, rowNode) {
187
187
  const shouldShowSelectCellEditor = this.getUserInterfaceApi().internalApi.shouldShowSelectCellEditor(column);
188
188
  if (!shouldShowSelectCellEditor) {
189
189
  return;
190
190
  }
191
- const returnValues = this.getGridApi().internalApi.getDistinctDisplayValuesForColumnOld(column.columnId);
192
- // FIXME add support for asynchronous custom select cell editor values
193
- // it involves refactoring the AdaptableForm & adaptableFormComponent
194
- // await this.getSelectCellEditorValuesForColumn(
195
- // column,
196
- // gridCell
197
- // );
198
- return returnValues?.map((value) => ({
199
- value,
200
- label: value,
191
+ const gridCell = rowNode
192
+ ? this.getGridApi().getGridCellFromRowNode(rowNode, column.columnId)
193
+ : undefined;
194
+ const valueOptions = await this.getGridApi().internalApi.getDistinctEditDisplayValuesForColumn({
195
+ columnId: column.columnId,
196
+ gridCell,
197
+ currentSearchValue: '',
198
+ });
199
+ if (!valueOptions?.length) {
200
+ return;
201
+ }
202
+ return valueOptions.map((opt) => ({
203
+ value: opt.value,
204
+ label: opt.label ?? String(opt.value),
201
205
  }));
202
206
  }
203
207
  }
@@ -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;
@@ -2229,10 +2229,12 @@ export class AdaptableAgGrid {
2229
2229
  return rawValue;
2230
2230
  }
2231
2231
  __updateColumnModelAndRefreshGrid_already_called = false;
2232
+ __forceUpdateColumnModel = false;
2232
2233
  updateColumnModelAndRefreshGrid() {
2233
- if (this.__updateColumnModelAndRefreshGrid_already_called) {
2234
+ if (this.__updateColumnModelAndRefreshGrid_already_called && !this.__forceUpdateColumnModel) {
2234
2235
  return;
2235
2236
  }
2237
+ this.__forceUpdateColumnModel = false;
2236
2238
  try {
2237
2239
  this._updateColumnModelAndRefreshGridNow();
2238
2240
  this.__updateColumnModelAndRefreshGrid_already_called = true;
@@ -4281,6 +4283,10 @@ export class AdaptableAgGrid {
4281
4283
  // this setGridOption call will also trigger layout.onColumnDefsChanged()
4282
4284
  // which will in turn call updateColumnModelAndRefreshGrid
4283
4285
  this.agGridAdapter.setGridOption('columnDefs', columnDefs);
4286
+ // the setGridOption call above already triggered updateColumnModelAndRefreshGrid,
4287
+ // setting the dedup guard. We force the next call so that the column model
4288
+ // is re-derived after the layout store has been updated.
4289
+ this.__forceUpdateColumnModel = true;
4284
4290
  // this is needed here for when we call setAdaptableStateKey
4285
4291
  // and pass a new config
4286
4292
  this.updateLayoutInManagerAfterStoreHasChanged();
package/src/env.js CHANGED
@@ -1,5 +1,5 @@
1
1
  export default {
2
2
  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" || '',
3
- PUBLISH_TIMESTAMP: 1773153884150 || Date.now(),
4
- VERSION: "22.0.2" || '--current-version--',
3
+ PUBLISH_TIMESTAMP: 1773747271741 || Date.now(),
4
+ VERSION: "22.0.4" || '--current-version--',
5
5
  };
@@ -26,6 +26,10 @@ export function destructurePivotColumnId(colDef, currentModel, logWarning) {
26
26
  const pivotColumnIds = pivotColsTxt.split('-');
27
27
  const pivotKeys = pivotKeysTxt.split('-');
28
28
  const pivotColumnId = pivotColumnIds[pivotKeys.length - 1];
29
+ if (aggregationColumnId !== '' && !currentModel.aggColIds.includes(aggregationColumnId)) {
30
+ logWarning(`Unknown aggregation column: ${aggregationColumnId}`);
31
+ return '!unknown!';
32
+ }
29
33
  return {
30
34
  pivotColumnIds,
31
35
  pivotKeys,
@@ -52,16 +56,18 @@ export function destructurePivotColumnId(colDef, currentModel, logWarning) {
52
56
  return {
53
57
  pivotColumnIds,
54
58
  pivotKeys,
55
- pivotColumnId: pivotColumnIds[pivotKeys.length],
59
+ pivotColumnId: pivotColumnIds[pivotKeys.length - 1],
56
60
  };
57
61
  }
58
- // For regular pivot columns, work backwards to find aggregation column
59
- const parts = withoutPrefix.split('_');
60
- const lastPart = parts[parts.length - 1];
61
- // Find the longest matching aggregation column id from the end
62
- const aggregationColumnId = currentModel.aggColIds.find((aggId) => lastPart.endsWith(aggId));
62
+ // For regular pivot columns, work backwards to find aggregation column.
63
+ // Check if the full string ends with _${aggColId} rather than splitting by _,
64
+ // since agg column IDs may themselves contain underscores (e.g. github_stars).
65
+ // Sort by length descending so the longest match wins.
66
+ const aggregationColumnId = [...currentModel.aggColIds]
67
+ .sort((a, b) => b.length - a.length)
68
+ .find((aggId) => withoutPrefix.endsWith('_' + aggId));
63
69
  if (!aggregationColumnId) {
64
- logWarning(`Could not identify aggregation column in: ${lastPart}`);
70
+ logWarning(`Could not identify aggregation column in: ${withoutPrefix}`);
65
71
  return '!unknown!';
66
72
  }
67
73
  // Remove aggregation part and get pivot columns
@@ -1279,10 +1279,22 @@ export class LayoutManager extends LMEmitter {
1279
1279
  this.computeColumnSorts(layout, columnState);
1280
1280
  this.computePinnedColumns(layout, columnState);
1281
1281
  this.computePivotAggregations(layout, columnState);
1282
- // Add pivot result columns to the state for ordering (will be applied with applyOrder: true later)
1282
+ // Add pivot result columns to the state for ordering (will be applied with applyOrder: true later).
1283
+ // Some pivot result columns may already be in the state (e.g. added by computeColumnSorts),
1284
+ // so remove them first and re-add all pivot result columns in the persisted order,
1285
+ // merging any existing state (like sort info) back in.
1283
1286
  if (Array.isArray(layout.PivotResultColumnsOrder)) {
1287
+ const pivotResultColumnsOrderSet = new Set(layout.PivotResultColumnsOrder);
1288
+ const existingPivotResultState = {};
1289
+ columnState.state = columnState.state.filter((colState) => {
1290
+ if (pivotResultColumnsOrderSet.has(colState.colId)) {
1291
+ existingPivotResultState[colState.colId] = colState;
1292
+ return false;
1293
+ }
1294
+ return true;
1295
+ });
1284
1296
  layout.PivotResultColumnsOrder.forEach((colId) => {
1285
- columnState.state.push({ colId });
1297
+ columnState.state.push(existingPivotResultState[colId] || { colId });
1286
1298
  });
1287
1299
  }
1288
1300
  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;