Skip to content

Commit b0ad553

Browse files
Mattia VianelliAndrea Barbasso
authored andcommitted
Merged in task/dspace-cris-2023_02_x/DSC-2715 (pull request DSpace#4043)
Task/dspace cris 2023 02 x/DSC-2715 Approved-by: Andrea Barbasso
2 parents ce57adc + ee2aee5 commit b0ad553

13 files changed

+115
-2
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
@@ -1,5 +1,6 @@
11
import { ChangeDetectorRef, Component, NO_ERRORS_SCHEMA, SimpleChange } from '@angular/core';
22
import { ComponentFixture, inject, TestBed, waitForAsync } from '@angular/core/testing';
3+
import { By } from '@angular/platform-browser';
34

45
import { of as observableOf } from 'rxjs';
56
import { cold, getTestScheduler } from 'jasmine-marbles';
@@ -259,6 +260,44 @@ describe('SubmissionFormComponent Component', () => {
259260
done();
260261
});
261262

263+
describe('submission legend', () => {
264+
beforeEach(() => {
265+
comp.collectionId = collectionId;
266+
comp.submissionId = submissionId;
267+
comp.submissionDefinition = submissionDefinition;
268+
comp.selfUrl = selfUrl;
269+
comp.sections = sectionsData;
270+
comp.item = new Item();
271+
comp.entityType = 'publication';
272+
submissionServiceStub.getSubmissionObject.and.returnValue(observableOf(submissionState));
273+
submissionServiceStub.getSubmissionSections.and.returnValue(observableOf(sectionsList));
274+
275+
spyOn(comp, 'isLoading').and.returnValue(observableOf(false));
276+
277+
comp.uploadEnabled$ = observableOf(false);
278+
});
279+
280+
it('should display submission legend when shouldShowLegend is true', () => {
281+
spyOnProperty(comp, 'shouldShowLegend', 'get').and.returnValue(true);
282+
283+
fixture.detectChanges();
284+
285+
const legendElement = fixture.debugElement.query(By.css('ds-submission-legend'));
286+
expect(legendElement).toBeTruthy();
287+
expect(legendElement.nativeElement.classList.contains('submission-form-header-legend')).toBe(true);
288+
});
289+
290+
it('should not display submission legend when shouldShowLegend is false', () => {
291+
spyOnProperty(comp, 'shouldShowLegend', 'get').and.returnValue(false);
292+
293+
fixture.detectChanges();
294+
295+
const legendElement = fixture.debugElement.query(By.css('ds-submission-legend'));
296+
expect(legendElement).toBeNull();
297+
});
298+
299+
});
300+
262301
});
263302
});
264303

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

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ import { SubmissionVisibility } from '../utils/visibility.util';
2727
import { MetadataSecurityConfiguration } from '../../core/submission/models/metadata-security-configuration';
2828
import { getFirstCompletedRemoteData } from '../../core/shared/operators';
2929
import { MetadataSecurityConfigurationService } from '../../core/submission/metadatasecurityconfig-data.service';
30+
import { environment } from '../../../environments/environment';
3031

3132
/**
3233
* This component represents the submission form.
@@ -301,6 +302,13 @@ export class SubmissionFormComponent implements OnChanges, OnDestroy {
301302
return this.loading;
302303
}
303304

305+
/**
306+
* Check if submission legend should be shown
307+
*/
308+
get shouldShowLegend(): boolean {
309+
return environment.submission.showLegend;
310+
}
311+
304312
/**
305313
* Check if submission form is loading
306314
*/
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 { ComponentFixture, TestBed } from '@angular/core/testing';
2+
import { TranslateModule } from '@ngx-translate/core';
3+
4+
import { SubmissionLegendComponent } from './submission-legend.component';
5+
6+
describe('SubmissionLegendComponent', () => {
7+
let component: SubmissionLegendComponent;
8+
let fixture: ComponentFixture<SubmissionLegendComponent>;
9+
10+
beforeEach(async () => {
11+
await TestBed.configureTestingModule({
12+
imports: [
13+
TranslateModule.forRoot()
14+
],
15+
declarations: [ SubmissionLegendComponent ]
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: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
import { Component } from '@angular/core';
2+
3+
@Component({
4+
selector: 'ds-submission-legend',
5+
templateUrl: './submission-legend.component.html',
6+
styleUrls: ['./submission-legend.component.scss']
7+
})
8+
export class SubmissionLegendComponent {
9+
legendText = 'submission.sections.general.legend';
10+
}

src/app/submission/submission.module.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,7 @@ import { SectionFormOperationsService } from './sections/form/section-form-opera
7373
import { SubmissionSectionIdentifiersComponent } from './sections/identifiers/section-identifiers.component';
7474
import { SubmissionSectionCorrectionComponent } from './sections/correction/section-correction.component';
7575
import { MyDspaceSearchModule } from '../my-dspace-page/my-dspace-search.module';
76+
import {SubmissionLegendComponent} from './submission-legend/submission-legend.component';
7677

7778
const ENTRY_COMPONENTS = [
7879
// put only entry components that use custom decorator
@@ -115,7 +116,8 @@ const DECLARATIONS = [
115116
PublicationInformationComponent,
116117
MetadataInformationComponent,
117118
ThemedSubmissionSectionUploadFileComponent,
118-
DuplicateMatchComponent
119+
DuplicateMatchComponent,
120+
SubmissionLegendComponent
119121
];
120122

121123
@NgModule({

src/assets/i18n/en.json5

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

65006500
"submission.sections.general.sections_not_valid": "There are incomplete sections.",
65016501

6502+
"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>",
6503+
65026504
"submission.sections.identifiers.info": "The following identifiers will be created for your item:",
65036505

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

0 commit comments

Comments
 (0)