Skip to content

Commit 2f17784

Browse files
Mattia VianelliAndrea Barbasso
authored andcommitted
Merged in task/dspace-cris-2025_02_x/DSC-2715 (pull request DSpace#4045)
Task/dspace cris 2025 02 x/DSC-2715 Approved-by: Andrea Barbasso
2 parents c420571 + 880f162 commit 2f17784

13 files changed

+124
-1
lines changed

src/app/submission/form/submission-form.component.html

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,16 @@
99
<div class="clearfix"></div>
1010
</div>
1111
}
12+
@if (shouldShowLegend) {
13+
<ds-submission-legend class="submission-form-header-legend">
14+
</ds-submission-legend>
15+
}
1216
<div class="submission-form-header-item mb-3 mb-sm-0 flex-sm-grow-1 flex-md-grow-0">
1317
@if (!isSectionHidden) {
1418
<ds-submission-form-collection
1519
[currentCollectionId]="collectionId"
1620
[currentDefinition]="definitionId"
17-
[entityType]="entityType"
21+
[entityType]="entityType"
1822
[submissionId]="submissionId"
1923
[collectionModifiable]="collectionModifiable"
2024
[isReadonly]="isSectionReadonly"

src/app/submission/form/submission-form.component.scss

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,10 @@
99
flex-grow: 1;
1010
}
1111

12+
.submission-form-header-legend {
13+
width: 100%;
14+
}
15+
1216
.submission-form-footer {
1317
border-radius: var(--bs-card-border-radius);
1418
bottom: 0;

src/app/submission/form/submission-form.component.spec.ts

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -286,6 +286,43 @@ describe('SubmissionFormComponent', () => {
286286
done();
287287
});
288288

289+
describe('submission legend', () => {
290+
beforeEach(() => {
291+
comp.collectionId = collectionId;
292+
comp.submissionId = submissionId;
293+
comp.submissionDefinition = submissionDefinition;
294+
comp.selfUrl = selfUrl;
295+
comp.sections = sectionsData;
296+
comp.item = new Item();
297+
comp.entityType = 'publication';
298+
submissionServiceStub.getSubmissionObject.and.returnValue(of(submissionState));
299+
submissionServiceStub.getSubmissionSections.and.returnValue(of(sectionsList));
300+
301+
comp.isLoading$ = of(false);
302+
303+
comp.uploadEnabled$ = of(false);
304+
});
305+
306+
it('should display submission legend when shouldShowLegend is true', () => {
307+
spyOnProperty(comp, 'shouldShowLegend', 'get').and.returnValue(true);
308+
309+
fixture.detectChanges();
310+
311+
const legendElement = fixture.debugElement.nativeElement.querySelector('ds-submission-legend');
312+
expect(legendElement).toBeTruthy();
313+
expect(legendElement.classList.contains('submission-form-header-legend')).toBe(true);
314+
});
315+
316+
it('should not display submission legend when shouldShowLegend is false', () => {
317+
spyOnProperty(comp, 'shouldShowLegend', 'get').and.returnValue(false);
318+
319+
fixture.detectChanges();
320+
321+
const legendElement = fixture.debugElement.nativeElement.querySelector('ds-submission-legend');
322+
expect(legendElement).toBeNull();
323+
});
324+
});
325+
289326
});
290327
});
291328

src/app/submission/form/submission-form.component.ts

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ import {
2222
switchMap,
2323
} from 'rxjs/operators';
2424

25+
import { environment } from '../../../environments/environment';
2526
import { AuthService } from '../../core/auth/auth.service';
2627
import { SubmissionDefinitionsModel } from '../../core/config/models/config-submission-definitions.model';
2728
import { Collection } from '../../core/shared/collection.model';
@@ -46,6 +47,7 @@ import { SectionDataObject } from '../sections/models/section-data.model';
4647
import { SectionsService } from '../sections/sections.service';
4748
import { SectionsType } from '../sections/sections-type';
4849
import { SubmissionService } from '../submission.service';
50+
import { SubmissionLegendComponent } from '../submission-legend/submission-legend.component';
4951
import { SubmissionVisibility } from '../utils/visibility.util';
5052
import {
5153
SubmissionSectionModel,
@@ -67,6 +69,7 @@ import { ThemedSubmissionUploadFilesComponent } from './submission-upload-files/
6769
CommonModule,
6870
SubmissionFormCollectionComponent,
6971
SubmissionFormSectionAddComponent,
72+
SubmissionLegendComponent,
7073
ThemedLoadingComponent,
7174
ThemedSubmissionFormFooterComponent,
7275
ThemedSubmissionSectionContainerComponent,
@@ -335,6 +338,16 @@ export class SubmissionFormComponent implements OnChanges, OnDestroy {
335338
});
336339
}
337340

