Skip to content

Commit

Permalink
Merge pull request #2458 from ProgrammeVitam/cp_8.0_13492
Browse files Browse the repository at this point in the history
CP V8.0 - Bug #13492 [Collection] - The folder without attachment is missing in the case of an attachment project by key-value.
  • Loading branch information
Salimdev authored Feb 17, 2025
2 parents acb4d47 + 5427297 commit 030ac01
Show file tree
Hide file tree
Showing 3 changed files with 51 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
[transactionId]="transaction?.id"
(showArchiveUnitDetails)="showPreviewArchiveUnit($event)"
[searchHasMatches]="searchHasResults"
[hasDynamicAttachment]="hasDynamicAttachment"
[searchRequestTotalResults]="totalResults"
>
</app-filing-holding-scheme>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,7 @@ export class ArchiveSearchCollectComponent extends SidenavPage<any> implements O
direction = Direction.ASCENDANT;
DEFAULT_RESULT_THRESHOLD = 10000;
searchHasResults = false;
hasDynamicAttachment = false;
pageNumbers = 0;
canLoadMore = false;

Expand Down Expand Up @@ -305,6 +306,7 @@ export class ArchiveSearchCollectComponent extends SidenavPage<any> 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);
Expand Down Expand Up @@ -1078,4 +1080,50 @@ export class ArchiveSearchCollectComponent extends SidenavPage<any> 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);
});
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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<Unit>();
Expand Down Expand Up @@ -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'),
Expand Down

0 comments on commit 030ac01

Please sign in to comment.