@platforma-sdk/ui-vue 1.8.18 → 1.8.20

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.18",
3
+ "version": "1.8.20",
4
4
  "type": "module",
5
5
  "main": "dist/lib.umd.cjs",
6
6
  "module": "dist/lib.js",
@@ -35,8 +35,10 @@
35
35
  "@ag-grid-enterprise/menu": "^32.3.2",
36
36
  "@ag-grid-enterprise/excel-export": "^32.3.2",
37
37
  "@ag-grid-community/theming": "^32.3.2",
38
- "@milaboratories/uikit": "^2.2.0",
39
- "@platforma-sdk/model": "^1.8.0"
38
+ "@ag-grid-enterprise/side-bar": "^32.3.2",
39
+ "@ag-grid-enterprise/column-tool-panel": "^32.3.2",
40
+ "@platforma-sdk/model": "^1.8.19",
41
+ "@milaboratories/uikit": "^2.2.1"
40
42
  },
41
43
  "devDependencies": {
42
44
  "@faker-js/faker": "^8.4.1",
package/src/aggrid.ts CHANGED
@@ -11,6 +11,8 @@ import { RangeSelectionModule } from '@ag-grid-enterprise/range-selection';
11
11
  import { RichSelectModule } from '@ag-grid-enterprise/rich-select';
12
12
  import { MenuModule } from '@ag-grid-enterprise/menu';
13
13
  import { ExcelExportModule } from '@ag-grid-enterprise/excel-export';
14
+ import { SideBarModule } from '@ag-grid-enterprise/side-bar';
15
+ import { ColumnsToolPanelModule } from '@ag-grid-enterprise/column-tool-panel';
14
16
  import { type Theme, themeQuartz } from '@ag-grid-community/theming';
15
17
 
16
18
  export function activateAgGrid() {
@@ -24,6 +26,8 @@ export function activateAgGrid() {
24
26
  RichSelectModule,
25
27
  MenuModule,
26
28
  ExcelExportModule,
29
+ SideBarModule,
30
+ ColumnsToolPanelModule,
27
31
  ]);
28
32
  const agGridLicense = getEnvironmentValue('AGGRID_LICENSE');
29
33
  if (agGridLicense) {
@@ -11,6 +11,8 @@ import type {
11
11
  } from '@ag-grid-community/core';
12
12
  import { ModuleRegistry } from '@ag-grid-community/core';
13
13
  import { ServerSideRowModelModule } from '@ag-grid-enterprise/server-side-row-model';
14
+ import { SideBarModule } from '@ag-grid-enterprise/side-bar';
15
+ import { ColumnsToolPanelModule } from '@ag-grid-enterprise/column-tool-panel';
14
16
  import { AgGridVue } from '@ag-grid-community/vue3';
15
17
  import { ClipboardModule } from '@ag-grid-enterprise/clipboard';
16
18
  import { RangeSelectionModule } from '@ag-grid-enterprise/range-selection';
@@ -26,7 +28,14 @@ import { updateXsvGridOptions } from './sources/file-source';
26
28
  import { enrichJoinWithLabelColumns, makeSheets, parseColId, updatePFrameGridOptions } from './sources/table-source';
27
29
  import type { PlDataTableSettings, PlDataTableSheet } from './types';
28
30
 
29
- ModuleRegistry.registerModules([ClientSideRowModelModule, ClipboardModule, ServerSideRowModelModule, RangeSelectionModule]);
31
+ ModuleRegistry.registerModules([
32
+ ClientSideRowModelModule,
33
+ ClipboardModule,
34
+ ServerSideRowModelModule,
35
+ RangeSelectionModule,
36
+ SideBarModule,
37
+ ColumnsToolPanelModule
38
+ ]);
30
39
 
31
40
  const tableState = defineModel<PlDataTableState>({ default: { gridState: {} } });
32
41
  const props = defineProps<{
@@ -121,6 +130,7 @@ const gridState = computed({
121
130
  return {
122
131
  columnOrder: state.gridState.columnOrder,
123
132
  sort: state.gridState.sort,
133
+ columnVisibility: state.gridState.columnVisibility,
124
134
  };
125
135
  },
126
136
  set: (gridState) => {
@@ -131,6 +141,7 @@ const gridState = computed({
131
141
 
132
142
  state.gridState.columnOrder = gridState.columnOrder;
133
143
  state.gridState.sort = gridState.sort;
144
+ state.gridState.columnVisibility = gridState.columnVisibility;
134
145
 
135
146
  if (settings.value.sourceType === 'ptable' || settings.value.sourceType === 'pframe') {
136
147
  if (!state.pTableParams) {
@@ -252,6 +263,27 @@ const gridOptions = ref<GridOptions>({
252
263
  loadingOverlayComponentParams: { notReady: true },
253
264
  loadingOverlayComponent: PlOverlayLoading,
254
265
  noRowsOverlayComponent: PlOverlayNoRows,
266
+ sideBar: {
267
+ toolPanels: [
268
+ {
269
+ id: 'columns',
270
+ labelDefault: 'Columns',
271
+ labelKey: 'columns',
272
+ iconKey: 'columns',
273
+ toolPanel: 'agColumnsToolPanel',
274
+ toolPanelParams: {
275
+ suppressRowGroups: true,
276
+ suppressValues: true,
277
+ suppressPivots: true,
278
+ suppressPivotMode: true,
279
+ suppressColumnFilter: true,
280
+ suppressColumnSelectAll: true,
281
+ suppressColumnExpandAll: true,
282
+ },
283
+ },
284
+ ],
285
+ defaultToolPanel: 'columns',
286
+ },
255
287
  });
256
288
  const onGridReady = (event: GridReadyEvent) => {
257
289
  const api = event.api;
@@ -283,6 +315,8 @@ const onStateUpdated = (event: StateUpdatedEvent) => {
283
315
  gridState.value = {
284
316
  columnOrder: event.state.columnOrder,
285
317
  sort: event.state.sort,
318
+ columnVisibility: event.state.columnVisibility
319
+ ?? (event.state.columnOrder ? { hiddenColIds: [] } : undefined),
286
320
  };
287
321
  gridOptions.value.initialState = gridState.value;
288
322
  };
@@ -291,6 +325,8 @@ const onGridPreDestroyed = () => {
291
325
  gridState.value = {
292
326
  columnOrder: state.columnOrder,
293
327
  sort: state.sort,
328
+ columnVisibility: state.columnVisibility
329
+ ?? (state.columnOrder ? { hiddenColIds: [] } : undefined),
294
330
  };
295
331
  gridOptions.value.initialState = gridState.value;
296
332
  gridApi.value = undefined;
@@ -309,6 +345,8 @@ watch(
309
345
  const selfState = {
310
346
  columnOrder: selfFullState.columnOrder,
311
347
  sort: selfFullState.sort,
348
+ columnVisibility: selfFullState.columnVisibility
349
+ ?? (selfFullState.columnOrder ? { hiddenColIds: [] } : undefined),
312
350
  };
313
351
  if (lodash.isEqual(gridState, selfState)) return;
314
352
 
@@ -360,7 +398,8 @@ watch(
360
398
  columnDefs: [],
361
399
  });
362
400
  }
363
- const options = await updatePFrameGridOptions(pfDriver, pTable, sheets);
401
+ const hiddenColIds = gridState.value?.columnVisibility?.hiddenColIds;
402
+ const options = await updatePFrameGridOptions(pfDriver, pTable, sheets, hiddenColIds);
364
403
  return gridApi.updateGridOptions({
365
404
  loading: options.rowModelType !== 'clientSide',
366
405
  loadingOverlayComponentParams: { notReady: false },
@@ -52,12 +52,14 @@ export const defaultValueFormatter = (value: any) => {
52
52
  /**
53
53
  * Calculates column definition for a given p-table column
54
54
  */
55
- function getColDef(iCol: number, spec: PTableColumnSpec): ColDef {
55
+ function getColDef(iCol: number, spec: PTableColumnSpec, hiddenColIds?: string[]): ColDef {
56
+ const colId = makeColId(spec);
56
57
  return {
57
- colId: makeColId(spec),
58
+ colId,
58
59
  field: iCol.toString(),
59
60
  headerName: spec.spec.annotations?.['pl7.app/label']?.trim() ?? 'Unlabeled ' + spec.type + ' ' + iCol.toString(),
60
61
  lockPosition: spec.type === 'axis',
62
+ hide: hiddenColIds?.includes(colId) ?? spec.spec.annotations?.['pl7.app/table/visibility'] === 'optional',
61
63
  valueFormatter: defaultValueFormatter,
62
64
  cellDataType: ((valueType: ValueType) => {
63
65
  switch (valueType) {
@@ -268,6 +270,7 @@ export async function updatePFrameGridOptions(
268
270
  pfDriver: PFrameDriver,
269
271
  pt: PTableHandle,
270
272
  sheets: PlDataTableSheet[],
273
+ hiddenColIds?: string[],
271
274
  ): Promise<{
272
275
  columnDefs: ColDef[];
273
276
  serverSideDatasource?: IServerSideDatasource;
@@ -309,7 +312,7 @@ export async function updatePFrameGridOptions(
309
312
 
310
313
  const ptShape = await pfDriver.getShape(pt);
311
314
  const rowCount = ptShape.rows;
312
- const columnDefs = fields.map((i) => getColDef(i, specs[i]));
315
+ const columnDefs = fields.map((i) => getColDef(i, specs[i], hiddenColIds));
313
316
 
314
317
  if (hColumns.length > 1) {
315
318
  console.warn('Currently, only one heterogeneous axis is supported in the table, got', hColumns.length, ' transposition will not be applied.');