341+
/**
342+
* Check if submission legend should be shown
343+
*/
344+
get shouldShowLegend(): boolean {
345+
return environment.submission.showLegend;
346+
}
347+
348+
/**
349+
* Check if submission form is loading
350+
*/
338351
protected getSectionsList(): Observable<any> {
339352
return this.submissionService.getSubmissionSections(this.submissionId).pipe(
340353
filter((sections: SectionDataObject[]) => isNotEmpty(sections)),
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
<p [innerHTML]="legendText | translate"></p>
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
:host {
2+
display: block;
3+
margin-bottom: 1rem;
4+
}
5+
6+
p {
7+
margin: 0;
8+
padding: 0.75rem 1rem;
9+
border: 1px solid #dee2e6;
10+
border-radius: 0.25rem;
11+
background-color: rgba(0, 0, 0, 0.03);
12+
font-size: 0.875rem;
13+
color: #343a40;
14+
}
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
import {
2+
ComponentFixture,
3+
TestBed,
4+
} from '@angular/core/testing';
5+
import { TranslateModule } from '@ngx-translate/core';
6+
7+
import { SubmissionLegendComponent } from './submission-legend.component';
8+
9+
describe('SubmissionLegendComponent', () => {
10+
let component: SubmissionLegendComponent;
11+
let fixture: ComponentFixture<SubmissionLegendComponent>;
12+
13+
beforeEach(async () => {
14+
await TestBed.configureTestingModule({
15+
imports: [ SubmissionLegendComponent, TranslateModule.forRoot() ],
16+
})
17+
.compileComponents();
18+
19+
fixture = TestBed.createComponent(SubmissionLegendComponent);
20+
component = fixture.componentInstance;
21+
fixture.detectChanges();
22+
});
23+
24+
it('should create', () => {
25+
expect(component).toBeTruthy();
26+
});
27+
});
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
import { Component } from '@angular/core';
2+
import { TranslateModule } from '@ngx-translate/core';
3+
4+
@Component({
5+
selector: 'ds-submission-legend',
6+
templateUrl: './submission-legend.component.html',
7+
styleUrls: ['./submission-legend.component.scss'],
8+
imports: [
9+
TranslateModule,
10+
],
11+
})
12+
export class SubmissionLegendComponent {
13+
legendText = 'submission.sections.general.legend';
14+
}

src/assets/i18n/en.json5

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7372,6 +7372,8 @@
73727372

73737373
"submission.sections.general.sections_not_valid": "There are incomplete sections.",
73747374

7375+
"submission.sections.general.legend": "<h3><b>Mandatory Fields</b></h3><p>Fields marked with an asterisk (*) must be completed before the submission can be finalized.</p>",
7376+
73757377
"submission.sections.identifiers.info": "The following identifiers will be created for your item:",
73767378

73777379
"submission.sections.identifiers.no_handle": "No handles have been minted for this item.",

src/assets/i18n/it.json5

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11639,6 +11639,9 @@
1163911639
// "submission.sections.general.sections_not_valid": "There are incomplete sections.",
1164011640
"submission.sections.general.sections_not_valid": "Ci sono sezioni incomplete.",
1164111641

11642+
// "submission.sections.general.legend": "<h3><b>Mandatory Fields</b></h3><p>Fields marked with an asterisk (*) must be completed before the submission can be finalized.</p>",
11643+
"submission.sections.general.legend": "<h3><b>Campi Obbligatori</b></h3><p>I campi contrassegnati con un asterisco (*) devono essere compilati prima che la submission possa essere finalizzata.</p>",
11644+
1164211645
// "submission.sections.identifiers.info": "The following identifiers will be created for your item:",
1164311646
"submission.sections.identifiers.info": "Per questo item saranno generati i seguenti identificativi:",
1164411647

0 commit comments

Comments
 (0)