diff --git a/ui/ui-frontend/projects/collect/src/app/collect/archive-search-collect/archive-search-collect.component.html b/ui/ui-frontend/projects/collect/src/app/collect/archive-search-collect/archive-search-collect.component.html index 2c90b21a307..2bffd0ce458 100644 --- a/ui/ui-frontend/projects/collect/src/app/collect/archive-search-collect/archive-search-collect.component.html +++ b/ui/ui-frontend/projects/collect/src/app/collect/archive-search-collect/archive-search-collect.component.html @@ -4,6 +4,7 @@ [transactionId]="transaction?.id" (showArchiveUnitDetails)="showPreviewArchiveUnit($event)" [searchHasMatches]="searchHasResults" + [hasDynamicAttachment]="hasDynamicAttachment" [searchRequestTotalResults]="totalResults" > diff --git a/ui/ui-frontend/projects/collect/src/app/collect/archive-search-collect/archive-search-collect.component.ts b/ui/ui-frontend/projects/collect/src/app/collect/archive-search-collect/archive-search-collect.component.ts index 796b67dae38..9f8b7e36402 100644 --- a/ui/ui-frontend/projects/collect/src/app/collect/archive-search-collect/archive-search-collect.component.ts +++ b/ui/ui-frontend/projects/collect/src/app/collect/archive-search-collect/archive-search-collect.component.ts @@ -143,6 +143,7 @@ export class ArchiveSearchCollectComponent extends SidenavPage implements O direction = Direction.ASCENDANT; DEFAULT_RESULT_THRESHOLD = 10000; searchHasResults = false; + hasDynamicAttachment = false; pageNumbers = 0; canLoadMore = false; @@ -305,6 +306,7 @@ export class ArchiveSearchCollectComponent extends SidenavPage implements O if (!!transaction) { this.isNotOpen$.next(transaction.status !== TransactionStatus.OPEN); this.isNotReady$.next(transaction.status !== TransactionStatus.READY); + this.existsArchiveUnitWithDynamicAttachment(); } else { this.isNotOpen$.next(true); this.isNotReady$.next(true); @@ -1078,4 +1080,50 @@ export class ArchiveSearchCollectComponent extends SidenavPage implements O // FIXME: for some reason, that trackBy - used to make Angular update the Unit in the list when it's modified in the sidenav - is not always working correctly: sometimes, the Unit is updated, sometimes not. It looks like it is updated for "simple" Units (with only Généralités) and not for "complex" ones. return unit['#id']; } + + existsArchiveUnitWithDynamicAttachment(): void { + const criteriaList = [ + { + criteria: 'ALL_ARCHIVE_UNIT_TYPES', + values: [ + { + value: 'ARCHIVE_UNIT_WITH_OBJECTS', + id: 'ARCHIVE_UNIT_WITH_OBJECTS', + }, + { + value: 'ARCHIVE_UNIT_WITHOUT_OBJECTS', + id: 'ARCHIVE_UNIT_WITHOUT_OBJECTS', + }, + ], + operator: 'EQ', + category: 'FIELDS', + dataType: 'STRING', + }, + { + criteria: 'TITLE_OR_DESCRIPTION', + values: [ + { + value: 'DYNAMIC_ATTACHEMENT', + id: 'DYNAMIC_ATTACHEMENT', + }, + ], + operator: 'EQ', + category: 'FIELDS', + dataType: 'STRING', + }, + ]; + const searchCriteria = { + criteriaList: criteriaList, + pageNumber: 0, + size: 1, + sortingCriteria: { criteria: this.orderBy, sorting: this.direction }, + trackTotalHits: false, + computeFacets: false, + }; + this.archiveUnitCollectService + .searchArchiveUnitsByCriteria(searchCriteria, this.transaction?.id || null) + .subscribe((response: PagedResult) => { + this.hasDynamicAttachment = response.results != null && !isEmpty(response.results); + }); + } } diff --git a/ui/ui-frontend/projects/collect/src/app/collect/archive-search-collect/archive-search-criteria/components/filing-holding-scheme/filing-holding-scheme.component.ts b/ui/ui-frontend/projects/collect/src/app/collect/archive-search-collect/archive-search-criteria/components/filing-holding-scheme/filing-holding-scheme.component.ts index 16aee30d6b6..b957e770801 100644 --- a/ui/ui-frontend/projects/collect/src/app/collect/archive-search-collect/archive-search-criteria/components/filing-holding-scheme/filing-holding-scheme.component.ts +++ b/ui/ui-frontend/projects/collect/src/app/collect/archive-search-collect/archive-search-criteria/components/filing-holding-scheme/filing-holding-scheme.component.ts @@ -56,6 +56,7 @@ import { ArchiveSharedDataService } from '../../services/archive-shared-data.ser export class FilingHoldingSchemeComponent implements OnInit, OnDestroy { @Input() transactionId: string; @Input() searchHasMatches = false; + @Input() hasDynamicAttachment = false; @Input() searchRequestTotalResults: number; @Output() showArchiveUnitDetails = new EventEmitter(); @@ -128,7 +129,7 @@ export class FilingHoldingSchemeComponent implements OnInit, OnDestroy { } // Re-init attachment units to render children by criteria this.nestedDataSourceLeaves.data = [...this.attachmentNodes]; - if (this.searchRequestTotalResults > 0 && isEmpty(this.attachmentNodes)) { + if (this.searchRequestTotalResults > 0 && (isEmpty(this.attachmentNodes) || this.hasDynamicAttachment)) { FilingHoldingSchemeHandler.addOrphansNodeFromTree( this.nestedDataSourceLeaves.data, this.translateService.instant('ARCHIVE_SEARCH.FILING_SCHEMA.ORPHANS_NODE'),