@acorex/platform 20.8.7 → 20.8.9

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.
@@ -27,6 +27,7 @@ import * as i10 from '@acorex/core/translation';
27
27
  import { AXTranslationService, AXTranslationModule, translateSync } from '@acorex/core/translation';
28
28
  import { AXPAuthModule } from '@acorex/platform/auth';
29
29
  import { AXPThemeLayoutBlockComponent, AXPThemeLayoutHeaderComponent, AXPThemeLayoutToolbarComponent, AXPStateMessageComponent, AXPQueryFiltersComponent, AXPQuerySortsComponent, AXPQueryViewsComponent, AXPQueryColumnsComponent, AXPThemeLayoutStartSideComponent } from '@acorex/platform/layout/components';
30
+ import { AXPCategoryTreeService, AXPEntityListViewColumnViewModel, getDataSourcePageIndex, restoreEntityListExpandedRows } from '@acorex/platform/layout/entity';
30
31
  import * as i7$1 from '@acorex/platform/layout/widget-core';
31
32
  import { AXPWidgetCoreModule } from '@acorex/platform/layout/widget-core';
32
33
  import { AXPWidgetsModule } from '@acorex/platform/layout/widgets';
@@ -37,12 +38,12 @@ import { FormsModule } from '@angular/forms';
37
38
  import { AXDropdownButtonModule } from '@acorex/components/dropdown-button';
38
39
  import { AXPPageLayoutBaseComponent, AXPPageLayoutComponent, AXPPageLayoutBase } from '@acorex/platform/layout/views';
39
40
  import { AXPLayoutThemeService } from '@acorex/platform/themes/shared';
41
+ import { Subject, takeUntil } from 'rxjs';
40
42
  import * as i2$1 from '@acorex/components/skeleton';
41
43
  import { AXSkeletonModule } from '@acorex/components/skeleton';
42
44
  import { AXTreeViewModule, AXTreeViewComponent } from '@acorex/components/tree-view';
43
45
  import { AXPRefreshEvent, AXPSettingsService, AXPCommonSettings } from '@acorex/platform/common';
44
46
  import { AXHighlightService, AXPDeviceService } from '@acorex/platform/core';
45
- import { AXPCategoryTreeService, AXPEntityListViewColumnViewModel } from '@acorex/platform/layout/entity';
46
47
  import { AXPWorkflowService, ofType } from '@acorex/platform/workflow';
47
48
  import { takeUntilDestroyed } from '@angular/core/rxjs-interop';
48
49
  import { isEqual } from 'lodash-es';
