Skip to content

Commit f997df5

Browse files
Mattia VianelliAndrea Barbasso
authored andcommitted
Merged in task/dspace-cris-2024_02_x/DSC-2715 (pull request DSpace#4044)
Task/dspace cris 2024 02 x/DSC-2715 Approved-by: Andrea Barbasso
2 parents 4b242e9 + 1940256 commit f997df5

12 files changed

+117
-1
lines changed

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,8 @@
66
[uploadFilesOptions]="uploadFilesOptions"></ds-submission-upload-files>
77
<div class="clearfix"></div>
88
</div>
9-
9+
<ds-submission-legend *ngIf="shouldShowLegend" class="submission-form-header-legend">
10+
</ds-submission-legend>
1011
<div class="submission-form-header-item mb-3 mb-sm-0 flex-sm-grow-1 flex-md-grow-0">
1112
<ng-container *ngIf="!isSectionHidden">
1213
<ds-submission-form-collection [currentCollectionId]="collectionId"

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: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -286,6 +286,45 @@ 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(observableOf(submissionState));
299+
submissionServiceStub.getSubmissionSections.and.returnValue(observableOf(sectionsList));
300+
301+
// Mock isLoading$ to return false so the template renders
302+
comp.isLoading$ = observableOf(false);
303+
304+
// Mock uploadEnabled$ to ensure template renders properly
305+
comp.uploadEnabled$ = observableOf(false);
306+
});
307+
308+
it('should display submission legend when shouldShowLegend is true', () => {
309+
spyOnProperty(comp, 'shouldShowLegend', 'get').and.returnValue(true);
310+
311+
fixture.detectChanges();
312+
313+
const legendElement = fixture.debugElement.nativeElement.querySelector('ds-submission-legend');
314+
expect(legendElement).toBeTruthy();
315+
expect(legendElement.classList.contains('submission-form-header-legend')).toBe(true);
316+
});
317+
318+
it('should not display submission legend when shouldShowLegend is false', () => {
319+
spyOnProperty(comp, 'shouldShowLegend', 'get').and.returnValue(false);
320+
321+
fixture.detectChanges();
322+
323+
const legendElement = fixture.debugElement.nativeElement.querySelector('ds-submission-legend');
324+
expect(legendElement).toBeNull();
325+
});
326+
});
327+
289328
});
290329
});
291330

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

Lines changed: 10 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,
@@ -71,6 +73,7 @@ import { ThemedSubmissionUploadFilesComponent } from './submission-upload-files/
7173
ThemedSubmissionUploadFilesComponent,
7274
SubmissionFormCollectionComponent,
7375
SubmissionFormSectionAddComponent,
76+
SubmissionLegendComponent,
7477
TranslateModule,
7578
],
7679
standalone: true,
@@ -334,6 +337,13 @@ export class SubmissionFormComponent implements OnChanges, OnDestroy {
334337
});
335338
}
336339

340+
/**
341+
* Check if submission legend should be shown
342+
*/
343+
get shouldShowLegend(): boolean {
344+
return environment.submission.showLegend;
345+
}
346+
337347
/**
338348
* Check if submission form is loading
339349
*/
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: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
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+
standalone: true,
9+
imports: [TranslateModule],
10+
})
11+
export class SubmissionLegendComponent {
12+
legendText = 'submission.sections.general.legend';
13+
}

src/assets/i18n/en.json5

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

71267126
"submission.sections.general.sections_not_valid": "There are incomplete sections.",
71277127

7128+
"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>",
7129+
71287130
"submission.sections.identifiers.info": "The following identifiers will be created for your item:",
71297131

71307132
"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
@@ -11633,6 +11633,9 @@
1163311633
// "submission.sections.general.sections_not_valid": "There are incomplete sections.",
1163411634
"submission.sections.general.sections_not_valid": "Ci sono sezioni incomplete.",
1163511635

11636+
// "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>",
11637+
"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>",
11638+
1163611639
// "submission.sections.identifiers.info": "The following identifiers will be created for your item:",
1163711640
"submission.sections.identifiers.info": "Per questo item saranno generati i seguenti identificativi:",
1163811641

0 commit comments

Comments
 (0)