@igo2/integration 21.0.0-next.40 → 21.0.0-next.42

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.
@@ -26,7 +26,7 @@ import { BehaviorSubject, combineLatest, forkJoin, map as map$1, of, merge, Subj
26
26
  import { take, switchMap, concatAll, map, toArray, skipWhile, distinctUntilChanged, takeUntil, tap, debounceTime, skip } from 'rxjs/operators';
27
27
  import { StorageService, StorageScope, StorageServiceEventEnum } from '@igo2/core/storage';
28
28
  import { ContextService, ContextEditComponent, ContextListComponent, ContextPermissionsComponent, ShareMapComponent, ContextImportExportComponent } from '@igo2/context';
29
- import { createExcelWorkBook, addExcelSheetToWorkBook, writeExcelFile, ObjectUtils, uuid, NumberUtils } from '@igo2/utils';
29
+ import { ObjectUtils, createExcelWorkBook, addExcelSheetToWorkBook, writeExcelFile, uuid, NumberUtils } from '@igo2/utils';
30
30
  import { toSignal, toObservable, takeUntilDestroyed } from '@angular/core/rxjs-interop';
31
31
  import { MediaService, Media } from '@igo2/core/media';
32
32
  import { MessageService } from '@igo2/core/message';
@@ -661,34 +661,34 @@ let CatalogLibraryToolComponent = class CatalogLibraryToolComponent {
661
661
  .map((layer) => getInfoFromSourceOptions(layer.sourceOptions, detailedContext.title ?? detailedContext.uri ?? ''));
662
662
  }), concatAll(), toArray());
663
663
  }
664
+ /**
665
+ * Sort items like the catalog browser display does (by title when a direction is set)
666
+ */
667
+ sortItemsForDisplay(items, direction) {
668
+ if (direction === undefined) {
669
+ return items;
670
+ }
671
+ return [...items].sort((a, b) => ObjectUtils.naturalCompare(a.title, b.title, direction));
672
+ }
664
673
  listExportFromCatalogs() {
665
- let rank = 1;
666
- const finalListExportOutputs = [];
667
674
  return this.store.entities$.pipe(switchMap((catalogs) => combineLatest(catalogs.map((catalog) => this.catalogService.loadCatalogItems(catalog).pipe(map((items) => {
668
675
  return { catalog, items };
669
676
  }))))), map((catalogsWithItems) => {
670
- catalogsWithItems.forEach((catalogAndItems) => {
671
- const catalog = catalogAndItems.catalog;
672
- const loadedCatalogItems = catalogAndItems.items;
673
- const catalogListExports = loadedCatalogItems.reduce((catalogListExports, item) => {
677
+ let rank = 1;
678
+ const listExports = [];
679
+ const collect = (items, direction, groupTitle, catalogTitle) => {
680
+ for (const item of this.sortItemsForDisplay(items, direction)) {
674
681
  if (item.type === CatalogItemType.Group) {
675
682
  const group = item;
676
- group.items?.forEach((item) => {
677
- const layer = item;
678
- catalogListExports.push(this.formatLayer(layer, rank, group.title, catalog.title));
679
- rank++;
680
- });
683
+ collect(group.items ?? [], group.sortDirection, group.title, catalogTitle);
681
684
  }
682
685
  else {
683
- const layer = item;
684
- catalogListExports.push(this.formatLayer(layer, rank, '', catalog.title));
685
- rank++;
686
+ listExports.push(this.formatLayer(item, rank++, groupTitle, catalogTitle));
686
687
  }
687
- return catalogListExports;
688
- }, []);
689
- finalListExportOutputs.push(...catalogListExports);
690
- });
691
- return finalListExportOutputs;
688
+ }
689
+ };
690
+ catalogsWithItems.forEach(({ catalog, items }) => collect(items, catalog.sortDirection, '', catalog.title));
691
+ return listExports;
692
692
  }));
693
693
  }
694
694
  async getCatalogList() {
@@ -1826,8 +1826,8 @@ class WorkspaceState {
1826
1826
  this._store = new WorkspaceStore([]);
1827
1827
  this._store.stateView
1828
1828
  .firstBy$((record) => record.state.active === true)
1829
- .subscribe((record) => {
1830
- const workspace = record ? record.entity : undefined;
1829
+ .pipe(map((record) => (record ? record.entity : undefined)), distinctUntilChanged())
1830
+ .subscribe((workspace) => {
1831
1831
  this.workspace$.next(workspace);
1832
1832
  });
1833
1833
  this._store.stateView.all$().subscribe((workspaces) => {