Skip to content

Commit 3eba347

Browse files
author
Hassane Diaby
committed
Story #15575 : Collect - Errors displaying improvement
1 parent c8585c7 commit 3eba347

28 files changed

+483
-40
lines changed

ui/ui-frontend/projects/collect/src/app/collect/archive-search-collect/archive-preview/archive-preview.component.html

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
[extended]="isPanelextended"
33
[title]="archiveUnit | unitI18n: 'Title' | truncate: 29"
44
[icon]="getArchiveUnitIcon(archiveUnit)"
5+
[badge]="addStatusBadgeforArchiveUnitWithErrors()"
56
[hasToolTipOnTitle]="true"
67
[toolTipTitleText]="archiveUnit | unitI18n: 'Title'"
78
[toolTipTitleDuration]="300"
@@ -31,6 +32,7 @@
3132
<app-archive-unit-information-tab
3233
[archiveUnit]="archiveUnit"
3334
(showNormalPanel)="showNormalPanel()"
35+
(openObjectsTab)="selectedTabChangeEvent($event)"
3436
></app-archive-unit-information-tab>
3537
</mat-tab>
3638

ui/ui-frontend/projects/collect/src/app/collect/archive-search-collect/archive-preview/archive-preview.component.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -151,4 +151,8 @@ export class ArchivePreviewComponent implements OnChanges, AfterViewInit {
151151
getArchiveUnitIcon(unit: Unit) {
152152
return unitToVitamuiIcon(unit);
153153
}
154+
155+
addStatusBadgeforArchiveUnitWithErrors() {
156+
return this.archiveUnit['#errors']?.length > 0 || this.archiveUnit['#ogInfo']?.['#errors']?.length > 0 ? 'red' : '';
157+
}
154158
}

ui/ui-frontend/projects/collect/src/app/collect/archive-search-collect/archive-preview/archive-unit-information-tab/archive-unit-information-tab.component.html

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,8 +52,20 @@
5252
/>
5353
</div>
5454

