@platforma-sdk/ui-vue 1.8.24 → 1.8.25

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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@platforma-sdk/ui-vue",
3
- "version": "1.8.24",
3
+ "version": "1.8.25",
4
4
  "type": "module",
5
5
  "main": "dist/lib.umd.cjs",
6
6
  "module": "dist/lib.js",
@@ -37,8 +37,8 @@
37
37
  "@ag-grid-community/theming": "^32.3.3",
38
38
  "@ag-grid-enterprise/side-bar": "^32.3.3",
39
39
  "@ag-grid-enterprise/column-tool-panel": "^32.3.3",
40
- "@platforma-sdk/model": "^1.8.19",
41
- "@milaboratories/uikit": "^2.2.2"
40
+ "@milaboratories/uikit": "^2.2.2",
41
+ "@platforma-sdk/model": "^1.8.19"
42
42
  },
43
43
  "devDependencies": {
44
44
  "@faker-js/faker": "^8.4.1",
@@ -4,6 +4,7 @@ import type {
4
4
  GridApi,
5
5
  GridOptions,
6
6
  GridReadyEvent,
7
+ GridState,
7
8
  ManagedGridOptionKey,
8
9
  ManagedGridOptions,
9
10
  SortState,
@@ -139,9 +140,7 @@ const gridState = computed({
139
140
  // do not apply driver sorting for client side rendering
140
141
  const sorting = gridOptions.value.rowModelType === 'clientSide' ? undefined : makeSorting(gridState.sort);
141
142
 
142
- state.gridState.columnOrder = gridState.columnOrder;
143
- state.gridState.sort = gridState.sort;
144
- state.gridState.columnVisibility = gridState.columnVisibility;
143
+ state.gridState = { ...state.gridState, ...gridState };
145
144
 
146
145
  if (settings.value.sourceType === 'ptable' || settings.value.sourceType === 'pframe') {
147
146
  if (!state.pTableParams) {
@@ -314,22 +313,19 @@ const onGridReady = (event: GridReadyEvent) => {
314
313
  },
315
314
  });
316
315
  };
317
- const onStateUpdated = (event: StateUpdatedEvent) => {
318
- gridState.value = {
319
- columnOrder: event.state.columnOrder,
320
- sort: event.state.sort,
321
- columnVisibility: event.state.columnVisibility ?? (event.state.columnOrder ? { hiddenColIds: [] } : undefined),
322
- };
323
- gridOptions.value.initialState = gridState.value;
324
- };
325
- const onGridPreDestroyed = () => {
326
- const state = gridApi.value!.getState();
327
- gridState.value = {
316
+ const makePartialState = (state: GridState) => {
317
+ return {
328
318
  columnOrder: state.columnOrder,
329
319
  sort: state.sort,
330
320
  columnVisibility: state.columnVisibility ?? (state.columnOrder ? { hiddenColIds: [] } : undefined),
331
321
  };
332
- gridOptions.value.initialState = gridState.value;
322
+ };
323
+ const onStateUpdated = (event: StateUpdatedEvent) => {
324
+ gridOptions.value.initialState = gridState.value = makePartialState(event.state);
325
+ event.api.autoSizeAllColumns();
326
+ };
327
+ const onGridPreDestroyed = () => {
328
+ gridOptions.value.initialState = gridState.value = makePartialState(gridApi.value!.getState());
333
329
  gridApi.value = undefined;
334
330
  };
335
331
 
@@ -342,12 +338,7 @@ watch(
342
338
  const [gridApi, gridState] = state;
343
339
  if (!gridApi) return;
344
340
 
345
- const selfFullState = gridApi.getState();
346
- const selfState = {
347
- columnOrder: selfFullState.columnOrder,
348
- sort: selfFullState.sort,
349
- columnVisibility: selfFullState.columnVisibility ?? (selfFullState.columnOrder ? { hiddenColIds: [] } : undefined),
350
- };
341
+ const selfState = makePartialState(gridApi.getState());
351
342
  if (lodash.isEqual(gridState, selfState)) return;
352
343
 
353
344
  gridOptions.value.initialState = gridState;
@@ -280,9 +280,19 @@ export async function updatePFrameGridOptions(
280
280
  const specs = await pfDriver.getSpec(pt);
281
281
 
282
282
  // column indices in the specs array that we are going to process
283
- const indices = [...specs.keys()].filter(
284
- (i) => !lodash.find(sheets, (sheet) => lodash.isEqual(sheet.axis, specs[i].id) || lodash.isEqual(sheet.column, specs[i].id)),
285
- );
283
+ const indices = [...specs.keys()]
284
+ .filter((i) => !lodash.find(sheets, (sheet) => lodash.isEqual(sheet.axis, specs[i].id) || lodash.isEqual(sheet.column, specs[i].id)))
285
+ .sort((a, b) => {
286
+ if (specs[a].type !== specs[b].type) return specs[a].type === 'axis' ? -1 : 1;
287
+
288
+ const aPriority = specs[a].spec.annotations?.['pl7.app/table/orderPriority'];
289
+ const bPriority = specs[b].spec.annotations?.['pl7.app/table/orderPriority'];
290
+
291
+ if (aPriority === undefined) return bPriority === undefined ? 0 : 1;
292
+ if (bPriority === undefined) return -1;
293
+ return Number(bPriority) - Number(aPriority);
294
+ });
295
+
286
296
  const fields = lodash.cloneDeep(indices);
287
297
 
288
298
  // get columns with heterogeneous axes