@platforma-sdk/ui-vue 1.7.17 → 1.7.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/CHANGELOG.md +13 -0
- package/dist/lib.js +2753 -2732
- package/dist/lib.umd.cjs +21 -21
- package/dist/src/components/PlAgDataTable/PlAgDataTable.vue.d.ts.map +1 -1
- package/dist/src/components/PlAgDataTable/sources/file-source.d.ts +2 -2
- package/dist/src/components/PlAgDataTable/sources/file-source.d.ts.map +1 -1
- package/dist/src/components/PlAgDataTable/sources/table-source.d.ts +2 -2
- package/dist/src/components/PlAgDataTable/sources/table-source.d.ts.map +1 -1
- package/dist/style.css +1 -1
- package/dist/tsconfig.lib.tsbuildinfo +1 -1
- package/package.json +3 -3
- package/src/components/PlAgDataTable/PlAgDataTable.vue +56 -24
- package/src/components/PlAgDataTable/sources/file-source.ts +1 -3
- package/src/components/PlAgDataTable/sources/table-source.ts +7 -4
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@platforma-sdk/ui-vue",
|
|
3
|
-
"version": "1.7.
|
|
3
|
+
"version": "1.7.20",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"main": "dist/lib.umd.cjs",
|
|
6
6
|
"module": "dist/lib.js",
|
|
@@ -35,7 +35,7 @@
|
|
|
35
35
|
"@ag-grid-enterprise/menu": "^32.3.0",
|
|
36
36
|
"@ag-grid-enterprise/excel-export": "^32.3.0",
|
|
37
37
|
"@milaboratories/uikit": "^1.2.26",
|
|
38
|
-
"@platforma-sdk/model": "^1.7.
|
|
38
|
+
"@platforma-sdk/model": "^1.7.20"
|
|
39
39
|
},
|
|
40
40
|
"devDependencies": {
|
|
41
41
|
"@faker-js/faker": "^8.4.1",
|
|
@@ -58,7 +58,7 @@
|
|
|
58
58
|
"vue-tsc": "^2.1.6",
|
|
59
59
|
"zod": "^3.23.8",
|
|
60
60
|
"yarpm": "^1.2.0",
|
|
61
|
-
"@milaboratories/helpers": "^1.6.
|
|
61
|
+
"@milaboratories/helpers": "^1.6.6"
|
|
62
62
|
},
|
|
63
63
|
"scripts": {
|
|
64
64
|
"test": "vitest run --passWithNoTests",
|
|
@@ -1,7 +1,15 @@
|
|
|
1
1
|
<script lang="ts" setup>
|
|
2
2
|
import './ag-theme.css';
|
|
3
3
|
import { ClientSideRowModelModule } from '@ag-grid-community/client-side-row-model';
|
|
4
|
-
import type {
|
|
4
|
+
import type {
|
|
5
|
+
GridApi,
|
|
6
|
+
GridOptions,
|
|
7
|
+
GridReadyEvent,
|
|
8
|
+
ManagedGridOptionKey,
|
|
9
|
+
ManagedGridOptions,
|
|
10
|
+
SortState,
|
|
11
|
+
StateUpdatedEvent,
|
|
12
|
+
} from '@ag-grid-community/core';
|
|
5
13
|
import { ModuleRegistry } from '@ag-grid-community/core';
|
|
6
14
|
import { ServerSideRowModelModule } from '@ag-grid-enterprise/server-side-row-model';
|
|
7
15
|
import { AgGridVue } from '@ag-grid-community/vue3';
|
|
@@ -225,13 +233,7 @@ const gridOptions = ref<GridOptions>({
|
|
|
225
233
|
animateRows: false,
|
|
226
234
|
suppressColumnMoveAnimation: true,
|
|
227
235
|
cellSelection: true,
|
|
228
|
-
initialState:
|
|
229
|
-
onStateUpdated: (event) => {
|
|
230
|
-
gridState.value = {
|
|
231
|
-
columnOrder: event.state.columnOrder,
|
|
232
|
-
sort: event.state.sort,
|
|
233
|
-
};
|
|
234
|
-
},
|
|
236
|
+
initialState: gridState.value,
|
|
235
237
|
autoSizeStrategy: { type: 'fitCellContents' },
|
|
236
238
|
onRowDataUpdated: (event) => {
|
|
237
239
|
event.api.autoSizeAllColumns();
|
|
@@ -239,6 +241,8 @@ const gridOptions = ref<GridOptions>({
|
|
|
239
241
|
rowModelType: 'clientSide',
|
|
240
242
|
maxBlocksInCache: 10000,
|
|
241
243
|
cacheBlockSize: 100,
|
|
244
|
+
serverSideSortAllLevels: true,
|
|
245
|
+
suppressServerSideFullWidthLoadingRow: true,
|
|
242
246
|
getRowId: (params) => params.data.id,
|
|
243
247
|
loading: true,
|
|
244
248
|
loadingOverlayComponentParams: { notReady: true },
|
|
@@ -271,6 +275,22 @@ const onGridReady = (event: GridReadyEvent) => {
|
|
|
271
275
|
},
|
|
272
276
|
});
|
|
273
277
|
};
|
|
278
|
+
const onStateUpdated = (event: StateUpdatedEvent) => {
|
|
279
|
+
gridState.value = {
|
|
280
|
+
columnOrder: event.state.columnOrder,
|
|
281
|
+
sort: event.state.sort,
|
|
282
|
+
};
|
|
283
|
+
gridOptions.value.initialState = gridState.value;
|
|
284
|
+
};
|
|
285
|
+
const onGridPreDestroyed = () => {
|
|
286
|
+
const state = gridApi.value!.getState();
|
|
287
|
+
gridState.value = {
|
|
288
|
+
columnOrder: state.columnOrder,
|
|
289
|
+
sort: state.sort,
|
|
290
|
+
};
|
|
291
|
+
gridOptions.value.initialState = gridState.value;
|
|
292
|
+
gridApi.value = undefined;
|
|
293
|
+
};
|
|
274
294
|
|
|
275
295
|
const reloadKey = ref(0);
|
|
276
296
|
watch(
|
|
@@ -281,9 +301,21 @@ watch(
|
|
|
281
301
|
const [gridApi, gridState] = state;
|
|
282
302
|
if (!gridApi) return;
|
|
283
303
|
|
|
284
|
-
const
|
|
285
|
-
|
|
286
|
-
|
|
304
|
+
const selfFullState = gridApi.getState();
|
|
305
|
+
const selfState = {
|
|
306
|
+
columnOrder: selfFullState.columnOrder,
|
|
307
|
+
sort: selfFullState.sort,
|
|
308
|
+
};
|
|
309
|
+
if (lodash.isEqual(gridState, selfState)) return;
|
|
310
|
+
|
|
311
|
+
console.log(
|
|
312
|
+
'reloading; columnOrder changed',
|
|
313
|
+
!lodash.isEqual(gridState.columnOrder, selfState.columnOrder),
|
|
314
|
+
'saved',
|
|
315
|
+
gridState.columnOrder,
|
|
316
|
+
'current',
|
|
317
|
+
selfState.columnOrder,
|
|
318
|
+
);
|
|
287
319
|
gridOptions.value.initialState = gridState;
|
|
288
320
|
++reloadKey.value;
|
|
289
321
|
},
|
|
@@ -292,16 +324,7 @@ watch(
|
|
|
292
324
|
() => gridOptions.value,
|
|
293
325
|
(options, oldOptions) => {
|
|
294
326
|
if (!oldOptions) return;
|
|
295
|
-
if (options.rowModelType != oldOptions.rowModelType)
|
|
296
|
-
console.log('reloading gridOptions');
|
|
297
|
-
options.loading = false;
|
|
298
|
-
options.columnDefs = [];
|
|
299
|
-
options.rowData = undefined;
|
|
300
|
-
options.serverSideDatasource = undefined;
|
|
301
|
-
gridOptions.value = options;
|
|
302
|
-
gridApi.value = undefined;
|
|
303
|
-
++reloadKey.value;
|
|
304
|
-
}
|
|
327
|
+
if (options.rowModelType != oldOptions.rowModelType) ++reloadKey.value;
|
|
305
328
|
},
|
|
306
329
|
);
|
|
307
330
|
|
|
@@ -337,8 +360,9 @@ watch(
|
|
|
337
360
|
columnDefs: [],
|
|
338
361
|
});
|
|
339
362
|
}
|
|
340
|
-
const options = await updatePFrameGridOptions(
|
|
363
|
+
const options = await updatePFrameGridOptions(pfDriver, pTable, sheets);
|
|
341
364
|
return gridApi.updateGridOptions({
|
|
365
|
+
loading: options.rowModelType !== 'clientSide',
|
|
342
366
|
loadingOverlayComponentParams: { notReady: false },
|
|
343
367
|
...options,
|
|
344
368
|
});
|
|
@@ -357,8 +381,9 @@ watch(
|
|
|
357
381
|
});
|
|
358
382
|
}
|
|
359
383
|
|
|
360
|
-
const options = await updateXsvGridOptions(
|
|
384
|
+
const options = await updateXsvGridOptions(blobDriver, xsvFile.value);
|
|
361
385
|
return gridApi.updateGridOptions({
|
|
386
|
+
loading: true,
|
|
362
387
|
loadingOverlayComponentParams: { notReady: false },
|
|
363
388
|
...options,
|
|
364
389
|
});
|
|
@@ -384,7 +409,14 @@ watch(
|
|
|
384
409
|
/>
|
|
385
410
|
</div>
|
|
386
411
|
</Transition>
|
|
387
|
-
<AgGridVue
|
|
412
|
+
<AgGridVue
|
|
413
|
+
class="ap-ag-data-table-grid"
|
|
414
|
+
:grid-options="gridOptions"
|
|
415
|
+
:key="reloadKey"
|
|
416
|
+
@grid-ready="onGridReady"
|
|
417
|
+
@state-updated="onStateUpdated"
|
|
418
|
+
@grid-pre-destroyed="onGridPreDestroyed"
|
|
419
|
+
/>
|
|
388
420
|
</div>
|
|
389
421
|
</template>
|
|
390
422
|
|
|
@@ -1,15 +1,13 @@
|
|
|
1
|
-
import type { ColDef,
|
|
1
|
+
import type { ColDef, IDatasource } from '@ag-grid-community/core';
|
|
2
2
|
import type { BlobDriver, LocalBlobHandleAndSize, RemoteBlobHandleAndSize } from '@platforma-sdk/model';
|
|
3
3
|
|
|
4
4
|
export async function updateXsvGridOptions(
|
|
5
|
-
gridApi: GridApi,
|
|
6
5
|
blobDriver: BlobDriver,
|
|
7
6
|
file: LocalBlobHandleAndSize | RemoteBlobHandleAndSize,
|
|
8
7
|
): Promise<{
|
|
9
8
|
columnDefs: ColDef[];
|
|
10
9
|
datasource: IDatasource;
|
|
11
10
|
}> {
|
|
12
|
-
gridApi;
|
|
13
11
|
blobDriver;
|
|
14
12
|
file;
|
|
15
13
|
//blobDriver.getContent(file.handle!)
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { ColDef,
|
|
1
|
+
import type { ColDef, IServerSideDatasource, IServerSideGetRowsParams, RowModelType } from '@ag-grid-community/core';
|
|
2
2
|
import type { AxisId, JoinEntry, PColumnIdAndSpec, PFrameHandle, PObjectId } from '@platforma-sdk/model';
|
|
3
3
|
import {
|
|
4
4
|
type PColumnSpec,
|
|
@@ -273,7 +273,6 @@ const isLabelColumn = (col: PTableColumnSpec) => col.type === 'column' && col.sp
|
|
|
273
273
|
* Calculate GridOptions for p-table data source type
|
|
274
274
|
*/
|
|
275
275
|
export async function updatePFrameGridOptions(
|
|
276
|
-
gridApi: GridApi,
|
|
277
276
|
pfDriver: PFrameDriver,
|
|
278
277
|
pt: PTableHandle,
|
|
279
278
|
sheets: PlDataTableSheet[],
|
|
@@ -335,7 +334,8 @@ export async function updatePFrameGridOptions(
|
|
|
335
334
|
try {
|
|
336
335
|
if (rowCount == 0) {
|
|
337
336
|
params.success({ rowData: [], rowCount });
|
|
338
|
-
|
|
337
|
+
params.api.showNoRowsOverlay();
|
|
338
|
+
params.api.setGridOption('loading', false);
|
|
339
339
|
return;
|
|
340
340
|
}
|
|
341
341
|
|
|
@@ -343,6 +343,7 @@ export async function updatePFrameGridOptions(
|
|
|
343
343
|
if (lastParams && !lodash.isEqual(lastParams.request.sortModel, params.request.sortModel)) {
|
|
344
344
|
lastParams = undefined;
|
|
345
345
|
params.fail();
|
|
346
|
+
params.api.setGridOption('loading', true);
|
|
346
347
|
return;
|
|
347
348
|
}
|
|
348
349
|
lastParams = params;
|
|
@@ -361,9 +362,11 @@ export async function updatePFrameGridOptions(
|
|
|
361
362
|
}
|
|
362
363
|
|
|
363
364
|
params.success({ rowData, rowCount });
|
|
364
|
-
|
|
365
|
+
params.api.autoSizeAllColumns();
|
|
366
|
+
params.api.setGridOption('loading', false);
|
|
365
367
|
} catch (error: unknown) {
|
|
366
368
|
params.fail();
|
|
369
|
+
params.api.setGridOption('loading', true);
|
|
367
370
|
}
|
|
368
371
|
},
|
|
369
372
|
} satisfies IServerSideDatasource;
|