55-
@if (hasErrorMessages) {
56-
<vitamui-common-data [label]="'COLLECT.ARCHIVE_UNIT_PREVIEW.FIELDS.ENCOUNTERED_ERRORS' | translate" [value]="errorMessages" />
55+
@if (hasErrorsOnGOTorOT) {
56+
<vitamui-information-bloc
57+
[messageKey]="'COLLECT.ARCHIVE_UNIT_PREVIEW.FIELDS.SOME_OBJECTS_CONTAINS_ERRORS'"
58+
[withObjectsTabLink]="true"
59+
[decoration]="'bordered'"
60+
(openObjectsTab)="goToObjectsTab()"
61+
></vitamui-information-bloc>
62+
}
63+
64+
@if (hasErrorsOnArchiveUnit) {
65+
<div class="text normal bold danger">{{ 'COLLECT.ARCHIVE_UNIT_PREVIEW.FIELDS.ENCOUNTERED_ERRORS' | translate | uppercase }}</div>
66+
@for (error of errorsOnArchiveUnit; track $index) {
67+
<vitamui-information-detail [error]="error" [hideEvDetData]="true"></vitamui-information-detail>
68+
}
5769
}
5870
</div>
5971

ui/ui-frontend/projects/collect/src/app/collect/archive-search-collect/archive-preview/archive-unit-information-tab/archive-unit-information-tab.component.ts

Lines changed: 25 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,6 @@
3535
* knowledge of the CeCILL-C license and that you accept its terms.
3636
*/
3737
import { Component, EventEmitter, Input, OnChanges, Output, SimpleChanges } from '@angular/core';
38-
import { TranslateService } from '@ngx-translate/core';
3938
import { Observable } from 'rxjs';
4039
import { TenantSelectionService, Unit } from 'vitamui-library';
4140
import { ArchiveCollectService } from '../../archive-collect.service';
@@ -47,9 +46,11 @@ import { ArchiveCollectService } from '../../archive-collect.service';
4746
standalone: false,
4847
})
4948
export class ArchiveUnitInformationTabComponent implements OnChanges {
50-
@Input() archiveUnit: Unit;
49+
OBJECTS_TAB_INDEX = 3;
5150

51+
@Input() archiveUnit: Unit;
5252
@Output() showNormalPanel = new EventEmitter<any>();
53+
@Output() openObjectsTab = new EventEmitter<any>();
5354

5455
uaPath$: Observable<{ fullPath: string; resumePath: string }>;
5556
fullPath = false;
@@ -58,7 +59,6 @@ export class ArchiveUnitInformationTabComponent implements OnChanges {
5859
constructor(
5960
private archiveService: ArchiveCollectService,
6061
private tenantSelectionService: TenantSelectionService,
61-
private translateService: TranslateService,
6262
) {}
6363

6464
ngOnChanges(changes: SimpleChanges): void {
@@ -83,20 +83,28 @@ export class ArchiveUnitInformationTabComponent implements OnChanges {
8383
return this.archiveUnit['#errors']?.length > 0 || this.archiveUnit['#ogInfo']?.['#errors']?.length > 0;
8484
}
8585

86-
get errorMessages(): string[] | undefined {
87-
if (!this.hasErrorMessages) return;
88-
const unitValidationErrors = this.archiveUnit['#errors']?.map((error) => error.outMessg) ?? [];
89-
const nbObjectGroupValidationErrors = this.archiveUnit['#ogInfo']?.['#errors']?.length ?? 0;
90-
91-
const result = [...unitValidationErrors];
92-
if (nbObjectGroupValidationErrors > 0) {
93-
result.push(
94-
this.translateService.instant('COLLECT.ARCHIVE_UNIT_PREVIEW.FIELDS.OBJECT_GROUP_VALIDATION_ERRORS', {
95-
nbErrors: nbObjectGroupValidationErrors,
96-
}),
97-
);
98-
}
99-
return result;
86+
get errorsOnArchiveUnit() {
87+
return this.archiveUnit['#errors'];
88+
}
89+
90+
get errorOnTechnicalObjectsGroup() {
91+
return this.archiveUnit['#ogInfo']?.['#errors'].filter((error) => error.obId === null);
92+
}
93+
94+
get errorOnObjectsGroup() {
95+
return this.archiveUnit['#ogInfo']?.['#errors'].filter((error) => error.obId !== null);
96+
}
97+
98+
get hasErrorsOnArchiveUnit() {
99+
return this.errorsOnArchiveUnit?.length > 0;
100+
}
101+
102+
get hasErrorsOnGOTorOT() {
103+
return this.errorOnTechnicalObjectsGroup?.length > 0 || this.errorOnObjectsGroup?.length > 0;
104+
}
105+
106+
goToObjectsTab() {
107+
this.openObjectsTab.emit({ index: this.OBJECTS_TAB_INDEX, tab: null });
100108
}
101109

102110
private checkDownloadPermissions() {

ui/ui-frontend/projects/collect/src/app/collect/archive-search-collect/archive-preview/collect-object-group-details-tab/collect-object-group-details-tab.component.html

Lines changed: 20 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,13 @@
11
<div class="object-details-group IDS" *ngIf="unitObject">
2+
@if (hasErrorOnObjectsGroup) {
3+
<div class="mb-3">
4+
<vitamui-information-bloc
5+
[messageKey]="'COLLECT.ARCHIVE_UNIT_PREVIEW.FIELDS.SOME_OBJECTS_CONTAINS_ERRORS'"
6+
[decoration]="'bordered'"
7+
></vitamui-information-bloc>
8+
</div>
9+
}
10+
211
<div class="row">
312
<div class="col title">
413
{{ 'COLLECT.ARCHIVE_UNIT_PREVIEW.FIELDS.TECHNICAL_OBJECT_GROUP' | translate }}
@@ -27,17 +36,15 @@
2736
</div>
2837
</div>
2938

30-
@if (errorMessagesGot && errorMessagesGot['null']) {
31-
<div class="row-separator"></div>
32-
<div class="row">
33-
<div class="col title">
39+
@if (hasErrorOnTechnicalObjectsGroup) {
40+
<div class="d-flex flex-column gap-2 align-items-stretch">
41+
<div class="text normal bold danger">
3442
{{ 'COLLECT.ARCHIVE_UNIT_PREVIEW.FIELDS.ENCOUNTERED_ERRORS' | translate | uppercase }}
3543
</div>
44+
@for (error of errorOnTechnicalObjectsGroup; track error) {
45+
<vitamui-information-detail [error]="error"></vitamui-information-detail>
46+
}
3647
</div>
37-
<vitamui-common-data
38-
[label]="'COLLECT.ARCHIVE_UNIT_PREVIEW.FIELDS.LABEL' | translate"
39-
[value]="errorMessagesGot['null']"
40-
></vitamui-common-data>
4148
}
4249
</div>
4350

@@ -290,14 +297,13 @@
290297
</div>
291298

292299
@if (errorMessagesGot && errorMessagesGot[versionWithQualifier['#id']]) {
293-
<div class="object-details-group">
294-
<div class="row title">
300+
<div class="d-flex flex-column gap-2 align-items-stretch">
301+
<div class="text normal bold danger">
295302
{{ 'COLLECT.ARCHIVE_UNIT_PREVIEW.FIELDS.ENCOUNTERED_ERRORS' | translate | uppercase }}
296303
</div>
297-
<vitamui-common-data
298-
[label]="'COLLECT.ARCHIVE_UNIT_PREVIEW.FIELDS.LABEL' | translate"
299-
[value]="errorMessagesGot[versionWithQualifier['#id']]"
300-
></vitamui-common-data>
304+
@for (error of errorMessagesGot[versionWithQualifier['#id']]; track $index) {
305+
<vitamui-information-detail [error]="error"></vitamui-information-detail>
306+
}
301307
</div>
302308
}
303309

ui/ui-frontend/projects/collect/src/app/collect/archive-search-collect/archive-preview/collect-object-group-details-tab/collect-object-group-details-tab.component.ts

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ import {
4646
TenantSelectionService,
4747
Unit,
4848
VersionWithQualifierDto,
49+
ValidationError,
4950
} from 'vitamui-library';
5051
import { ArchiveCollectService } from '../../archive-collect.service';
5152

@@ -69,7 +70,7 @@ export class CollectObjectGroupDetailsTabComponent implements OnChanges {
6970
versionsWithQualifiersOrdered: Array<VersionWithQualifierDto>;
7071
hasDownloadDocumentRole = false;
7172
private allowedDescriptionLevel = [DescriptionLevel.ITEM, DescriptionLevel.RECORD_GRP];
72-
errorMessagesGot: Record<string, string[]>;
73+
errorMessagesGot: Record<string, ValidationError[]>;
7374

7475
constructor(
7576
private archiveCollectService: ArchiveCollectService,
@@ -93,6 +94,18 @@ export class CollectObjectGroupDetailsTabComponent implements OnChanges {
9394
return this.allowedDescriptionLevel.includes(this.archiveUnit.DescriptionLevel) && !!this.archiveUnit['#object'];
9495
}
9596

97+
get hasErrorOnTechnicalObjectsGroup() {
98+
return this.archiveUnit['#ogInfo']?.['#errors'].filter((error) => error.obId === null)?.length > 0;
99+
}
100+
101+
get errorOnTechnicalObjectsGroup() {
102+
return this.archiveUnit['#ogInfo']?.['#errors'].filter((error) => error.obId === null);
103+
}
104+
105+
get hasErrorOnObjectsGroup() {
106+
return this.archiveUnit['#ogInfo']?.['#errors'].filter((error) => error.obId !== null)?.length > 0;
107+
}
108+
96109
onClickDownloadObject(event: Event, versionWithQualifier: VersionWithQualifierDto) {
97110
event.stopPropagation();
98111
return this.archiveCollectService.downloadObjectFromUnit(
@@ -114,10 +127,10 @@ export class CollectObjectGroupDetailsTabComponent implements OnChanges {
114127
this.errorMessagesGot = this.unitObject['#errors']?.reduce(
115128
(acc, err) => {
116129
const key = err.obId || 'null';
117-
acc[key] = [...(acc[key] || []), err.outMessg];
130+
acc[key] = [...(acc[key] || []), err];
118131
return acc;
119132
},
120-
{} as Record<string, string[]>,
133+
{} as Record<string, ValidationError[]>,
121134
);
122135
this.setFirstVersionWithQualifierOpen();
123136
});

ui/ui-frontend/projects/collect/src/app/collect/archive-search-collect/archive-search-collect.component.html

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -396,10 +396,18 @@ <h5>{{ 'APPLICATION.COLLECT_APP.NAME' | translate }} : {{ projectName }}</h5>
396396
<ng-container *ngSwitchCase="UnitType.INGEST">
397397
<span class="table-filter-icon">
398398
<ng-container *ngIf="!archiveUnit?.['#object']">
399-
<i class="vitamui-icon vitamui-icon-folder vitamui-row-icon status-badge"></i>
399+
<i
400+
class="vitamui-icon vitamui-icon-folder vitamui-row-icon status-badge {{
401+
addStatusBadgeforArchiveUnitWithErrors(archiveUnit)
402+
}}"
403+
></i>
400404
</ng-container>
401405
<ng-container *ngIf="!!archiveUnit?.['#object']">
402-
<i class="vitamui-icon vitamui-icon-file vitamui-row-icon status-badge"></i>
406+
<i
407+
class="vitamui-icon vitamui-icon-file vitamui-row-icon status-badge {{
408+
addStatusBadgeforArchiveUnitWithErrors(archiveUnit)
409+
}}"
410+
></i>
403411
</ng-container>
404412
</span>
405413
</ng-container>

ui/ui-frontend/projects/collect/src/app/collect/archive-search-collect/archive-search-collect.component.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1331,6 +1331,10 @@ export class ArchiveSearchCollectComponent extends SidenavPage<any> implements O
13311331
}
13321332
}
13331333

1334+
addStatusBadgeforArchiveUnitWithErrors(archiveUnit: Unit) {
1335+
return archiveUnit['#errors']?.length > 0 || archiveUnit['#ogInfo']?.['#errors']?.length > 0 ? 'status-badge-red' : '';
1336+
}
1337+
13341338
private addCriteria(
13351339
keyElt: string,
13361340
valueElt: CriteriaValue,

ui/ui-frontend/projects/design-system/src/app/app-routing.module.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,8 @@ import { TypographyComponent } from './components/tokens/typography/typography.c
5151
import { DesignSystemComponent } from './components/design-system/design-system.component';
5252
import { DesignSystemChipsComponent } from './components/atoms/chips/design-system-chips.component';
5353
import { DesignSystemBadgesComponent } from './components/atoms/badges/design-system-badges.component';
54+
import { DesignSystemInformationBlocComponent } from './components/atoms/design-system-information-bloc/design-system-information-bloc.component';
55+
import { DesignSystemInformationDetailComponent } from './components/atoms/design-system-information-detail/design-system-information-detail.component';
5456
import { SpacingComponent } from './components/tokens/spacing/spacing.component';
5557
import { DesignSystemCheckboxComponent } from './components/molecules/inputs/checkbox/design-system-checkbox.component';
5658
import { DesignSystemSelectComponent } from './components/molecules/inputs/select/design-system-select.component';
@@ -94,6 +96,8 @@ const routes: Routes = [
9496
{ path: 'buttons', component: ButtonsComponent },
9597
{ path: 'chips', component: DesignSystemChipsComponent },
9698
{ path: 'badges', component: DesignSystemBadgesComponent },
99+
{ path: 'information-bloc', component: DesignSystemInformationBlocComponent },
100+
{ path: 'information-detail', component: DesignSystemInformationDetailComponent },
97101
{ path: 'icons', component: IconsComponent },
98102
{ path: 'slide-toggle', component: SlideToggleComponent },
99103
{ path: 'tooltip', component: TooltipComponent },
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
@for (decoration of decorations; track decoration) {
2+
@for (color of colors; track color) {
3+
<div class="flex-row gap-5 mb-3">
4+
@for (icon of icons; track icon) {
5+
<vitamui-information-bloc [color]="color" [messageKey]="message" [icon]="icon" [decoration]="decoration"></vitamui-information-bloc>
6+
<vitamui-information-bloc
7+
[color]="color"
8+
[messageKey]="message"
9+
[icon]="icon"
10+
[withObjectsTabLink]="true"
11+
[decoration]="decoration"
12+
></vitamui-information-bloc>
13+
}
14+
</div>
15+
}
16+
}

0 commit comments

Comments
 (0)