@@ -1089,7 +1090,10 @@ class AXPEntityMasterToolbarViewComponent {
1089
1090
  this.sortQueries = computed(() => this.vm
1090
1091
  .sortedFields()
1091
1092
  .filter((s) => !!s.dir)
1092
- .map((s) => ({ name: s.name, dir: s.dir })), ...(ngDevMode ? [{ debugName: "sortQueries" }] : []));
1093
+ .map((s) => ({
1094
+ name: s.name,
1095
+ dir: s.dir,
1096
+ })), ...(ngDevMode ? [{ debugName: "sortQueries" }] : []));
1093
1097
  this.sortDefinitions = computed(() => this.vm.sortableFields().map((s) => ({
1094
1098
  name: s.name,
1095
1099
  title: s.title,
@@ -1100,6 +1104,7 @@ class AXPEntityMasterToolbarViewComponent {
1100
1104
  // Prefer saved settings (view/columns/sorts/filters) if available, then apply
1101
1105
  await this.loadSettings();
1102
1106
  await this.vm.setView();
1107
+ await this.vm.ensureListPagingResolved();
1103
1108
  this.filtersDefinitions.set(this.vm.filtersDef);
1104
1109
  this.isInitializing = true;
1105
1110
  // this.pendingInitialFilters = true;
@@ -1191,6 +1196,9 @@ class AXPEntityMasterToolbarViewComponent {
1191
1196
  const byKey = new Map(prev.map((c) => [keyOf(c), c]));
1192
1197
  return columns.map((newColumn) => {
1193
1198
  const existing = byKey.get(keyOf(newColumn));
1199
+ if (!existing) {
1200
+ return null;
1201
+ }
1194
1202
  return new AXPEntityListViewColumnViewModel(existing.property, {
1195
1203
  ...existing.column,
1196
1204
  options: {
@@ -1198,7 +1206,7 @@ class AXPEntityMasterToolbarViewComponent {
1198
1206
  visible: newColumn.visible,
1199
1207
  },
1200
1208
  });
1201
- });
1209
+ }).filter((c) => c != null);
1202
1210
  });
1203
1211
  // Persist column order/visibility
1204
1212
  this.vm.onColumnsChanged(this.vm.columns());
@@ -1245,6 +1253,9 @@ class AXPEntityMasterListViewComponent extends AXPPageLayoutBaseComponent {
1245
1253
  this.grid = viewChild('grid', ...(ngDevMode ? [{ debugName: "grid" }] : []));
1246
1254
  this.initializedFromRoute = false;
1247
1255
  this.lastEvaluatedViewName = null;
1256
+ this.componentDestroyed = new Subject();
1257
+ this.isRestoringExpandedRows = false;
1258
+ this.restoreExpandedRowsScheduled = false;
1248
1259
  this.commandRowItems = computed(() => {
1249
1260
  return this.vm.primaryRowActions().map((c) => {
1250
1261
  return {
@@ -1278,9 +1289,17 @@ class AXPEntityMasterListViewComponent extends AXPPageLayoutBaseComponent {
1278
1289
  this.updateParentHasChildAfterRefresh(refreshTargetId);
1279
1290
  }
1280
1291
  else {
1292
+ if (!resetPagination) {
1293
+ await this.vm.ensureListPagingResolved();
1294
+ this.vm.applyPagingToDataSourceWithoutLoad();
1295
+ }
1281
1296
  this.grid()?.refresh({
1282
1297
  reset: resetPagination,
1283
1298
  });
1299
+ if (!resetPagination) {
1300
+ this.scheduleSyncGridPagerUi();
1301
+ }
1302
+ this.scheduleRestoreExpandedRows();
1284
1303
  }
1285
1304
  }
1286
1305
  });
@@ -1310,6 +1329,7 @@ class AXPEntityMasterListViewComponent extends AXPPageLayoutBaseComponent {
1310
1329
  if (this.lastEvaluatedViewName !== currentViewName) {
1311
1330
  this.lastEvaluatedViewName = currentViewName;
1312
1331
  this.recompute();
1332
+ this.scheduleRestoreExpandedRows();
1313
1333
  }
1314
1334
  });
1315
1335
  }
@@ -1318,6 +1338,7 @@ class AXPEntityMasterListViewComponent extends AXPPageLayoutBaseComponent {
1318
1338
  this.queryParamSub = this.activeRoute.queryParamMap.subscribe(async (qp) => {
1319
1339
  const viewFromUrl = qp.get('view');
1320
1340
  await this.vm.setView(viewFromUrl);
1341
+ this.scheduleRestoreExpandedRows();
1321
1342
  });
1322
1343
  }
1323
1344
  async ngAfterViewInit() {
@@ -1334,6 +1355,8 @@ class AXPEntityMasterListViewComponent extends AXPPageLayoutBaseComponent {
1334
1355
  });
1335
1356
  }
1336
1357
  this.initializedFromRoute = true;
1358
+ this.bindExpandedRowPersistence();
1359
+ this.scheduleRestoreExpandedRows();
1337
1360
  }
1338
1361
  onColumnSizeChanged(e) {
1339
1362
  if (e.isUserInteraction && e.type === 'end') {
@@ -1341,12 +1364,10 @@ class AXPEntityMasterListViewComponent extends AXPPageLayoutBaseComponent {
1341
1364
  }
1342
1365
  }
1343
1366
  onPageChanged(e) {
1344
- if (e.isUserInteraction) {
1345
- const pageSizeChanged = e.take != this.vm.dataSource.pageSize;
1346
- if (pageSizeChanged) {
1347
- this.vm.saveSettings('pageSize', e.take);
1348
- }
1367
+ if (e.isUserInteraction && !this.vm.skipListPagingPersistence) {
1368
+ this.vm.saveListPaging(e.take, e.skip);
1349
1369
  }
1370
+ this.scheduleRestoreExpandedRows();
1350
1371
  }
1351
1372
  onColumnsOrderChanged(e) {
1352
1373
  if (e.isUserInteraction) {
@@ -1491,9 +1512,94 @@ class AXPEntityMasterListViewComponent extends AXPPageLayoutBaseComponent {
1491
1512
  this.toggleEndSide();
1492
1513
  }
1493
1514
  ngOnDestroy() {
1515
+ this.componentDestroyed.next();
1516
+ this.componentDestroyed.complete();
1494
1517
  this.queryParamSub?.unsubscribe();
1495
1518
  this.vm.destroy();
1496
1519
  }
1520
+ bindExpandedRowPersistence() {
1521
+ if (!this.vm.parentKey()) {
1522
+ return;
1523
+ }
1524
+ this.vm.dataSource.onItemExpanded.pipe(takeUntil(this.componentDestroyed)).subscribe((event) => {
1525
+ const expandedItem = event?.expandedItem;
1526
+ if (expandedItem && typeof expandedItem === 'object') {
1527
+ this.vm.handleRowExpandChange(expandedItem);
1528
+ }
1529
+ });
1530
+ }
1531
+ scheduleSyncGridPagerUi() {
1532
+ queueMicrotask(() => {
1533
+ this.syncGridPagerUi();
1534
+ });
1535
+ }
1536
+ syncGridPagerUi() {
1537
+ const gridRef = this.grid();
1538
+ if (!gridRef) {
1539
+ return;
1540
+ }
1541
+ const pageIndex = getDataSourcePageIndex(this.vm.dataSource);
1542
+ const take = this.vm.dataSource.config.pageSize;
1543
+ const pagerPage = pageIndex + 1;
1544
+ const grid = gridRef;
1545
+ this.vm.skipListPagingPersistence = true;
1546
+ try {
1547
+ if (grid.page() !== pageIndex) {
1548
+ grid.page.set(pageIndex);
1549
+ }
1550
+ grid.pageSize.set(take);
1551
+ const pager = grid.dataPager;
1552
+ if (pager && pager.value !== pagerPage) {
1553
+ pager.goToPage(pagerPage);
1554
+ }
1555
+ }
1556
+ finally {
1557
+ this.vm.skipListPagingPersistence = false;
1558
+ }
1559
+ }
1560
+ scheduleRestoreExpandedRows() {
1561
+ if (!this.vm.parentKey() || this.restoreExpandedRowsScheduled) {
1562
+ return;
1563
+ }
1564
+ this.restoreExpandedRowsScheduled = true;
1565
+ queueMicrotask(() => {
1566
+ this.restoreExpandedRowsScheduled = false;
1567
+ void this.restoreExpandedRows();
1568
+ });
1569
+ }
1570
+ async restoreExpandedRows() {
1571
+ if (!this.vm.parentKey() || this.isRestoringExpandedRows) {
1572
+ return;
1573
+ }
1574
+ const expandedRowIds = this.vm.getExpandedRowIds();
1575
+ if (!expandedRowIds.length) {
1576
+ return;
1577
+ }
1578
+ const gridRef = this.grid();
1579
+ if (!gridRef || gridRef.dataSource.isLoading) {
1580
+ return;
1581
+ }
1582
+ const gridWithDisplayedRows = gridRef;
1583
+ const displayedRows = gridWithDisplayedRows.displayedRows?.() ?? [];
1584
+ if (!displayedRows.length) {
1585
+ return;
1586
+ }
1587
+ this.isRestoringExpandedRows = true;
1588
+ this.vm.skipExpandedRowPersistence = true;
1589
+ try {
1590
+ const rowKey = this.vm.dataSource.config?.key ?? 'id';
1591
+ await restoreEntityListExpandedRows({
1592
+ expandedRowIds,
1593
+ rowKey,
1594
+ getDisplayedRows: () => gridWithDisplayedRows.displayedRows?.() ?? [],
1595
+ expandRow: (row) => gridRef.expandRow(row),
1596
+ });
1597
+ }
1598
+ finally {
1599
+ this.vm.skipExpandedRowPersistence = false;
1600
+ this.isRestoringExpandedRows = false;
1601
+ }
1602
+ }
1497
1603
  toggleCategoryDrawer() {
1498
1604
  this.toggleStartSide();
1499
1605
  }
@@ -1607,4 +1713,4 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.19", ngImpo
1607
1713
  }], ctorParameters: () => [{ type: i1$1.AXPlatform }], propDecorators: { grid: [{ type: i0.ViewChild, args: ['grid', { isSignal: true }] }] } });
1608
1714
 
1609
1715
  export { AXPEntityMasterListViewComponent };
1610
- //# sourceMappingURL=acorex-platform-themes-default-entity-master-list-view.component-DZeByyDy.mjs.map
1716
+ //# sourceMappingURL=acorex-platform-themes-default-entity-master-list-view.component-D2CtNrSn.mjs.map