From 5add939a1d5989f59f0eb35d96e83472f6e0c5f5 Mon Sep 17 00:00:00 2001 From: Rezart Vata Date: Thu, 21 Apr 2022 12:33:38 +0200 Subject: [PATCH 01/28] [CST-5270] Insertion of submission section with mock & section layout --- .../models/sherpa-policies-details.model.ts | 60 ++++++ ...spaceitem-section-sherpa-policies.model.ts | 22 ++ .../models/workspaceitem-sections.model.ts | 2 + .../objects/submission-objects.effects.ts | 111 ++++++++-- src/app/submission/sections/sections-type.ts | 1 + .../content-accordion.component.html | 30 +++ .../content-accordion.component.scss | 33 +++ .../content-accordion.component.spec.ts | 25 +++ .../content-accordion.component.ts | 15 ++ .../section-sherpa-policies.component.html | 45 ++++ .../section-sherpa-policies.component.scss | 31 +++ .../section-sherpa-policies.component.spec.ts | 204 ++++++++++++++++++ .../section-sherpa-policies.component.ts | 79 +++++++ .../section-sherpa-policies.service.ts | 42 ++++ src/app/submission/submission.module.ts | 10 +- 15 files changed, 694 insertions(+), 16 deletions(-) create mode 100644 src/app/core/submission/models/sherpa-policies-details.model.ts create mode 100644 src/app/core/submission/models/workspaceitem-section-sherpa-policies.model.ts create mode 100644 src/app/submission/sections/sherpa-policies/content-accordion/content-accordion.component.html create mode 100644 src/app/submission/sections/sherpa-policies/content-accordion/content-accordion.component.scss create mode 100644 src/app/submission/sections/sherpa-policies/content-accordion/content-accordion.component.spec.ts create mode 100644 src/app/submission/sections/sherpa-policies/content-accordion/content-accordion.component.ts create mode 100644 src/app/submission/sections/sherpa-policies/section-sherpa-policies.component.html create mode 100644 src/app/submission/sections/sherpa-policies/section-sherpa-policies.component.scss create mode 100644 src/app/submission/sections/sherpa-policies/section-sherpa-policies.component.spec.ts create mode 100644 src/app/submission/sections/sherpa-policies/section-sherpa-policies.component.ts create mode 100644 src/app/submission/sections/sherpa-policies/section-sherpa-policies.service.ts diff --git a/src/app/core/submission/models/sherpa-policies-details.model.ts b/src/app/core/submission/models/sherpa-policies-details.model.ts new file mode 100644 index 0000000000..84f3735403 --- /dev/null +++ b/src/app/core/submission/models/sherpa-policies-details.model.ts @@ -0,0 +1,60 @@ +/** + * An interface to represent an access condition. + */ +export class SherpaPoliciesDetailsObject { + + /** + * The sherpa policies uri + */ + uri: string; + + /** + * The sherpa policies details + */ + journals: Journals; +} + + +export interface Journals { + titles: string[]; + url: string; + issns: string[]; + romeoPub: string; + zetoPub: string; + inDOAJ: boolean; + publisher: Publisher; + policies: Policies; + urls: string[]; + openAccessProhibited: boolean; +} + +export interface Publisher { + name: string; + relationshipType: string; + country: string; + uri: string; + identifier: string; + paidAccessDescription: string; + paidAccessUrl: string; +} + +export interface Policies { + openAccessPermitted: boolean; + uri: string; + internalMoniker: string; + permittedVersions: PermittedVersions; +} + +export interface PermittedVersions { + articleVersion: string; + conditions: string[]; + prerequisites: string[]; + locations: string[]; + licenses: string[]; + embargo: Embargo; +} + +export interface Embargo { + units: any; + amount: any; +} diff --git a/src/app/core/submission/models/workspaceitem-section-sherpa-policies.model.ts b/src/app/core/submission/models/workspaceitem-section-sherpa-policies.model.ts new file mode 100644 index 0000000000..d7666befe7 --- /dev/null +++ b/src/app/core/submission/models/workspaceitem-section-sherpa-policies.model.ts @@ -0,0 +1,22 @@ +import { SherpaPoliciesDetailsObject } from './sherpa-policies-details.model'; + +/** + * An interface to represent the submission's item accesses condition. + */ +export interface WorkspaceitemSectionSherpaPoliciesObject { + + /** + * The access condition id + */ + id: string; + + /** + * The sherpa policies retrievalTime + */ + retrievalTime: string; + + /** + * The sherpa policies details + */ + details: SherpaPoliciesDetailsObject; +} diff --git a/src/app/core/submission/models/workspaceitem-sections.model.ts b/src/app/core/submission/models/workspaceitem-sections.model.ts index 084da3f088..1112d740ed 100644 --- a/src/app/core/submission/models/workspaceitem-sections.model.ts +++ b/src/app/core/submission/models/workspaceitem-sections.model.ts @@ -3,6 +3,7 @@ import { WorkspaceitemSectionFormObject } from './workspaceitem-section-form.mod import { WorkspaceitemSectionLicenseObject } from './workspaceitem-section-license.model'; import { WorkspaceitemSectionUploadObject } from './workspaceitem-section-upload.model'; import { WorkspaceitemSectionCcLicenseObject } from './workspaceitem-section-cc-license.model'; +import { WorkspaceitemSectionSherpaPoliciesObject } from './workspaceitem-section-sherpa-policies.model'; /** * An interface to represent submission's section object. @@ -21,4 +22,5 @@ export type WorkspaceitemSectionDataType | WorkspaceitemSectionLicenseObject | WorkspaceitemSectionCcLicenseObject | WorkspaceitemSectionAccessesObject + | WorkspaceitemSectionSherpaPoliciesObject | string; diff --git a/src/app/submission/objects/submission-objects.effects.ts b/src/app/submission/objects/submission-objects.effects.ts index e8de418436..f1750cb30f 100644 --- a/src/app/submission/objects/submission-objects.effects.ts +++ b/src/app/submission/objects/submission-objects.effects.ts @@ -1,3 +1,4 @@ +import { WorkspaceitemSectionSherpaPoliciesObject } from './../../core/submission/models/workspaceitem-section-sherpa-policies.model'; import { Injectable } from '@angular/core'; import { Actions, Effect, ofType } from '@ngrx/effects'; import { Store } from '@ngrx/store'; @@ -51,6 +52,7 @@ import { SubmissionObjectDataService } from '../../core/submission/submission-ob import { followLink } from '../../shared/utils/follow-link-config.model'; import parseSectionErrorPaths, { SectionErrorPath } from '../utils/parseSectionErrorPaths'; import { FormState } from '../../shared/form/form.reducer'; +import { SUBMISSION_SECTION_TYPE } from 'src/app/core/config/models/config-type'; @Injectable() export class SubmissionObjectEffects { @@ -63,7 +65,7 @@ export class SubmissionObjectEffects { map((action: InitSubmissionFormAction) => { const definition = action.payload.submissionDefinition; const mappedActions = []; - definition.sections.page.forEach((sectionDefinition: any) => { + definition.sections.page.forEach((sectionDefinition: any, index) => { const selfLink = sectionDefinition._links.self.href || sectionDefinition._links.self; const sectionId = selfLink.substr(selfLink.lastIndexOf('/') + 1); const config = sectionDefinition._links.config ? (sectionDefinition._links.config.href || sectionDefinition._links.config) : ''; @@ -75,6 +77,7 @@ export class SubmissionObjectEffects { sectionData = action.payload.item.metadata; } const sectionErrors = isNotEmpty(action.payload.errors) ? (action.payload.errors[sectionId] || null) : null; + mappedActions.push( new InitSectionAction( action.payload.submissionId, @@ -89,7 +92,87 @@ export class SubmissionObjectEffects { sectionErrors ) ); + + if (index === definition.sections.page.length - 1) { + mappedActions.push( + new InitSectionAction( + action.payload.submissionId, + 'sherpaPolicies', + 'submit.progressbar.sherpaPolicies', + 'submit.progressbar.sherpaPolicies', + true, + SectionsType.SherpaPolicies, + { main: null, other: 'READONLY' }, + true, + { + 'id': 'sherpaPolicies', + 'retrievalTime': '2022-01-11T09:43:53Z', + 'details': { + 'uri': 'https://www.nature.com/natsynth/', + 'journals': { + 'titles': [ + 'Nature Synthesis' + ], + 'url': 'http://europepmc.org/', + 'issns': [ + '2731-0582', + '2731-0583', + '2731-0584', + ], + 'romeoPub': 'Self archiving and license to publish', + 'zetoPub': 'Self archiving and license to publish', + 'inDOAJ': true, + 'publisher': { + 'name': 'Europe PMC', + 'relationshipType': 'Stest', + 'country': 'gb', + 'uri': 'https://v2.sherpa.ac.uk/id/publication/40863', + 'identifier': '123123123', + 'paidAccessDescription': 'test test sss', + 'paidAccessUrl': 'https://www.nature.com/nature-portfolio/editorial-policies/preprints-and-conference-proceedings' + }, + 'policies': { + 'openAccessPermitted': true, + 'uri': 'https://v2.sherpa.ac.uk/id/publisher_policy/3286', + 'internalMoniker': 'Default Policy', + 'permittedVersions': { + 'articleVersion': 'submitted', + 'conditions': [ + 'Must link to publisher version', + 'Published source must be acknowledged and DOI cited', + 'Post-prints are subject to Springer Nature re-use terms', + 'Non-commercial use only' + ], + 'prerequisites': [], + 'locations': [ + 'authors_homepage', + 'funder_designated_location', + 'institutional_repository', + 'preprint_repository' + ], + 'licenses': [], + 'embargo': { + 'units': 'months', + 'amount': 6 + } + } + }, + 'urls': [ + 'https://www.nature.com/neuro/editorial-policies/self-archiving-and-license-to-publish', + 'https://www.nature.com/nature-portfolio/editorial-policies/preprints-and-conference-proceedings', + 'https://www.springernature.com/gp/open-research/policies/accepted-manuscript-terms' + ], + 'openAccessProhibited': true + } + } + } as WorkspaceitemSectionSherpaPoliciesObject, + null + ) + ); + } + }); + console.log(mappedActions); return { action: action, definition: definition, mappedActions: mappedActions }; }), mergeMap((result) => { @@ -125,8 +208,8 @@ export class SubmissionObjectEffects { this.submissionService.getSubmissionObjectLinkName(), action.payload.submissionId, 'sections').pipe( - map((response: SubmissionObject[]) => new SaveSubmissionFormSuccessAction(action.payload.submissionId, response, action.payload.isManual)), - catchError(() => observableOf(new SaveSubmissionFormErrorAction(action.payload.submissionId)))); + map((response: SubmissionObject[]) => new SaveSubmissionFormSuccessAction(action.payload.submissionId, response, action.payload.isManual)), + catchError(() => observableOf(new SaveSubmissionFormErrorAction(action.payload.submissionId)))); })); /** @@ -139,8 +222,8 @@ export class SubmissionObjectEffects { this.submissionService.getSubmissionObjectLinkName(), action.payload.submissionId, 'sections').pipe( - map((response: SubmissionObject[]) => new SaveForLaterSubmissionFormSuccessAction(action.payload.submissionId, response)), - catchError(() => observableOf(new SaveSubmissionFormErrorAction(action.payload.submissionId)))); + map((response: SubmissionObject[]) => new SaveForLaterSubmissionFormSuccessAction(action.payload.submissionId, response)), + catchError(() => observableOf(new SaveSubmissionFormErrorAction(action.payload.submissionId)))); })); /** @@ -179,8 +262,8 @@ export class SubmissionObjectEffects { action.payload.submissionId, 'sections', action.payload.sectionId).pipe( - map((response: SubmissionObject[]) => new SaveSubmissionSectionFormSuccessAction(action.payload.submissionId, response)), - catchError(() => observableOf(new SaveSubmissionSectionFormErrorAction(action.payload.submissionId)))); + map((response: SubmissionObject[]) => new SaveSubmissionSectionFormSuccessAction(action.payload.submissionId, response)), + catchError(() => observableOf(new SaveSubmissionSectionFormErrorAction(action.payload.submissionId)))); })); /** @@ -317,13 +400,13 @@ export class SubmissionObjectEffects { tap(() => this.notificationsService.error(null, this.translate.get('submission.sections.general.discard_error_notice')))); constructor(private actions$: Actions, - private notificationsService: NotificationsService, - private operationsService: SubmissionJsonPatchOperationsService, - private sectionService: SectionsService, - private store$: Store, - private submissionService: SubmissionService, - private submissionObjectService: SubmissionObjectDataService, - private translate: TranslateService) { + private notificationsService: NotificationsService, + private operationsService: SubmissionJsonPatchOperationsService, + private sectionService: SectionsService, + private store$: Store, + private submissionService: SubmissionService, + private submissionObjectService: SubmissionObjectDataService, + private translate: TranslateService) { } /** diff --git a/src/app/submission/sections/sections-type.ts b/src/app/submission/sections/sections-type.ts index d13aef1da1..f998ef4554 100644 --- a/src/app/submission/sections/sections-type.ts +++ b/src/app/submission/sections/sections-type.ts @@ -6,4 +6,5 @@ export enum SectionsType { CcLicense = 'cclicense', collection = 'collection', AccessesCondition = 'accessCondition', + SherpaPolicies = 'sherpaPolicies', } diff --git a/src/app/submission/sections/sherpa-policies/content-accordion/content-accordion.component.html b/src/app/submission/sections/sherpa-policies/content-accordion/content-accordion.component.html new file mode 100644 index 0000000000..8aa4a7ef9f --- /dev/null +++ b/src/app/submission/sections/sherpa-policies/content-accordion/content-accordion.component.html @@ -0,0 +1,30 @@ + + + + Publication information +
+ + +
+
+ +
+
+
+

Title

+
+
+
+
+
+
+

ISSNs

+
+
+
+
+
+ +
+
+
\ No newline at end of file diff --git a/src/app/submission/sections/sherpa-policies/content-accordion/content-accordion.component.scss b/src/app/submission/sections/sherpa-policies/content-accordion/content-accordion.component.scss new file mode 100644 index 0000000000..73d0f259cc --- /dev/null +++ b/src/app/submission/sections/sherpa-policies/content-accordion/content-accordion.component.scss @@ -0,0 +1,33 @@ +:host ::ng-deep { + .card { + border: none; + margin-bottom: 20px; + border-bottom: 1px solid rgba(0, 0, 0, 0.125); + + .card-header { + border: none; + background-color: transparent; + border-top: 1px solid rgba(0, 0, 0, 0.125); + + button { + text-align: left; + padding: 0px; + width: 100%; + color: #000; + font-weight: normal; + + .fas { + background: #fff; + color: #000; + margin-right: 10px; + height: 1.25em; + display: flex; + align-items: center; + justify-content: center; + font-size: 12px; + } + } + } + } + +} \ No newline at end of file diff --git a/src/app/submission/sections/sherpa-policies/content-accordion/content-accordion.component.spec.ts b/src/app/submission/sections/sherpa-policies/content-accordion/content-accordion.component.spec.ts new file mode 100644 index 0000000000..3b4d18a633 --- /dev/null +++ b/src/app/submission/sections/sherpa-policies/content-accordion/content-accordion.component.spec.ts @@ -0,0 +1,25 @@ +import { ComponentFixture, TestBed } from '@angular/core/testing'; + +import { ContentAccordionComponent } from './content-accordion.component'; + +describe('ContentAccordionComponent', () => { + let component: ContentAccordionComponent; + let fixture: ComponentFixture; + + beforeEach(async () => { + await TestBed.configureTestingModule({ + declarations: [ ContentAccordionComponent ] + }) + .compileComponents(); + }); + + beforeEach(() => { + fixture = TestBed.createComponent(ContentAccordionComponent); + component = fixture.componentInstance; + fixture.detectChanges(); + }); + + it('should create', () => { + expect(component).toBeTruthy(); + }); +}); diff --git a/src/app/submission/sections/sherpa-policies/content-accordion/content-accordion.component.ts b/src/app/submission/sections/sherpa-policies/content-accordion/content-accordion.component.ts new file mode 100644 index 0000000000..09e1d174d1 --- /dev/null +++ b/src/app/submission/sections/sherpa-policies/content-accordion/content-accordion.component.ts @@ -0,0 +1,15 @@ +import { Component, OnInit } from '@angular/core'; + +@Component({ + selector: 'ds-content-accordion', + templateUrl: './content-accordion.component.html', + styleUrls: ['./content-accordion.component.scss'] +}) +export class ContentAccordionComponent implements OnInit { + + constructor() { } + + ngOnInit(): void { + } + +} diff --git a/src/app/submission/sections/sherpa-policies/section-sherpa-policies.component.html b/src/app/submission/sections/sherpa-policies/section-sherpa-policies.component.html new file mode 100644 index 0000000000..a8014f0d6e --- /dev/null +++ b/src/app/submission/sections/sherpa-policies/section-sherpa-policies.component.html @@ -0,0 +1,45 @@ + + + +
+ + +
+ Publication information +
+ +
+
+
+

Title

+
+
+

{{title}}

+
+
+
+
+

ISSNs

+
+
+

{{issn}}

+
+
+
+ +
+
+ + +
+ + +
+ Publisher Policy +
+ + + + +
+
\ No newline at end of file diff --git a/src/app/submission/sections/sherpa-policies/section-sherpa-policies.component.scss b/src/app/submission/sections/sherpa-policies/section-sherpa-policies.component.scss new file mode 100644 index 0000000000..8c1bfc2580 --- /dev/null +++ b/src/app/submission/sections/sherpa-policies/section-sherpa-policies.component.scss @@ -0,0 +1,31 @@ +:host ::ng-deep { + .card { + border: none; + margin-bottom: 20px; + border-bottom: 1px solid rgba(0, 0, 0, 0.125); + + .card-header { + border: none; + background-color: transparent; + border-top: 1px solid rgba(0, 0, 0, 0.125); + + button { + text-align: left; + padding: 0px; + width: auto; + font-weight: bold; + + .fas { + background: #207698; + color: #fff; + margin-right: 10px; + height: 1.25em; + display: flex; + align-items: center; + justify-content: center; + } + } + } + } + +} \ No newline at end of file diff --git a/src/app/submission/sections/sherpa-policies/section-sherpa-policies.component.spec.ts b/src/app/submission/sections/sherpa-policies/section-sherpa-policies.component.spec.ts new file mode 100644 index 0000000000..5509cab4bb --- /dev/null +++ b/src/app/submission/sections/sherpa-policies/section-sherpa-policies.component.spec.ts @@ -0,0 +1,204 @@ +import { FormService } from '../../../shared/form/form.service'; +import { ComponentFixture, inject, TestBed } from '@angular/core/testing'; + +import { SubmissionSectionAccessesComponent } from './section-accesses.component'; +import { SectionsService } from '../sections.service'; +import { SectionsServiceStub } from '../../../shared/testing/sections-service.stub'; + +import { FormBuilderService } from '../../../shared/form/builder/form-builder.service'; +import { getMockFormBuilderService } from '../../../shared/mocks/form-builder-service.mock'; +import { SubmissionAccessesConfigService } from '../../../core/config/submission-accesses-config.service'; +import { + getSubmissionAccessesConfigNotChangeDiscoverableService, + getSubmissionAccessesConfigService +} from '../../../shared/mocks/section-accesses-config.service.mock'; +import { SectionAccessesService } from './section-accesses.service'; +import { SectionFormOperationsService } from '../form/section-form-operations.service'; +import { JsonPatchOperationsBuilder } from '../../../core/json-patch/builder/json-patch-operations-builder'; +import { TranslateModule, TranslateService } from '@ngx-translate/core'; +import { SubmissionJsonPatchOperationsService } from '../../../core/submission/submission-json-patch-operations.service'; +import { getSectionAccessesService } from '../../../shared/mocks/section-accesses.service.mock'; +import { getMockFormOperationsService } from '../../../shared/mocks/form-operations-service.mock'; +import { getMockTranslateService } from '../../../shared/mocks/translate.service.mock'; +import { SubmissionJsonPatchOperationsServiceStub } from '../../../shared/testing/submission-json-patch-operations-service.stub'; +import { BrowserModule } from '@angular/platform-browser'; + +import { of as observableOf } from 'rxjs'; +import { Store } from '@ngrx/store'; +import { FormComponent } from '../../../shared/form/form.component'; +import { + DynamicCheckboxModel, + DynamicDatePickerModel, + DynamicFormArrayModel, + DynamicSelectModel +} from '@ng-dynamic-forms/core'; +import { AppState } from '../../../app.reducer'; +import { getMockFormService } from '../../../shared/mocks/form-service.mock'; +import { mockAccessesFormData } from '../../../shared/mocks/submission.mock'; +import { accessConditionChangeEvent, checkboxChangeEvent } from '../../../shared/testing/form-event.stub'; + +describe('SubmissionSectionAccessesComponent', () => { + let component: SubmissionSectionAccessesComponent; + let fixture: ComponentFixture; + + const sectionsServiceStub = new SectionsServiceStub(); + // const pathCombiner = new JsonPatchOperationPathCombiner('sections', sectionId, 'files', fileIndex); + + const builderService: FormBuilderService = getMockFormBuilderService(); + const submissionAccessesConfigService = getSubmissionAccessesConfigService(); + const sectionAccessesService = getSectionAccessesService(); + const sectionFormOperationsService = getMockFormOperationsService(); + const operationsBuilder = jasmine.createSpyObj('operationsBuilder', { + add: undefined, + remove: undefined, + replace: undefined, + }); + + let formService: any; + + const storeStub = jasmine.createSpyObj('store', ['dispatch']); + + const sectionData = { + header: 'submit.progressbar.accessCondition', + config: 'http://localhost:8080/server/api/config/submissionaccessoptions/AccessConditionDefaultConfiguration', + mandatory: true, + sectionType: 'accessCondition', + collapsed: false, + enabled: true, + data: { + discoverable: true, + accessConditions: [] + }, + errorsToShow: [], + serverValidationErrors: [], + isLoading: false, + isValid: true + }; + + describe('First with canChangeDiscoverable true', () => { + + beforeEach(async () => { + await TestBed.configureTestingModule({ + imports: [ + BrowserModule, + TranslateModule.forRoot() + ], + declarations: [SubmissionSectionAccessesComponent, FormComponent], + providers: [ + { provide: SectionsService, useValue: sectionsServiceStub }, + { provide: FormBuilderService, useValue: builderService }, + { provide: SubmissionAccessesConfigService, useValue: submissionAccessesConfigService }, + { provide: SectionAccessesService, useValue: sectionAccessesService }, + { provide: SectionFormOperationsService, useValue: sectionFormOperationsService }, + { provide: JsonPatchOperationsBuilder, useValue: operationsBuilder }, + { provide: TranslateService, useValue: getMockTranslateService() }, + { provide: FormService, useValue: getMockFormService() }, + { provide: Store, useValue: storeStub }, + { provide: SubmissionJsonPatchOperationsService, useValue: SubmissionJsonPatchOperationsServiceStub }, + { provide: 'sectionDataProvider', useValue: sectionData }, + { provide: 'submissionIdProvider', useValue: '1508' }, + ] + }) + .compileComponents(); + }); + + beforeEach(inject([Store], (store: Store) => { + fixture = TestBed.createComponent(SubmissionSectionAccessesComponent); + component = fixture.componentInstance; + formService = TestBed.inject(FormService); + formService.validateAllFormFields.and.callFake(() => null); + formService.isValid.and.returnValue(observableOf(true)); + formService.getFormData.and.returnValue(observableOf(mockAccessesFormData)); + fixture.detectChanges(); + })); + + + it('should create', () => { + expect(component).toBeTruthy(); + }); + + it('should have created formModel', () => { + expect(component.formModel).toBeTruthy(); + }); + + it('should have formModel length should be 2', () => { + expect(component.formModel.length).toEqual(2); + }); + + it('formModel should have 1 model type checkbox and 1 model type array', () => { + expect(component.formModel[0] instanceof DynamicCheckboxModel).toBeTrue(); + expect(component.formModel[1] instanceof DynamicFormArrayModel).toBeTrue(); + }); + + it('formModel type array should have formgroup with 1 input and 2 datepickers', () => { + const formModel: any = component.formModel[1]; + const formGroup = formModel.groupFactory()[0].group; + expect(formGroup[0] instanceof DynamicSelectModel).toBeTrue(); + expect(formGroup[1] instanceof DynamicDatePickerModel).toBeTrue(); + expect(formGroup[2] instanceof DynamicDatePickerModel).toBeTrue(); + }); + + it('when checkbox changed it should call operationsBuilder replace function', () => { + component.onChange(checkboxChangeEvent); + fixture.detectChanges(); + + expect(operationsBuilder.replace).toHaveBeenCalled(); + }); + + it('when dropdown select changed it should call operationsBuilder add function', () => { + component.onChange(accessConditionChangeEvent); + fixture.detectChanges(); + expect(operationsBuilder.add).toHaveBeenCalled(); + }); + }); + + describe('when canDescoverable is false', () => { + + + + beforeEach(async () => { + await TestBed.configureTestingModule({ + imports: [ + BrowserModule, + TranslateModule.forRoot() + ], + declarations: [SubmissionSectionAccessesComponent, FormComponent], + providers: [ + { provide: SectionsService, useValue: sectionsServiceStub }, + { provide: FormBuilderService, useValue: builderService }, + { provide: SubmissionAccessesConfigService, useValue: getSubmissionAccessesConfigNotChangeDiscoverableService() }, + { provide: SectionAccessesService, useValue: sectionAccessesService }, + { provide: SectionFormOperationsService, useValue: sectionFormOperationsService }, + { provide: JsonPatchOperationsBuilder, useValue: operationsBuilder }, + { provide: TranslateService, useValue: getMockTranslateService() }, + { provide: FormService, useValue: getMockFormService() }, + { provide: Store, useValue: storeStub }, + { provide: SubmissionJsonPatchOperationsService, useValue: SubmissionJsonPatchOperationsServiceStub }, + { provide: 'sectionDataProvider', useValue: sectionData }, + { provide: 'submissionIdProvider', useValue: '1508' }, + ] + }) + .compileComponents(); + }); + + beforeEach(inject([Store], (store: Store) => { + fixture = TestBed.createComponent(SubmissionSectionAccessesComponent); + component = fixture.componentInstance; + formService = TestBed.inject(FormService); + formService.validateAllFormFields.and.callFake(() => null); + formService.isValid.and.returnValue(observableOf(true)); + formService.getFormData.and.returnValue(observableOf(mockAccessesFormData)); + fixture.detectChanges(); + })); + + + it('should have formModel length should be 1', () => { + expect(component.formModel.length).toEqual(1); + }); + + it('formModel should have only 1 model type array', () => { + expect(component.formModel[0] instanceof DynamicFormArrayModel).toBeTrue(); + }); + + }); +}); diff --git a/src/app/submission/sections/sherpa-policies/section-sherpa-policies.component.ts b/src/app/submission/sections/sherpa-policies/section-sherpa-policies.component.ts new file mode 100644 index 0000000000..5704d1abbb --- /dev/null +++ b/src/app/submission/sections/sherpa-policies/section-sherpa-policies.component.ts @@ -0,0 +1,79 @@ +import { WorkspaceitemSectionSherpaPoliciesObject } from './../../../core/submission/models/workspaceitem-section-sherpa-policies.model'; +import { SectionSherpaPoliciesService } from './section-sherpa-policies.service'; +import { Component, Inject, ViewChild } from '@angular/core'; +import { FormControl } from '@angular/forms'; + +import { filter, map, mergeMap, take } from 'rxjs/operators'; +import { combineLatest, Observable, of, Subscription } from 'rxjs'; +import { TranslateService } from '@ngx-translate/core'; + +import { renderSectionFor } from '../sections-decorator'; +import { SectionsType } from '../sections-type'; +import { SectionDataObject } from '../models/section-data.model'; +import { SectionsService } from '../sections.service'; +import { SectionModelComponent } from '../models/section.model'; +import { NgbAccordionConfig } from '@ng-bootstrap/ng-bootstrap'; + +/** + * This component represents a section for managing item's access conditions. + */ +@Component({ + selector: 'ds-section-sherpa-policies', + templateUrl: './section-sherpa-policies.component.html', + styleUrls: ['./section-sherpa-policies.component.scss'] +}) +@renderSectionFor(SectionsType.SherpaPolicies) +export class SubmissionSectionSherpaPoliciesComponent extends SectionModelComponent { + + /** + * The accesses section data + * @type {WorkspaceitemSectionAccessesObject} + */ + public sherpaPoliciesData: WorkspaceitemSectionSherpaPoliciesObject; + + + /** + * Initialize instance variables + * + * @param {SectionsService} sectionService + * @param {SectionDataObject} injectedSectionData + * @param {SectionSherpaPoliciesService} sectionSherpaPoliciesService + * @param {string} injectedSubmissionId + */ + constructor( + protected sectionService: SectionsService, + private sectionSherpaPoliciesService: SectionSherpaPoliciesService, + @Inject('sectionDataProvider') public injectedSectionData: SectionDataObject, + @Inject('submissionIdProvider') public injectedSubmissionId: string) { + super(undefined, injectedSectionData, injectedSubmissionId); + } + + /** + * Unsubscribe from all subscriptions + */ + // tslint:disable-next-line:no-empty + onSectionDestroy() { + + } + + /** + * Initialize all instance variables and retrieve collection default access conditions + */ + protected onSectionInit(): void { + this.sectionSherpaPoliciesService.getSherpaPoliciesData(this.submissionId, this.sectionData.id).subscribe((sherpaPolicies: WorkspaceitemSectionSherpaPoliciesObject) => { + console.log(sherpaPolicies); + this.sherpaPoliciesData = sherpaPolicies; + }); + } + + /** + * Get section status + * + * @return Observable + * the section status + */ + protected getSectionStatus(): Observable { + return of(true); + } + +} diff --git a/src/app/submission/sections/sherpa-policies/section-sherpa-policies.service.ts b/src/app/submission/sections/sherpa-policies/section-sherpa-policies.service.ts new file mode 100644 index 0000000000..c81caca41e --- /dev/null +++ b/src/app/submission/sections/sherpa-policies/section-sherpa-policies.service.ts @@ -0,0 +1,42 @@ +import { WorkspaceitemSectionSherpaPoliciesObject } from './../../../core/submission/models/workspaceitem-section-sherpa-policies.model'; +import { Injectable } from '@angular/core'; + +import { Observable } from 'rxjs'; +import { distinctUntilChanged, filter } from 'rxjs/operators'; +import { Store } from '@ngrx/store'; + +import { SubmissionState } from '../../submission.reducers'; +import { isNotUndefined } from '../../../shared/empty.util'; +import { submissionSectionDataFromIdSelector } from '../../selectors'; + +/** + * A service that provides methods to handle submission item's accesses condition state. + */ +@Injectable() +export class SectionSherpaPoliciesService { + + /** + * Initialize service variables + * + * @param {Store} store + */ + constructor(private store: Store) { } + + + /** + * Return item's accesses condition state. + * + * @param submissionId + * The submission id + * @param sectionId + * The section id + * @returns {Observable} + * Emits bitstream's metadata + */ + public getSherpaPoliciesData(submissionId: string, sectionId: string): Observable { + + return this.store.select(submissionSectionDataFromIdSelector(submissionId, sectionId)).pipe( + filter((state) => isNotUndefined(state)), + distinctUntilChanged()); + } +} diff --git a/src/app/submission/submission.module.ts b/src/app/submission/submission.module.ts index 939d1bff29..f1cedc8953 100644 --- a/src/app/submission/submission.module.ts +++ b/src/app/submission/submission.module.ts @@ -1,3 +1,4 @@ +import { SectionSherpaPoliciesService } from './sections/sherpa-policies/section-sherpa-policies.service'; import { NgModule } from '@angular/core'; import { CoreModule } from '../core/core.module'; import { SharedModule } from '../shared/shared.module'; @@ -42,6 +43,8 @@ import { NgbAccordionModule, NgbModalModule } from '@ng-bootstrap/ng-bootstrap'; import { SubmissionSectionAccessesComponent } from './sections/accesses/section-accesses.component'; import { SubmissionAccessesConfigService } from '../core/config/submission-accesses-config.service'; import { SectionAccessesService } from './sections/accesses/section-accesses.service'; +import { SubmissionSectionSherpaPoliciesComponent } from './sections/sherpa-policies/section-sherpa-policies.component'; +import { ContentAccordionComponent } from './sections/sherpa-policies/content-accordion/content-accordion.component'; const ENTRY_COMPONENTS = [ // put only entry components that use custom decorator @@ -50,7 +53,8 @@ const ENTRY_COMPONENTS = [ SubmissionSectionLicenseComponent, SubmissionSectionCcLicensesComponent, SubmissionSectionAccessesComponent, - SubmissionSectionUploadFileEditComponent + SubmissionSectionUploadFileEditComponent, + SubmissionSectionSherpaPoliciesComponent, ]; const DECLARATIONS = [ @@ -75,6 +79,7 @@ const DECLARATIONS = [ SubmissionImportExternalSearchbarComponent, SubmissionImportExternalPreviewComponent, SubmissionImportExternalCollectionComponent, + ContentAccordionComponent, ]; @NgModule({ @@ -97,7 +102,8 @@ const DECLARATIONS = [ SectionsService, SubmissionUploadsConfigService, SubmissionAccessesConfigService, - SectionAccessesService + SectionAccessesService, + SectionSherpaPoliciesService ] }) From da2cba5827d22be7bb8df4a53d14fd488bc0eb80 Mon Sep 17 00:00:00 2001 From: Rezart Vata Date: Thu, 21 Apr 2022 18:48:19 +0200 Subject: [PATCH 02/28] [CST-5270] Added some information from mock json to the layout --- .../content-accordion.component.html | 48 ++++++++++-- .../content-accordion.component.scss | 2 +- .../content-accordion.component.ts | 10 +-- .../section-sherpa-policies.component.html | 78 ++++++++++++++++++- 4 files changed, 122 insertions(+), 16 deletions(-) diff --git a/src/app/submission/sections/sherpa-policies/content-accordion/content-accordion.component.html b/src/app/submission/sections/sherpa-policies/content-accordion/content-accordion.component.html index 8aa4a7ef9f..2a453ec408 100644 --- a/src/app/submission/sections/sherpa-policies/content-accordion/content-accordion.component.html +++ b/src/app/submission/sections/sherpa-policies/content-accordion/content-accordion.component.html @@ -1,26 +1,60 @@ - - + + - Publication information + {{id.replace('-',' ') | titlecase}}
- - + +
-

Title

+

Article Version

+ {{data.articleVersion}}
-

ISSNs

+

Conditions

+

{{condition}}

+
+
+
+
+

Prerequisites

+
+
+

{{prerequisite}}

+
+
+
+
+

Location

+
+
+

{{location}}

+
+
+
+
+

License

+
+
+

{{license}}

+
+
+
+
+

Embargo

+
+
+

{{data.embargo.amount}} {{data.embargo.units}}

diff --git a/src/app/submission/sections/sherpa-policies/content-accordion/content-accordion.component.scss b/src/app/submission/sections/sherpa-policies/content-accordion/content-accordion.component.scss index 73d0f259cc..b18e7d3781 100644 --- a/src/app/submission/sections/sherpa-policies/content-accordion/content-accordion.component.scss +++ b/src/app/submission/sections/sherpa-policies/content-accordion/content-accordion.component.scss @@ -14,7 +14,7 @@ padding: 0px; width: 100%; color: #000; - font-weight: normal; + font-weight: 600; .fas { background: #fff; diff --git a/src/app/submission/sections/sherpa-policies/content-accordion/content-accordion.component.ts b/src/app/submission/sections/sherpa-policies/content-accordion/content-accordion.component.ts index 09e1d174d1..95f85e0732 100644 --- a/src/app/submission/sections/sherpa-policies/content-accordion/content-accordion.component.ts +++ b/src/app/submission/sections/sherpa-policies/content-accordion/content-accordion.component.ts @@ -1,15 +1,13 @@ -import { Component, OnInit } from '@angular/core'; +import { Component, Input } from '@angular/core'; @Component({ selector: 'ds-content-accordion', templateUrl: './content-accordion.component.html', styleUrls: ['./content-accordion.component.scss'] }) -export class ContentAccordionComponent implements OnInit { +export class ContentAccordionComponent { - constructor() { } - - ngOnInit(): void { - } + @Input() id: string; + @Input() data: any; } diff --git a/src/app/submission/sections/sherpa-policies/section-sherpa-policies.component.html b/src/app/submission/sections/sherpa-policies/section-sherpa-policies.component.html index a8014f0d6e..dbb33ee806 100644 --- a/src/app/submission/sections/sherpa-policies/section-sherpa-policies.component.html +++ b/src/app/submission/sections/sherpa-policies/section-sherpa-policies.component.html @@ -25,6 +25,50 @@

{{issn}}

+ + +
+
+

romeoPub

+
+
+

+ {{sherpaPoliciesData.details.journals.romeoPub}} +

+
+
+
+
+

zetoPub

+
+
+

+ {{sherpaPoliciesData.details.journals.zetoPub}} +

+
+
@@ -38,8 +82,38 @@ Publisher Policy - - +
+
+
+

+ Open Access pathways permitted by this journal's policy are listed below by article version. + Click on a pathway for a more detailed view +

+
+
+ + + +
+
+

+ For more information, please see the following links: +

+ +
+
+ + +
+ + + +
\ No newline at end of file From d390920ccafdb201a1daf2b0a8209be6f40a2fc6 Mon Sep 17 00:00:00 2001 From: Rezart Vata Date: Fri, 22 Apr 2022 19:09:40 +0200 Subject: [PATCH 03/28] [CST-5270] Code refactoring, made changes from the rest contract and implemented i18n --- .../models/sherpa-policies-details.model.ts | 49 ++++-- ...spaceitem-section-sherpa-policies.model.ts | 2 +- .../objects/submission-objects.effects.ts | 150 ++++++++++------- .../content-accordion.component.html | 57 ++++--- .../content-accordion.component.ts | 4 +- .../metadata-information.component.html | 39 +++++ .../metadata-information.component.scss | 0 .../metadata-information.component.spec.ts | 25 +++ .../metadata-information.component.ts | 13 ++ .../publication-information.component.html | 70 ++++++++ .../publication-information.component.scss | 0 .../publication-information.component.spec.ts | 25 +++ .../publication-information.component.ts | 13 ++ .../publisher-policy.component.html | 26 +++ .../publisher-policy.component.scss | 0 .../publisher-policy.component.spec.ts | 25 +++ .../publisher-policy.component.ts | 13 ++ .../section-sherpa-policies.component.html | 151 +++++------------- .../section-sherpa-policies.component.ts | 18 ++- src/app/submission/submission.module.ts | 6 + src/assets/i18n/en.json5 | 53 ++++++ 21 files changed, 522 insertions(+), 217 deletions(-) create mode 100644 src/app/submission/sections/sherpa-policies/metadata-information/metadata-information.component.html create mode 100644 src/app/submission/sections/sherpa-policies/metadata-information/metadata-information.component.scss create mode 100644 src/app/submission/sections/sherpa-policies/metadata-information/metadata-information.component.spec.ts create mode 100644 src/app/submission/sections/sherpa-policies/metadata-information/metadata-information.component.ts create mode 100644 src/app/submission/sections/sherpa-policies/publication-information/publication-information.component.html create mode 100644 src/app/submission/sections/sherpa-policies/publication-information/publication-information.component.scss create mode 100644 src/app/submission/sections/sherpa-policies/publication-information/publication-information.component.spec.ts create mode 100644 src/app/submission/sections/sherpa-policies/publication-information/publication-information.component.ts create mode 100644 src/app/submission/sections/sherpa-policies/publisher-policy/publisher-policy.component.html create mode 100644 src/app/submission/sections/sherpa-policies/publisher-policy/publisher-policy.component.scss create mode 100644 src/app/submission/sections/sherpa-policies/publisher-policy/publisher-policy.component.spec.ts create mode 100644 src/app/submission/sections/sherpa-policies/publisher-policy/publisher-policy.component.ts diff --git a/src/app/core/submission/models/sherpa-policies-details.model.ts b/src/app/core/submission/models/sherpa-policies-details.model.ts index 84f3735403..af4d4a5890 100644 --- a/src/app/core/submission/models/sherpa-policies-details.model.ts +++ b/src/app/core/submission/models/sherpa-policies-details.model.ts @@ -4,18 +4,39 @@ export class SherpaPoliciesDetailsObject { /** - * The sherpa policies uri + * The sherpa policies error */ - uri: string; + error: boolean; /** - * The sherpa policies details + * The sherpa policies journal details */ - journals: Journals; + journals: Journal[]; + + /** + * The sherpa policies message + */ + message: string; + + /** + * The sherpa policies metadata + */ + metadata: Metadata; + } -export interface Journals { +export interface Metadata { + id: number; + uri: string; + dateCreated: string; + dateModified: string; + inDOAJ: boolean; + publiclyVisible: boolean; +} + + +export interface Journal { titles: string[]; url: string; issns: string[]; @@ -23,9 +44,8 @@ export interface Journals { zetoPub: string; inDOAJ: boolean; publisher: Publisher; - policies: Policies; - urls: string[]; - openAccessProhibited: boolean; + publishers: Publisher[]; + policies: Policy[]; } export interface Publisher { @@ -36,17 +56,26 @@ export interface Publisher { identifier: string; paidAccessDescription: string; paidAccessUrl: string; + publicationCount: number; } -export interface Policies { +export interface Policy { + id: number; openAccessPermitted: boolean; uri: string; internalMoniker: string; - permittedVersions: PermittedVersions; + permittedVersions: PermittedVersions[]; + urls: any; + publicationCount: number; + preArchiving: string; + postArchiving: string; + pubArchiving: string; + openAccessProhibited: boolean; } export interface PermittedVersions { articleVersion: string; + option: number; conditions: string[]; prerequisites: string[]; locations: string[]; diff --git a/src/app/core/submission/models/workspaceitem-section-sherpa-policies.model.ts b/src/app/core/submission/models/workspaceitem-section-sherpa-policies.model.ts index d7666befe7..cbef185090 100644 --- a/src/app/core/submission/models/workspaceitem-section-sherpa-policies.model.ts +++ b/src/app/core/submission/models/workspaceitem-section-sherpa-policies.model.ts @@ -18,5 +18,5 @@ export interface WorkspaceitemSectionSherpaPoliciesObject { /** * The sherpa policies details */ - details: SherpaPoliciesDetailsObject; + sherpaResponse: SherpaPoliciesDetailsObject[]; } diff --git a/src/app/submission/objects/submission-objects.effects.ts b/src/app/submission/objects/submission-objects.effects.ts index f1750cb30f..e91c2caf14 100644 --- a/src/app/submission/objects/submission-objects.effects.ts +++ b/src/app/submission/objects/submission-objects.effects.ts @@ -106,65 +106,101 @@ export class SubmissionObjectEffects { true, { 'id': 'sherpaPolicies', - 'retrievalTime': '2022-01-11T09:43:53Z', - 'details': { - 'uri': 'https://www.nature.com/natsynth/', - 'journals': { - 'titles': [ - 'Nature Synthesis' - ], - 'url': 'http://europepmc.org/', - 'issns': [ - '2731-0582', - '2731-0583', - '2731-0584', - ], - 'romeoPub': 'Self archiving and license to publish', - 'zetoPub': 'Self archiving and license to publish', - 'inDOAJ': true, - 'publisher': { - 'name': 'Europe PMC', - 'relationshipType': 'Stest', - 'country': 'gb', - 'uri': 'https://v2.sherpa.ac.uk/id/publication/40863', - 'identifier': '123123123', - 'paidAccessDescription': 'test test sss', - 'paidAccessUrl': 'https://www.nature.com/nature-portfolio/editorial-policies/preprints-and-conference-proceedings' + 'retrievalTime': '2022-04-20T09:44:39.870+00:00', + 'sherpaResponse': [ + { + 'error': false, + 'message': null, + 'metadata': { + 'id': 23803, + 'uri': 'http://v2.sherpa.ac.uk/id/publication/23803', + 'dateCreated': '2012-11-20 14:51:52', + 'dateModified': '2020-03-06 11:25:54', + 'inDOAJ': false, + 'publiclyVisible': true }, - 'policies': { - 'openAccessPermitted': true, - 'uri': 'https://v2.sherpa.ac.uk/id/publisher_policy/3286', - 'internalMoniker': 'Default Policy', - 'permittedVersions': { - 'articleVersion': 'submitted', - 'conditions': [ - 'Must link to publisher version', - 'Published source must be acknowledged and DOI cited', - 'Post-prints are subject to Springer Nature re-use terms', - 'Non-commercial use only' - ], - 'prerequisites': [], - 'locations': [ - 'authors_homepage', - 'funder_designated_location', - 'institutional_repository', - 'preprint_repository' - ], - 'licenses': [], - 'embargo': { - 'units': 'months', - 'amount': 6 - } - } - }, - 'urls': [ - 'https://www.nature.com/neuro/editorial-policies/self-archiving-and-license-to-publish', - 'https://www.nature.com/nature-portfolio/editorial-policies/preprints-and-conference-proceedings', - 'https://www.springernature.com/gp/open-research/policies/accepted-manuscript-terms' - ], - 'openAccessProhibited': true + 'journals': [{ + 'titles': ['The Lancet', 'Lancet'], + 'url': 'http://www.thelancet.com/journals/lancet/issue/current', + 'issns': ['0140-6736', '1474-547X'], + 'romeoPub': 'Elsevier: The Lancet', + 'zetoPub': 'Elsevier: The Lancet', + 'publisher': { + 'name': 'Elsevier', + 'relationshipType': null, + 'country': null, + 'uri': 'http://www.elsevier.com/', + 'identifier': null, + 'publicationCount': 0, + 'paidAccessDescription': 'Open access', + 'paidAccessUrl': 'https://www.elsevier.com/about/open-science/open-access' + }, + 'publishers': [{ + 'name': 'Elsevier', + 'relationshipType': null, + 'country': null, + 'uri': 'http://www.elsevier.com/', + 'identifier': null, + 'publicationCount': 0, + 'paidAccessDescription': 'Open access', + 'paidAccessUrl': 'https://www.elsevier.com/about/open-science/open-access' + }], + 'policies': [{ + 'id': 0, + 'openAccessPermitted': false, + 'uri': null, + 'internalMoniker': 'Lancet', + 'permittedVersions': [{ + 'articleVersion': 'submitted', + 'option': 1, + 'conditions': ['Upon publication publisher copyright and source must be acknowledged', 'Upon publication must link to publisher version'], + 'prerequisites': [], + 'locations': ['Author\'s Homepage', 'Preprint Repository'], + 'licenses': [], + 'embargo': null + }, { + 'articleVersion': 'accepted', + 'option': 1, + 'conditions': ['Publisher copyright and source must be acknowledged', 'Must link to publisher version'], + 'prerequisites': [], + 'locations': ['Author\'s Homepage', 'Institutional Website'], + 'licenses': ['CC BY-NC-ND'], + 'embargo': null + }, { + 'articleVersion': 'accepted', + 'option': 2, + 'conditions': ['Publisher copyright and source must be acknowledged', 'Must link to publisher version'], + 'prerequisites': ['If Required by Funder'], + 'locations': ['Non-Commercial Repository'], + 'licenses': ['CC BY-NC-ND'], + 'embargo': null + }, { + 'articleVersion': 'accepted', + 'option': 3, + 'conditions': ['Publisher copyright and source must be acknowledged', 'Must link to publisher version'], + 'prerequisites': [], + 'locations': ['Non-Commercial Repository'], + 'licenses': [], + 'embargo': null + }], + 'urls': { + 'http://download.thelancet.com/flatcontentassets/authors/lancet-information-for-authors.pdf': 'Guidelines for Authors', + 'http://www.thelancet.com/journals/lancet/article/PIIS0140-6736%2813%2960720-5/fulltext': 'The Lancet journals welcome a new open access policy', + 'http://www.thelancet.com/lancet-information-for-authors/after-publication': 'What happens after publication?', + 'http://www.thelancet.com/lancet/information-for-authors/disclosure-of-results': 'Disclosure of results before publication', + 'https://www.elsevier.com/__data/assets/pdf_file/0005/78476/external-embargo-list.pdf': 'Journal Embargo Period List', + 'https://www.elsevier.com/__data/assets/pdf_file/0011/78473/UK-Embargo-Periods.pdf': 'Journal Embargo List for UK Authors' + }, + 'openAccessProhibited': false, + 'publicationCount': 0, + 'preArchiving': 'can', + 'postArchiving': 'can', + 'pubArchiving': 'cannot' + }], + 'inDOAJ': false + }] } - } + ] } as WorkspaceitemSectionSherpaPoliciesObject, null ) diff --git a/src/app/submission/sections/sherpa-policies/content-accordion/content-accordion.component.html b/src/app/submission/sections/sherpa-policies/content-accordion/content-accordion.component.html index 2a453ec408..bec999603d 100644 --- a/src/app/submission/sections/sherpa-policies/content-accordion/content-accordion.component.html +++ b/src/app/submission/sections/sherpa-policies/content-accordion/content-accordion.component.html @@ -1,64 +1,63 @@ - - + + - {{id.replace('-',' ') | titlecase}} + + {{version.articleVersion | titlecase}} {{ 'submission.sections.sherpa.publisher.policy.version' | + translate }} +
- - + +
-

Article Version

+

{{ 'submission.sections.sherpa.publisher.policy.embargo' | translate }}

-
- {{data.articleVersion}} +
+

{{version.embargo.amount}} + {{version.embargo.units}}

+ +

{{ 'submission.sections.sherpa.publisher.policy.noembargo' | translate }}

+
+
-

Conditions

+

{{ 'submission.sections.sherpa.publisher.policy.license' | translate }}

-
-

{{condition}}

+
+

{{license}}

-

Prerequisites

+

{{ 'submission.sections.sherpa.publisher.policy.prerequisites' | translate }}

-
-

{{prerequisite}}

+
+

{{prerequisite}}

-

Location

+

{{ 'submission.sections.sherpa.publisher.policy.location' | translate }}

-
-

{{location}}

+
+

{{location}}

-

License

+

{{ 'submission.sections.sherpa.publisher.policy.conditions' | translate }}

-
-

{{license}}

-
-
-
-
-

Embargo

-
-
-

{{data.embargo.amount}} {{data.embargo.units}}

+
+

{{condition}}

- \ No newline at end of file diff --git a/src/app/submission/sections/sherpa-policies/content-accordion/content-accordion.component.ts b/src/app/submission/sections/sherpa-policies/content-accordion/content-accordion.component.ts index 95f85e0732..12b48d10f4 100644 --- a/src/app/submission/sections/sherpa-policies/content-accordion/content-accordion.component.ts +++ b/src/app/submission/sections/sherpa-policies/content-accordion/content-accordion.component.ts @@ -1,3 +1,4 @@ +import { PermittedVersions } from './../../../../core/submission/models/sherpa-policies-details.model'; import { Component, Input } from '@angular/core'; @Component({ @@ -7,7 +8,6 @@ import { Component, Input } from '@angular/core'; }) export class ContentAccordionComponent { - @Input() id: string; - @Input() data: any; + @Input() version: PermittedVersions; } diff --git a/src/app/submission/sections/sherpa-policies/metadata-information/metadata-information.component.html b/src/app/submission/sections/sherpa-policies/metadata-information/metadata-information.component.html new file mode 100644 index 0000000000..bfbfe5f2fd --- /dev/null +++ b/src/app/submission/sections/sherpa-policies/metadata-information/metadata-information.component.html @@ -0,0 +1,39 @@ +
+
+
+

{{ 'submission.sections.sherpa.record.information.id' | translate }}

+
+
+

{{metadata.id}} +

+
+
+
+
+

{{ 'submission.sections.sherpa.record.information.date.created' | translate }}

+
+
+

{{metadata.dateCreated | date: 'd MMMM Y H:mm:ss zzzz' }} +

+
+
+
+
+

{{ 'submission.sections.sherpa.record.information.date.modified' | translate }}

+
+
+

{{metadata.dateModified| date: 'd MMMM Y H:mm:ss zzzz' }} +

+
+
+
+
+

{{ 'submission.sections.sherpa.record.information.uri' | translate }}

+
+ +
+
\ No newline at end of file diff --git a/src/app/submission/sections/sherpa-policies/metadata-information/metadata-information.component.scss b/src/app/submission/sections/sherpa-policies/metadata-information/metadata-information.component.scss new file mode 100644 index 0000000000..e69de29bb2 diff --git a/src/app/submission/sections/sherpa-policies/metadata-information/metadata-information.component.spec.ts b/src/app/submission/sections/sherpa-policies/metadata-information/metadata-information.component.spec.ts new file mode 100644 index 0000000000..c1257fc802 --- /dev/null +++ b/src/app/submission/sections/sherpa-policies/metadata-information/metadata-information.component.spec.ts @@ -0,0 +1,25 @@ +import { ComponentFixture, TestBed } from '@angular/core/testing'; + +import { MetadataInformationComponent } from './metadata-information.component'; + +describe('MetadataInformationComponent', () => { + let component: MetadataInformationComponent; + let fixture: ComponentFixture; + + beforeEach(async () => { + await TestBed.configureTestingModule({ + declarations: [ MetadataInformationComponent ] + }) + .compileComponents(); + }); + + beforeEach(() => { + fixture = TestBed.createComponent(MetadataInformationComponent); + component = fixture.componentInstance; + fixture.detectChanges(); + }); + + it('should create', () => { + expect(component).toBeTruthy(); + }); +}); diff --git a/src/app/submission/sections/sherpa-policies/metadata-information/metadata-information.component.ts b/src/app/submission/sections/sherpa-policies/metadata-information/metadata-information.component.ts new file mode 100644 index 0000000000..334aa43593 --- /dev/null +++ b/src/app/submission/sections/sherpa-policies/metadata-information/metadata-information.component.ts @@ -0,0 +1,13 @@ +import { Component, Input } from '@angular/core'; +import { Metadata } from './../../../../core/submission/models/sherpa-policies-details.model'; + +@Component({ + selector: 'ds-metadata-information', + templateUrl: './metadata-information.component.html', + styleUrls: ['./metadata-information.component.scss'] +}) +export class MetadataInformationComponent { + + @Input() metadata: Metadata; + +} diff --git a/src/app/submission/sections/sherpa-policies/publication-information/publication-information.component.html b/src/app/submission/sections/sherpa-policies/publication-information/publication-information.component.html new file mode 100644 index 0000000000..2e6da459ae --- /dev/null +++ b/src/app/submission/sections/sherpa-policies/publication-information/publication-information.component.html @@ -0,0 +1,70 @@ +
+
+
+

{{'submission.sections.sherpa.publication.information.title' + | translate}}

+
+
+

{{title}} +

+
+
+
+
+

{{'submission.sections.sherpa.publication.information.issns' + | translate}}

+
+
+

{{issn}} +

+
+
+
+
+

{{'submission.sections.sherpa.publication.information.url' + | translate}}

+
+ +
+
+
+

{{'submission.sections.sherpa.publication.information.publishers' + | translate}}

+
+ +
+
+
+

{{'submission.sections.sherpa.publication.information.romeoPub' + | translate}}

+
+
+

+ {{journal.romeoPub}} +

+
+
+
+
+

{{'submission.sections.sherpa.publication.information.zetoPub' + | translate}}

+
+
+

+ {{journal.zetoPub}} +

+
+
+
\ No newline at end of file diff --git a/src/app/submission/sections/sherpa-policies/publication-information/publication-information.component.scss b/src/app/submission/sections/sherpa-policies/publication-information/publication-information.component.scss new file mode 100644 index 0000000000..e69de29bb2 diff --git a/src/app/submission/sections/sherpa-policies/publication-information/publication-information.component.spec.ts b/src/app/submission/sections/sherpa-policies/publication-information/publication-information.component.spec.ts new file mode 100644 index 0000000000..3f264df21f --- /dev/null +++ b/src/app/submission/sections/sherpa-policies/publication-information/publication-information.component.spec.ts @@ -0,0 +1,25 @@ +import { ComponentFixture, TestBed } from '@angular/core/testing'; + +import { PublicationInformationComponent } from './publication-information.component'; + +describe('PublicationInformationComponent', () => { + let component: PublicationInformationComponent; + let fixture: ComponentFixture; + + beforeEach(async () => { + await TestBed.configureTestingModule({ + declarations: [ PublicationInformationComponent ] + }) + .compileComponents(); + }); + + beforeEach(() => { + fixture = TestBed.createComponent(PublicationInformationComponent); + component = fixture.componentInstance; + fixture.detectChanges(); + }); + + it('should create', () => { + expect(component).toBeTruthy(); + }); +}); diff --git a/src/app/submission/sections/sherpa-policies/publication-information/publication-information.component.ts b/src/app/submission/sections/sherpa-policies/publication-information/publication-information.component.ts new file mode 100644 index 0000000000..a6cd6cc3da --- /dev/null +++ b/src/app/submission/sections/sherpa-policies/publication-information/publication-information.component.ts @@ -0,0 +1,13 @@ +import { Component, Input, OnInit } from '@angular/core'; +import { Journal } from './../../../../core/submission/models/sherpa-policies-details.model'; + +@Component({ + selector: 'ds-publication-information', + templateUrl: './publication-information.component.html', + styleUrls: ['./publication-information.component.scss'] +}) +export class PublicationInformationComponent { + + @Input() journal: Journal; + +} diff --git a/src/app/submission/sections/sherpa-policies/publisher-policy/publisher-policy.component.html b/src/app/submission/sections/sherpa-policies/publisher-policy/publisher-policy.component.html new file mode 100644 index 0000000000..3bc1cb5084 --- /dev/null +++ b/src/app/submission/sections/sherpa-policies/publisher-policy/publisher-policy.component.html @@ -0,0 +1,26 @@ +
+
+
+

+ {{'submission.sections.sherpa.publisher.policy.openaccess' | translate}} +

+
+
+ + + +
+
+

+ {{'submission.sections.sherpa.publisher.policy.more.information' | translate}} +

+ +
+
+ + +
\ No newline at end of file diff --git a/src/app/submission/sections/sherpa-policies/publisher-policy/publisher-policy.component.scss b/src/app/submission/sections/sherpa-policies/publisher-policy/publisher-policy.component.scss new file mode 100644 index 0000000000..e69de29bb2 diff --git a/src/app/submission/sections/sherpa-policies/publisher-policy/publisher-policy.component.spec.ts b/src/app/submission/sections/sherpa-policies/publisher-policy/publisher-policy.component.spec.ts new file mode 100644 index 0000000000..1821a97795 --- /dev/null +++ b/src/app/submission/sections/sherpa-policies/publisher-policy/publisher-policy.component.spec.ts @@ -0,0 +1,25 @@ +import { ComponentFixture, TestBed } from '@angular/core/testing'; + +import { PublisherPolicyComponent } from './publisher-policy.component'; + +describe('PublisherPolicyComponent', () => { + let component: PublisherPolicyComponent; + let fixture: ComponentFixture; + + beforeEach(async () => { + await TestBed.configureTestingModule({ + declarations: [ PublisherPolicyComponent ] + }) + .compileComponents(); + }); + + beforeEach(() => { + fixture = TestBed.createComponent(PublisherPolicyComponent); + component = fixture.componentInstance; + fixture.detectChanges(); + }); + + it('should create', () => { + expect(component).toBeTruthy(); + }); +}); diff --git a/src/app/submission/sections/sherpa-policies/publisher-policy/publisher-policy.component.ts b/src/app/submission/sections/sherpa-policies/publisher-policy/publisher-policy.component.ts new file mode 100644 index 0000000000..e526080d0d --- /dev/null +++ b/src/app/submission/sections/sherpa-policies/publisher-policy/publisher-policy.component.ts @@ -0,0 +1,13 @@ +import { Policy } from './../../../../core/submission/models/sherpa-policies-details.model'; +import { Component, Input, OnInit } from '@angular/core'; + +@Component({ + selector: 'ds-publisher-policy', + templateUrl: './publisher-policy.component.html', + styleUrls: ['./publisher-policy.component.scss'] +}) +export class PublisherPolicyComponent { + + @Input() policy: Policy; + +} diff --git a/src/app/submission/sections/sherpa-policies/section-sherpa-policies.component.html b/src/app/submission/sections/sherpa-policies/section-sherpa-policies.component.html index dbb33ee806..ade01a4312 100644 --- a/src/app/submission/sections/sherpa-policies/section-sherpa-policies.component.html +++ b/src/app/submission/sections/sherpa-policies/section-sherpa-policies.component.html @@ -1,119 +1,48 @@ - - + + + + +
+ + +
+ {{'submission.sections.sherpa.publication.information' + | translate}} +
+ + + +
+ + + +
+ + +
+ {{'submission.sections.sherpa.publisher.policy' + | translate}} +
+ + + +
+
+
+
- - + +
- Publication information + {{'submission.sections.sherpa.record.information' + | translate}}
-
-
-
-

Title

-
-
-

{{title}}

-
-
-
-
-

ISSNs

-
-
-

{{issn}}

-
-
- - -
-
-

romeoPub

-
-
-

- {{sherpaPoliciesData.details.journals.romeoPub}} -

-
-
-
-
-

zetoPub

-
-
-

- {{sherpaPoliciesData.details.journals.zetoPub}} -

-
-
-
- -
-
- - -
- - -
- Publisher Policy -
- -
-
-
-

- Open Access pathways permitted by this journal's policy are listed below by article version. - Click on a pathway for a more detailed view -

-
-
- - - -
-
-

- For more information, please see the following links: -

- -
-
- - -
- - - - +
\ No newline at end of file diff --git a/src/app/submission/sections/sherpa-policies/section-sherpa-policies.component.ts b/src/app/submission/sections/sherpa-policies/section-sherpa-policies.component.ts index 5704d1abbb..662f066663 100644 --- a/src/app/submission/sections/sherpa-policies/section-sherpa-policies.component.ts +++ b/src/app/submission/sections/sherpa-policies/section-sherpa-policies.component.ts @@ -1,18 +1,14 @@ import { WorkspaceitemSectionSherpaPoliciesObject } from './../../../core/submission/models/workspaceitem-section-sherpa-policies.model'; import { SectionSherpaPoliciesService } from './section-sherpa-policies.service'; -import { Component, Inject, ViewChild } from '@angular/core'; -import { FormControl } from '@angular/forms'; +import { Component, Inject, ViewChildren, QueryList } from '@angular/core'; -import { filter, map, mergeMap, take } from 'rxjs/operators'; -import { combineLatest, Observable, of, Subscription } from 'rxjs'; -import { TranslateService } from '@ngx-translate/core'; +import { Observable, of } from 'rxjs'; import { renderSectionFor } from '../sections-decorator'; import { SectionsType } from '../sections-type'; import { SectionDataObject } from '../models/section-data.model'; import { SectionsService } from '../sections.service'; import { SectionModelComponent } from '../models/section.model'; -import { NgbAccordionConfig } from '@ng-bootstrap/ng-bootstrap'; /** * This component represents a section for managing item's access conditions. @@ -25,6 +21,8 @@ import { NgbAccordionConfig } from '@ng-bootstrap/ng-bootstrap'; @renderSectionFor(SectionsType.SherpaPolicies) export class SubmissionSectionSherpaPoliciesComponent extends SectionModelComponent { + @ViewChildren('acc', { emitDistinctChangesOnly: true }) acc: QueryList; + /** * The accesses section data * @type {WorkspaceitemSectionAccessesObject} @@ -56,12 +54,18 @@ export class SubmissionSectionSherpaPoliciesComponent extends SectionModelCompon } + ngAfterViewInit() { + this.acc.forEach(accordion => { + accordion.expandAll(); + }); + } + + /** * Initialize all instance variables and retrieve collection default access conditions */ protected onSectionInit(): void { this.sectionSherpaPoliciesService.getSherpaPoliciesData(this.submissionId, this.sectionData.id).subscribe((sherpaPolicies: WorkspaceitemSectionSherpaPoliciesObject) => { - console.log(sherpaPolicies); this.sherpaPoliciesData = sherpaPolicies; }); } diff --git a/src/app/submission/submission.module.ts b/src/app/submission/submission.module.ts index f1cedc8953..85b8067d0e 100644 --- a/src/app/submission/submission.module.ts +++ b/src/app/submission/submission.module.ts @@ -45,6 +45,9 @@ import { SubmissionAccessesConfigService } from '../core/config/submission-acces import { SectionAccessesService } from './sections/accesses/section-accesses.service'; import { SubmissionSectionSherpaPoliciesComponent } from './sections/sherpa-policies/section-sherpa-policies.component'; import { ContentAccordionComponent } from './sections/sherpa-policies/content-accordion/content-accordion.component'; +import { PublisherPolicyComponent } from './sections/sherpa-policies/publisher-policy/publisher-policy.component'; +import { PublicationInformationComponent } from './sections/sherpa-policies/publication-information/publication-information.component'; +import { MetadataInformationComponent } from './sections/sherpa-policies/metadata-information/metadata-information.component'; const ENTRY_COMPONENTS = [ // put only entry components that use custom decorator @@ -80,6 +83,9 @@ const DECLARATIONS = [ SubmissionImportExternalPreviewComponent, SubmissionImportExternalCollectionComponent, ContentAccordionComponent, + PublisherPolicyComponent, + PublicationInformationComponent, + MetadataInformationComponent, ]; @NgModule({ diff --git a/src/assets/i18n/en.json5 b/src/assets/i18n/en.json5 index c3c68a6882..59079e34eb 100644 --- a/src/assets/i18n/en.json5 +++ b/src/assets/i18n/en.json5 @@ -3987,6 +3987,59 @@ "submission.sections.accesses.form.until-placeholder": "Until", + "submission.sections.sherpa.publication.information": "Publication information", + + "submission.sections.sherpa.publication.information.title": "Title", + + "submission.sections.sherpa.publication.information.issns": "ISSNs", + + "submission.sections.sherpa.publication.information.url": "URL", + + "submission.sections.sherpa.publication.information.publishers": "Publisher", + + "submission.sections.sherpa.publication.information.romeoPub": "Romeo Pub", + + "submission.sections.sherpa.publication.information.zetoPub": "Zeto Pub", + + + "submission.sections.sherpa.publisher.policy": "Publisher Policy", + + "submission.sections.sherpa.publisher.policy.openaccess": "Open Access pathways permitted by this journal's policy are listed below by article version. Click on a pathway for a more detailed view", + + "submission.sections.sherpa.publisher.policy.more.information": "For more information, please see the following links:", + + "submission.sections.sherpa.publisher.policy.version": "Version", + + "submission.sections.sherpa.publisher.policy.embargo": "Embargo", + + "submission.sections.sherpa.publisher.policy.noembargo": "No Embargo", + + "submission.sections.sherpa.publisher.policy.license": "License", + + "submission.sections.sherpa.publisher.policy.prerequisites": "Prerequisites", + + "submission.sections.sherpa.publisher.policy.location": "Location", + + "submission.sections.sherpa.publisher.policy.conditions": "Conditions", + + + "submission.sections.sherpa.record.information": "Record Information", + + "submission.sections.sherpa.record.information.id": "ID", + + "submission.sections.sherpa.record.information.date.created": "Date Created", + + "submission.sections.sherpa.record.information.date.modified": "Last Modified", + + "submission.sections.sherpa.record.information.uri": "URI", + + + + + + + + "submission.submit.breadcrumbs": "New submission", "submission.submit.title": "New submission", From cb84bc758e026d0f42739622af7413358d6dd62b Mon Sep 17 00:00:00 2001 From: Rezart Vata Date: Tue, 26 Apr 2022 17:52:28 +0200 Subject: [PATCH 04/28] [CST-5270] Implemented new refresh button & code refactoring --- .../content-accordion.component.ts | 4 +- .../metadata-information.component.ts | 4 +- .../publication-information.component.ts | 4 +- .../publisher-policy.component.html | 3 -- .../publisher-policy.component.ts | 3 ++ .../section-sherpa-policies.component.html | 6 +++ .../section-sherpa-policies.component.scss | 5 ++ .../section-sherpa-policies.component.ts | 46 ++++++++++++++++--- .../section-sherpa-policies.service.ts | 4 +- src/assets/i18n/en.json5 | 1 + 10 files changed, 66 insertions(+), 14 deletions(-) diff --git a/src/app/submission/sections/sherpa-policies/content-accordion/content-accordion.component.ts b/src/app/submission/sections/sherpa-policies/content-accordion/content-accordion.component.ts index 12b48d10f4..378f08c8bc 100644 --- a/src/app/submission/sections/sherpa-policies/content-accordion/content-accordion.component.ts +++ b/src/app/submission/sections/sherpa-policies/content-accordion/content-accordion.component.ts @@ -7,7 +7,9 @@ import { Component, Input } from '@angular/core'; styleUrls: ['./content-accordion.component.scss'] }) export class ContentAccordionComponent { - + /** + * PermittedVersions to show information from + */ @Input() version: PermittedVersions; } diff --git a/src/app/submission/sections/sherpa-policies/metadata-information/metadata-information.component.ts b/src/app/submission/sections/sherpa-policies/metadata-information/metadata-information.component.ts index 334aa43593..8b85237762 100644 --- a/src/app/submission/sections/sherpa-policies/metadata-information/metadata-information.component.ts +++ b/src/app/submission/sections/sherpa-policies/metadata-information/metadata-information.component.ts @@ -7,7 +7,9 @@ import { Metadata } from './../../../../core/submission/models/sherpa-policies-d styleUrls: ['./metadata-information.component.scss'] }) export class MetadataInformationComponent { - + /** + * Metadata to show information from + */ @Input() metadata: Metadata; } diff --git a/src/app/submission/sections/sherpa-policies/publication-information/publication-information.component.ts b/src/app/submission/sections/sherpa-policies/publication-information/publication-information.component.ts index a6cd6cc3da..a5306406af 100644 --- a/src/app/submission/sections/sherpa-policies/publication-information/publication-information.component.ts +++ b/src/app/submission/sections/sherpa-policies/publication-information/publication-information.component.ts @@ -7,7 +7,9 @@ import { Journal } from './../../../../core/submission/models/sherpa-policies-de styleUrls: ['./publication-information.component.scss'] }) export class PublicationInformationComponent { - + /** + * Journal to show information from + */ @Input() journal: Journal; } diff --git a/src/app/submission/sections/sherpa-policies/publisher-policy/publisher-policy.component.html b/src/app/submission/sections/sherpa-policies/publisher-policy/publisher-policy.component.html index 3bc1cb5084..4a03bae735 100644 --- a/src/app/submission/sections/sherpa-policies/publisher-policy/publisher-policy.component.html +++ b/src/app/submission/sections/sherpa-policies/publisher-policy/publisher-policy.component.html @@ -8,7 +8,6 @@
-

@@ -21,6 +20,4 @@

- -
\ No newline at end of file diff --git a/src/app/submission/sections/sherpa-policies/publisher-policy/publisher-policy.component.ts b/src/app/submission/sections/sherpa-policies/publisher-policy/publisher-policy.component.ts index e526080d0d..dcbc115ddd 100644 --- a/src/app/submission/sections/sherpa-policies/publisher-policy/publisher-policy.component.ts +++ b/src/app/submission/sections/sherpa-policies/publisher-policy/publisher-policy.component.ts @@ -8,6 +8,9 @@ import { Component, Input, OnInit } from '@angular/core'; }) export class PublisherPolicyComponent { + /** + * Policy to show information from + */ @Input() policy: Policy; } diff --git a/src/app/submission/sections/sherpa-policies/section-sherpa-policies.component.html b/src/app/submission/sections/sherpa-policies/section-sherpa-policies.component.html index ade01a4312..6756793fd5 100644 --- a/src/app/submission/sections/sherpa-policies/section-sherpa-policies.component.html +++ b/src/app/submission/sections/sherpa-policies/section-sherpa-policies.component.html @@ -1,3 +1,9 @@ +
+ +
+ diff --git a/src/app/submission/sections/sherpa-policies/section-sherpa-policies.component.scss b/src/app/submission/sections/sherpa-policies/section-sherpa-policies.component.scss index 8c1bfc2580..5a8e0e3c34 100644 --- a/src/app/submission/sections/sherpa-policies/section-sherpa-policies.component.scss +++ b/src/app/submission/sections/sherpa-policies/section-sherpa-policies.component.scss @@ -28,4 +28,9 @@ } } +} + +.refresh-container { + display: flex; + justify-content: right; } \ No newline at end of file diff --git a/src/app/submission/sections/sherpa-policies/section-sherpa-policies.component.ts b/src/app/submission/sections/sherpa-policies/section-sherpa-policies.component.ts index 662f066663..f5eaaa773a 100644 --- a/src/app/submission/sections/sherpa-policies/section-sherpa-policies.component.ts +++ b/src/app/submission/sections/sherpa-policies/section-sherpa-policies.component.ts @@ -1,14 +1,18 @@ +import { JsonPatchOperationPathCombiner } from './../../../core/json-patch/builder/json-patch-operation-path-combiner'; +import { JsonPatchOperationsBuilder } from './../../../core/json-patch/builder/json-patch-operations-builder'; import { WorkspaceitemSectionSherpaPoliciesObject } from './../../../core/submission/models/workspaceitem-section-sherpa-policies.model'; import { SectionSherpaPoliciesService } from './section-sherpa-policies.service'; import { Component, Inject, ViewChildren, QueryList } from '@angular/core'; -import { Observable, of } from 'rxjs'; +import { Observable, of, Subscription } from 'rxjs'; import { renderSectionFor } from '../sections-decorator'; import { SectionsType } from '../sections-type'; import { SectionDataObject } from '../models/section-data.model'; import { SectionsService } from '../sections.service'; import { SectionModelComponent } from '../models/section.model'; +import { SubmissionService } from '../../submission.service'; +import { hasValue } from '../../../shared/empty.util'; /** * This component represents a section for managing item's access conditions. @@ -29,6 +33,17 @@ export class SubmissionSectionSherpaPoliciesComponent extends SectionModelCompon */ public sherpaPoliciesData: WorkspaceitemSectionSherpaPoliciesObject; + /** + * The [[JsonPatchOperationPathCombiner]] object + * @type {JsonPatchOperationPathCombiner} + */ + protected pathCombiner: JsonPatchOperationPathCombiner; + + /** + * Array to track all subscriptions and unsubscribe them onDestroy + * @type {Array} + */ + protected subs: Subscription[] = []; /** * Initialize instance variables @@ -36,11 +51,15 @@ export class SubmissionSectionSherpaPoliciesComponent extends SectionModelCompon * @param {SectionsService} sectionService * @param {SectionDataObject} injectedSectionData * @param {SectionSherpaPoliciesService} sectionSherpaPoliciesService + * @param {JsonPatchOperationsBuilder} operationsBuilder + * @param {SubmissionService} submissionService * @param {string} injectedSubmissionId */ constructor( protected sectionService: SectionsService, private sectionSherpaPoliciesService: SectionSherpaPoliciesService, + protected operationsBuilder: JsonPatchOperationsBuilder, + private submissionService: SubmissionService, @Inject('sectionDataProvider') public injectedSectionData: SectionDataObject, @Inject('submissionIdProvider') public injectedSubmissionId: string) { super(undefined, injectedSectionData, injectedSubmissionId); @@ -49,11 +68,15 @@ export class SubmissionSectionSherpaPoliciesComponent extends SectionModelCompon /** * Unsubscribe from all subscriptions */ - // tslint:disable-next-line:no-empty onSectionDestroy() { - + this.subs + .filter((subscription) => hasValue(subscription)) + .forEach((subscription) => subscription.unsubscribe()); } + /** + * Expand all primary accordions + */ ngAfterViewInit() { this.acc.forEach(accordion => { accordion.expandAll(); @@ -65,9 +88,12 @@ export class SubmissionSectionSherpaPoliciesComponent extends SectionModelCompon * Initialize all instance variables and retrieve collection default access conditions */ protected onSectionInit(): void { - this.sectionSherpaPoliciesService.getSherpaPoliciesData(this.submissionId, this.sectionData.id).subscribe((sherpaPolicies: WorkspaceitemSectionSherpaPoliciesObject) => { - this.sherpaPoliciesData = sherpaPolicies; - }); + this.pathCombiner = new JsonPatchOperationPathCombiner('sections', this.sectionData.id); + this.subs.push( + this.sectionSherpaPoliciesService.getSherpaPoliciesData(this.submissionId, this.sectionData.id).subscribe((sherpaPolicies: WorkspaceitemSectionSherpaPoliciesObject) => { + this.sherpaPoliciesData = sherpaPolicies; + }) + ); } /** @@ -80,4 +106,12 @@ export class SubmissionSectionSherpaPoliciesComponent extends SectionModelCompon return of(true); } + /** + * Refresh sherpa information + */ + refresh() { + this.operationsBuilder.remove(this.pathCombiner.getPath('retrievalTime')); + this.submissionService.dispatchSaveSection(this.submissionId, this.sectionData.id); + } + } diff --git a/src/app/submission/sections/sherpa-policies/section-sherpa-policies.service.ts b/src/app/submission/sections/sherpa-policies/section-sherpa-policies.service.ts index c81caca41e..4ddf4509cb 100644 --- a/src/app/submission/sections/sherpa-policies/section-sherpa-policies.service.ts +++ b/src/app/submission/sections/sherpa-policies/section-sherpa-policies.service.ts @@ -10,7 +10,7 @@ import { isNotUndefined } from '../../../shared/empty.util'; import { submissionSectionDataFromIdSelector } from '../../selectors'; /** - * A service that provides methods to handle submission item's accesses condition state. + * A service that provides methods to handle submission item's sherpa policies state. */ @Injectable() export class SectionSherpaPoliciesService { @@ -24,7 +24,7 @@ export class SectionSherpaPoliciesService { /** - * Return item's accesses condition state. + * Return item's sherpa policies state. * * @param submissionId * The submission id diff --git a/src/assets/i18n/en.json5 b/src/assets/i18n/en.json5 index 59079e34eb..3c2ad2505f 100644 --- a/src/assets/i18n/en.json5 +++ b/src/assets/i18n/en.json5 @@ -4022,6 +4022,7 @@ "submission.sections.sherpa.publisher.policy.conditions": "Conditions", + "submission.sections.sherpa.publisher.policy.refresh": "Refresh", "submission.sections.sherpa.record.information": "Record Information", From 107199eb8e474848e0ff634f5c65687837a62e63 Mon Sep 17 00:00:00 2001 From: Rezart Vata Date: Wed, 27 Apr 2022 13:40:33 +0200 Subject: [PATCH 05/28] [CST-5270] Finished unit testing --- .../section-sherpa-policies.service.mock.ts | 108 +++++++++++ .../content-accordion.component.spec.ts | 30 ++- .../metadata-information.component.spec.ts | 25 ++- .../publication-information.component.spec.ts | 26 ++- .../publisher-policy.component.spec.ts | 29 ++- .../section-sherpa-policies.component.spec.ts | 180 ++++++------------ 6 files changed, 263 insertions(+), 135 deletions(-) create mode 100644 src/app/shared/mocks/section-sherpa-policies.service.mock.ts diff --git a/src/app/shared/mocks/section-sherpa-policies.service.mock.ts b/src/app/shared/mocks/section-sherpa-policies.service.mock.ts new file mode 100644 index 0000000000..895e518d96 --- /dev/null +++ b/src/app/shared/mocks/section-sherpa-policies.service.mock.ts @@ -0,0 +1,108 @@ +import { WorkspaceitemSectionSherpaPoliciesObject } from './../../core/submission/models/workspaceitem-section-sherpa-policies.model'; +import { SubmissionFormsModel } from '../../core/config/models/config-submission-forms.model'; +import { of as observableOf } from 'rxjs'; + +export const dataRes = { + 'id': 'sherpaPolicies', + 'retrievalTime': '2022-04-20T09:44:39.870+00:00', + 'sherpaResponse': [ + { + 'error': false, + 'message': null, + 'metadata': { + 'id': 23803, + 'uri': 'http://v2.sherpa.ac.uk/id/publication/23803', + 'dateCreated': '2012-11-20 14:51:52', + 'dateModified': '2020-03-06 11:25:54', + 'inDOAJ': false, + 'publiclyVisible': true + }, + 'journals': [{ + 'titles': ['The Lancet', 'Lancet'], + 'url': 'http://www.thelancet.com/journals/lancet/issue/current', + 'issns': ['0140-6736', '1474-547X'], + 'romeoPub': 'Elsevier: The Lancet', + 'zetoPub': 'Elsevier: The Lancet', + 'publisher': { + 'name': 'Elsevier', + 'relationshipType': null, + 'country': null, + 'uri': 'http://www.elsevier.com/', + 'identifier': null, + 'publicationCount': 0, + 'paidAccessDescription': 'Open access', + 'paidAccessUrl': 'https://www.elsevier.com/about/open-science/open-access' + }, + 'publishers': [{ + 'name': 'Elsevier', + 'relationshipType': null, + 'country': null, + 'uri': 'http://www.elsevier.com/', + 'identifier': null, + 'publicationCount': 0, + 'paidAccessDescription': 'Open access', + 'paidAccessUrl': 'https://www.elsevier.com/about/open-science/open-access' + }], + 'policies': [{ + 'id': 0, + 'openAccessPermitted': false, + 'uri': null, + 'internalMoniker': 'Lancet', + 'permittedVersions': [{ + 'articleVersion': 'submitted', + 'option': 1, + 'conditions': ['Upon publication publisher copyright and source must be acknowledged', 'Upon publication must link to publisher version'], + 'prerequisites': [], + 'locations': ['Author\'s Homepage', 'Preprint Repository'], + 'licenses': [], + 'embargo': null + }, { + 'articleVersion': 'accepted', + 'option': 1, + 'conditions': ['Publisher copyright and source must be acknowledged', 'Must link to publisher version'], + 'prerequisites': [], + 'locations': ['Author\'s Homepage', 'Institutional Website'], + 'licenses': ['CC BY-NC-ND'], + 'embargo': null + }, { + 'articleVersion': 'accepted', + 'option': 2, + 'conditions': ['Publisher copyright and source must be acknowledged', 'Must link to publisher version'], + 'prerequisites': ['If Required by Funder'], + 'locations': ['Non-Commercial Repository'], + 'licenses': ['CC BY-NC-ND'], + 'embargo': null + }, { + 'articleVersion': 'accepted', + 'option': 3, + 'conditions': ['Publisher copyright and source must be acknowledged', 'Must link to publisher version'], + 'prerequisites': [], + 'locations': ['Non-Commercial Repository'], + 'licenses': [], + 'embargo': null + }], + 'urls': { + 'http://download.thelancet.com/flatcontentassets/authors/lancet-information-for-authors.pdf': 'Guidelines for Authors', + 'http://www.thelancet.com/journals/lancet/article/PIIS0140-6736%2813%2960720-5/fulltext': 'The Lancet journals welcome a new open access policy', + 'http://www.thelancet.com/lancet-information-for-authors/after-publication': 'What happens after publication?', + 'http://www.thelancet.com/lancet/information-for-authors/disclosure-of-results': 'Disclosure of results before publication', + 'https://www.elsevier.com/__data/assets/pdf_file/0005/78476/external-embargo-list.pdf': 'Journal Embargo Period List', + 'https://www.elsevier.com/__data/assets/pdf_file/0011/78473/UK-Embargo-Periods.pdf': 'Journal Embargo List for UK Authors' + }, + 'openAccessProhibited': false, + 'publicationCount': 0, + 'preArchiving': 'can', + 'postArchiving': 'can', + 'pubArchiving': 'cannot' + }], + 'inDOAJ': false + }] + } + ] +} as WorkspaceitemSectionSherpaPoliciesObject; + +export function getSherpaPoliciesData() { + return jasmine.createSpyObj('SectionAccessesService', { + getSherpaPoliciesData: observableOf(dataRes), + }); +} diff --git a/src/app/submission/sections/sherpa-policies/content-accordion/content-accordion.component.spec.ts b/src/app/submission/sections/sherpa-policies/content-accordion/content-accordion.component.spec.ts index 3b4d18a633..ec1180a6c9 100644 --- a/src/app/submission/sections/sherpa-policies/content-accordion/content-accordion.component.spec.ts +++ b/src/app/submission/sections/sherpa-policies/content-accordion/content-accordion.component.spec.ts @@ -1,25 +1,51 @@ +import { NgbAccordionModule } from '@ng-bootstrap/ng-bootstrap'; +import { TranslateLoaderMock } from './../../../../shared/testing/translate-loader.mock'; import { ComponentFixture, TestBed } from '@angular/core/testing'; import { ContentAccordionComponent } from './content-accordion.component'; +import { dataRes } from './../../../../shared/mocks/section-sherpa-policies.service.mock'; +import { DebugElement } from '@angular/core'; +import { By } from '@angular/platform-browser'; +import { TranslateLoader, TranslateModule } from '@ngx-translate/core'; describe('ContentAccordionComponent', () => { let component: ContentAccordionComponent; let fixture: ComponentFixture; + let de: DebugElement; beforeEach(async () => { await TestBed.configureTestingModule({ - declarations: [ ContentAccordionComponent ] + imports: [ + TranslateModule.forRoot({ + loader: { + provide: TranslateLoader, + useClass: TranslateLoaderMock + } + }), + NgbAccordionModule + ], + declarations: [ContentAccordionComponent] }) - .compileComponents(); + .compileComponents(); }); beforeEach(() => { fixture = TestBed.createComponent(ContentAccordionComponent); component = fixture.componentInstance; + de = fixture.debugElement; + component.version = dataRes.sherpaResponse[0].journals[0].policies[0].permittedVersions[0]; fixture.detectChanges(); }); it('should create', () => { expect(component).toBeTruthy(); }); + + it('should show accordion', () => { + expect(de.query(By.css('ngb-accordion'))).toBeTruthy(); + }); + + it('should show 5 rows', () => { + expect(de.queryAll(By.css('.row')).length).toEqual(5); + }); }); diff --git a/src/app/submission/sections/sherpa-policies/metadata-information/metadata-information.component.spec.ts b/src/app/submission/sections/sherpa-policies/metadata-information/metadata-information.component.spec.ts index c1257fc802..b329fb1821 100644 --- a/src/app/submission/sections/sherpa-policies/metadata-information/metadata-information.component.spec.ts +++ b/src/app/submission/sections/sherpa-policies/metadata-information/metadata-information.component.spec.ts @@ -1,25 +1,46 @@ +import { TranslateLoaderMock } from './../../../../shared/testing/translate-loader.mock'; import { ComponentFixture, TestBed } from '@angular/core/testing'; import { MetadataInformationComponent } from './metadata-information.component'; +import { dataRes } from './../../../../shared/mocks/section-sherpa-policies.service.mock'; +import { DebugElement } from '@angular/core'; +import { By } from '@angular/platform-browser'; +import { TranslateLoader, TranslateModule } from '@ngx-translate/core'; describe('MetadataInformationComponent', () => { let component: MetadataInformationComponent; let fixture: ComponentFixture; + let de: DebugElement; beforeEach(async () => { await TestBed.configureTestingModule({ - declarations: [ MetadataInformationComponent ] + imports: [ + TranslateModule.forRoot({ + loader: { + provide: TranslateLoader, + useClass: TranslateLoaderMock + } + }), + ], + declarations: [MetadataInformationComponent] }) - .compileComponents(); + .compileComponents(); }); beforeEach(() => { fixture = TestBed.createComponent(MetadataInformationComponent); component = fixture.componentInstance; + de = fixture.debugElement; + component.metadata = dataRes.sherpaResponse[0].metadata; fixture.detectChanges(); }); it('should create', () => { expect(component).toBeTruthy(); }); + + it('should show 4 rows', () => { + expect(de.queryAll(By.css('.row')).length).toEqual(4); + }); + }); diff --git a/src/app/submission/sections/sherpa-policies/publication-information/publication-information.component.spec.ts b/src/app/submission/sections/sherpa-policies/publication-information/publication-information.component.spec.ts index 3f264df21f..e1acc016ab 100644 --- a/src/app/submission/sections/sherpa-policies/publication-information/publication-information.component.spec.ts +++ b/src/app/submission/sections/sherpa-policies/publication-information/publication-information.component.spec.ts @@ -1,25 +1,47 @@ +import { TranslateLoaderMock } from './../../../../shared/testing/translate-loader.mock'; import { ComponentFixture, TestBed } from '@angular/core/testing'; import { PublicationInformationComponent } from './publication-information.component'; +import { dataRes } from './../../../../shared/mocks/section-sherpa-policies.service.mock'; +import { DebugElement } from '@angular/core'; +import { By } from '@angular/platform-browser'; +import { TranslateLoader, TranslateModule } from '@ngx-translate/core'; describe('PublicationInformationComponent', () => { let component: PublicationInformationComponent; let fixture: ComponentFixture; + let de: DebugElement; + beforeEach(async () => { await TestBed.configureTestingModule({ - declarations: [ PublicationInformationComponent ] + imports: [ + TranslateModule.forRoot({ + loader: { + provide: TranslateLoader, + useClass: TranslateLoaderMock + } + }), + ], + declarations: [PublicationInformationComponent] }) - .compileComponents(); + .compileComponents(); }); beforeEach(() => { fixture = TestBed.createComponent(PublicationInformationComponent); component = fixture.componentInstance; + de = fixture.debugElement; + component.journal = dataRes.sherpaResponse[0].journals[0]; fixture.detectChanges(); }); it('should create', () => { expect(component).toBeTruthy(); }); + + it('should show 6 rows', () => { + expect(de.queryAll(By.css('.row')).length).toEqual(6); + }); + }); diff --git a/src/app/submission/sections/sherpa-policies/publisher-policy/publisher-policy.component.spec.ts b/src/app/submission/sections/sherpa-policies/publisher-policy/publisher-policy.component.spec.ts index 1821a97795..9ba77adf94 100644 --- a/src/app/submission/sections/sherpa-policies/publisher-policy/publisher-policy.component.spec.ts +++ b/src/app/submission/sections/sherpa-policies/publisher-policy/publisher-policy.component.spec.ts @@ -1,25 +1,50 @@ +import { TranslateLoaderMock } from './../../../../shared/testing/translate-loader.mock'; import { ComponentFixture, TestBed } from '@angular/core/testing'; import { PublisherPolicyComponent } from './publisher-policy.component'; +import { dataRes } from './../../../../shared/mocks/section-sherpa-policies.service.mock'; +import { By } from '@angular/platform-browser'; +import { DebugElement } from '@angular/core'; +import { TranslateLoader, TranslateModule, TranslateService } from '@ngx-translate/core'; +import { getMockTranslateService } from '../../../../shared/mocks/translate.service.mock'; describe('PublisherPolicyComponent', () => { let component: PublisherPolicyComponent; let fixture: ComponentFixture; + let de: DebugElement; beforeEach(async () => { await TestBed.configureTestingModule({ - declarations: [ PublisherPolicyComponent ] + imports: [ + TranslateModule.forRoot({ + loader: { + provide: TranslateLoader, + useClass: TranslateLoaderMock + } + }), + ], + declarations: [PublisherPolicyComponent], }) - .compileComponents(); + .compileComponents(); }); beforeEach(() => { fixture = TestBed.createComponent(PublisherPolicyComponent); component = fixture.componentInstance; + de = fixture.debugElement; + component.policy = dataRes.sherpaResponse[0].journals[0].policies[0]; fixture.detectChanges(); }); it('should create', () => { expect(component).toBeTruthy(); }); + + it('should show content accordion', () => { + expect(de.query(By.css('ds-content-accordion'))).toBeTruthy(); + }); + + it('should show 2 rows', () => { + expect(de.queryAll(By.css('.row')).length).toEqual(2); + }); }); diff --git a/src/app/submission/sections/sherpa-policies/section-sherpa-policies.component.spec.ts b/src/app/submission/sections/sherpa-policies/section-sherpa-policies.component.spec.ts index 5509cab4bb..ce64406486 100644 --- a/src/app/submission/sections/sherpa-policies/section-sherpa-policies.component.spec.ts +++ b/src/app/submission/sections/sherpa-policies/section-sherpa-policies.component.spec.ts @@ -1,100 +1,80 @@ -import { FormService } from '../../../shared/form/form.service'; +import { NgbAccordionModule } from '@ng-bootstrap/ng-bootstrap'; +import { SubmissionServiceStub } from './../../../shared/testing/submission-service.stub'; +import { dataRes, getSherpaPoliciesData } from './../../../shared/mocks/section-sherpa-policies.service.mock'; import { ComponentFixture, inject, TestBed } from '@angular/core/testing'; -import { SubmissionSectionAccessesComponent } from './section-accesses.component'; import { SectionsService } from '../sections.service'; import { SectionsServiceStub } from '../../../shared/testing/sections-service.stub'; import { FormBuilderService } from '../../../shared/form/builder/form-builder.service'; import { getMockFormBuilderService } from '../../../shared/mocks/form-builder-service.mock'; -import { SubmissionAccessesConfigService } from '../../../core/config/submission-accesses-config.service'; -import { - getSubmissionAccessesConfigNotChangeDiscoverableService, - getSubmissionAccessesConfigService -} from '../../../shared/mocks/section-accesses-config.service.mock'; -import { SectionAccessesService } from './section-accesses.service'; -import { SectionFormOperationsService } from '../form/section-form-operations.service'; import { JsonPatchOperationsBuilder } from '../../../core/json-patch/builder/json-patch-operations-builder'; -import { TranslateModule, TranslateService } from '@ngx-translate/core'; -import { SubmissionJsonPatchOperationsService } from '../../../core/submission/submission-json-patch-operations.service'; -import { getSectionAccessesService } from '../../../shared/mocks/section-accesses.service.mock'; -import { getMockFormOperationsService } from '../../../shared/mocks/form-operations-service.mock'; +import { TranslateLoader, TranslateModule, TranslateService } from '@ngx-translate/core'; import { getMockTranslateService } from '../../../shared/mocks/translate.service.mock'; -import { SubmissionJsonPatchOperationsServiceStub } from '../../../shared/testing/submission-json-patch-operations-service.stub'; -import { BrowserModule } from '@angular/platform-browser'; +import { BrowserModule, By } from '@angular/platform-browser'; -import { of as observableOf } from 'rxjs'; import { Store } from '@ngrx/store'; -import { FormComponent } from '../../../shared/form/form.component'; -import { - DynamicCheckboxModel, - DynamicDatePickerModel, - DynamicFormArrayModel, - DynamicSelectModel -} from '@ng-dynamic-forms/core'; import { AppState } from '../../../app.reducer'; -import { getMockFormService } from '../../../shared/mocks/form-service.mock'; -import { mockAccessesFormData } from '../../../shared/mocks/submission.mock'; -import { accessConditionChangeEvent, checkboxChangeEvent } from '../../../shared/testing/form-event.stub'; +import { SectionSherpaPoliciesService } from './section-sherpa-policies.service'; +import { SubmissionSectionSherpaPoliciesComponent } from './section-sherpa-policies.component'; +import { SubmissionService } from '../../submission.service'; +import { DebugElement } from '@angular/core'; +import { TranslateLoaderMock } from 'src/app/shared/mocks/translate-loader.mock'; -describe('SubmissionSectionAccessesComponent', () => { - let component: SubmissionSectionAccessesComponent; - let fixture: ComponentFixture; +describe('SubmissionSectionSherpaPoliciesComponent', () => { + let component: SubmissionSectionSherpaPoliciesComponent; + let fixture: ComponentFixture; + let de: DebugElement; const sectionsServiceStub = new SectionsServiceStub(); // const pathCombiner = new JsonPatchOperationPathCombiner('sections', sectionId, 'files', fileIndex); const builderService: FormBuilderService = getMockFormBuilderService(); - const submissionAccessesConfigService = getSubmissionAccessesConfigService(); - const sectionAccessesService = getSectionAccessesService(); - const sectionFormOperationsService = getMockFormOperationsService(); + const sectionSherpaPoliciesService = getSherpaPoliciesData(); + const operationsBuilder = jasmine.createSpyObj('operationsBuilder', { add: undefined, remove: undefined, replace: undefined, }); - let formService: any; - const storeStub = jasmine.createSpyObj('store', ['dispatch']); const sectionData = { - header: 'submit.progressbar.accessCondition', - config: 'http://localhost:8080/server/api/config/submissionaccessoptions/AccessConditionDefaultConfiguration', + header: 'submit.progressbar.sherpaPolicies', + config: 'http://localhost:8080/server/api/config/submissionaccessoptions/SherpaPoliciesDefaultConfiguration', mandatory: true, - sectionType: 'accessCondition', + sectionType: 'sherpaPolicies', collapsed: false, enabled: true, - data: { - discoverable: true, - accessConditions: [] - }, + data: dataRes, errorsToShow: [], serverValidationErrors: [], isLoading: false, isValid: true }; - describe('First with canChangeDiscoverable true', () => { + describe('SubmissionSectionSherpaPoliciesComponent', () => { beforeEach(async () => { await TestBed.configureTestingModule({ imports: [ BrowserModule, - TranslateModule.forRoot() + TranslateModule.forRoot({ + loader: { + provide: TranslateLoader, + useClass: TranslateLoaderMock + } + }), + NgbAccordionModule ], - declarations: [SubmissionSectionAccessesComponent, FormComponent], + declarations: [SubmissionSectionSherpaPoliciesComponent], providers: [ { provide: SectionsService, useValue: sectionsServiceStub }, - { provide: FormBuilderService, useValue: builderService }, - { provide: SubmissionAccessesConfigService, useValue: submissionAccessesConfigService }, - { provide: SectionAccessesService, useValue: sectionAccessesService }, - { provide: SectionFormOperationsService, useValue: sectionFormOperationsService }, + { provide: SectionSherpaPoliciesService, useValue: sectionSherpaPoliciesService }, { provide: JsonPatchOperationsBuilder, useValue: operationsBuilder }, - { provide: TranslateService, useValue: getMockTranslateService() }, - { provide: FormService, useValue: getMockFormService() }, + { provide: SubmissionService, useValue: SubmissionServiceStub }, { provide: Store, useValue: storeStub }, - { provide: SubmissionJsonPatchOperationsService, useValue: SubmissionJsonPatchOperationsServiceStub }, { provide: 'sectionDataProvider', useValue: sectionData }, { provide: 'submissionIdProvider', useValue: '1508' }, ] @@ -103,12 +83,9 @@ describe('SubmissionSectionAccessesComponent', () => { }); beforeEach(inject([Store], (store: Store) => { - fixture = TestBed.createComponent(SubmissionSectionAccessesComponent); + fixture = TestBed.createComponent(SubmissionSectionSherpaPoliciesComponent); component = fixture.componentInstance; - formService = TestBed.inject(FormService); - formService.validateAllFormFields.and.callFake(() => null); - formService.isValid.and.returnValue(observableOf(true)); - formService.getFormData.and.returnValue(observableOf(mockAccessesFormData)); + de = fixture.debugElement; fixture.detectChanges(); })); @@ -117,88 +94,37 @@ describe('SubmissionSectionAccessesComponent', () => { expect(component).toBeTruthy(); }); - it('should have created formModel', () => { - expect(component.formModel).toBeTruthy(); + it('should show accordions', () => { + expect(de.query(By.css('ngb-accordion'))).toBeTruthy(); }); - it('should have formModel length should be 2', () => { - expect(component.formModel.length).toEqual(2); + it('should show expanded accordion', () => { + expect(component.acc.first.isExpanded('publication-information-0')).toBeTrue(); }); - it('formModel should have 1 model type checkbox and 1 model type array', () => { - expect(component.formModel[0] instanceof DynamicCheckboxModel).toBeTrue(); - expect(component.formModel[1] instanceof DynamicFormArrayModel).toBeTrue(); + it('should show refresh button', () => { + expect(de.query(By.css('.refresh-container > button'))).toBeTruthy(); }); - it('formModel type array should have formgroup with 1 input and 2 datepickers', () => { - const formModel: any = component.formModel[1]; - const formGroup = formModel.groupFactory()[0].group; - expect(formGroup[0] instanceof DynamicSelectModel).toBeTrue(); - expect(formGroup[1] instanceof DynamicDatePickerModel).toBeTrue(); - expect(formGroup[2] instanceof DynamicDatePickerModel).toBeTrue(); + it('should show publisher information', () => { + expect(de.query(By.css('ds-publication-information'))).toBeTruthy(); }); - it('when checkbox changed it should call operationsBuilder replace function', () => { - component.onChange(checkboxChangeEvent); + it('should show publisher policy', () => { + expect(de.query(By.css('ds-publisher-policy'))).toBeTruthy(); + }); + + it('should show metadata information', () => { + expect(de.query(By.css('ds-metadata-information'))).toBeTruthy(); + }); + + it('when refresh button click operationsBuilder.remove should have been called', () => { + de.query(By.css('.refresh-container > button')).nativeElement.click(); fixture.detectChanges(); - - expect(operationsBuilder.replace).toHaveBeenCalled(); + expect(operationsBuilder.remove).toHaveBeenCalled(); }); - it('when dropdown select changed it should call operationsBuilder add function', () => { - component.onChange(accessConditionChangeEvent); - fixture.detectChanges(); - expect(operationsBuilder.add).toHaveBeenCalled(); - }); + }); - describe('when canDescoverable is false', () => { - - - - beforeEach(async () => { - await TestBed.configureTestingModule({ - imports: [ - BrowserModule, - TranslateModule.forRoot() - ], - declarations: [SubmissionSectionAccessesComponent, FormComponent], - providers: [ - { provide: SectionsService, useValue: sectionsServiceStub }, - { provide: FormBuilderService, useValue: builderService }, - { provide: SubmissionAccessesConfigService, useValue: getSubmissionAccessesConfigNotChangeDiscoverableService() }, - { provide: SectionAccessesService, useValue: sectionAccessesService }, - { provide: SectionFormOperationsService, useValue: sectionFormOperationsService }, - { provide: JsonPatchOperationsBuilder, useValue: operationsBuilder }, - { provide: TranslateService, useValue: getMockTranslateService() }, - { provide: FormService, useValue: getMockFormService() }, - { provide: Store, useValue: storeStub }, - { provide: SubmissionJsonPatchOperationsService, useValue: SubmissionJsonPatchOperationsServiceStub }, - { provide: 'sectionDataProvider', useValue: sectionData }, - { provide: 'submissionIdProvider', useValue: '1508' }, - ] - }) - .compileComponents(); - }); - - beforeEach(inject([Store], (store: Store) => { - fixture = TestBed.createComponent(SubmissionSectionAccessesComponent); - component = fixture.componentInstance; - formService = TestBed.inject(FormService); - formService.validateAllFormFields.and.callFake(() => null); - formService.isValid.and.returnValue(observableOf(true)); - formService.getFormData.and.returnValue(observableOf(mockAccessesFormData)); - fixture.detectChanges(); - })); - - - it('should have formModel length should be 1', () => { - expect(component.formModel.length).toEqual(1); - }); - - it('formModel should have only 1 model type array', () => { - expect(component.formModel[0] instanceof DynamicFormArrayModel).toBeTrue(); - }); - - }); }); From f9d55dc3e8130db99926e34bf3852a1857f3a0e9 Mon Sep 17 00:00:00 2001 From: Giuseppe Digilio Date: Wed, 27 Apr 2022 17:19:38 +0200 Subject: [PATCH 06/28] [CST-5270] Refactoring implementation and remove mock response --- ...spaceitem-section-sherpa-policies.model.ts | 2 +- .../section-sherpa-policies.service.mock.ts | 17 +++----- src/app/submission/sections/sections-type.ts | 2 +- .../content-accordion.component.spec.ts | 7 ++-- .../content-accordion.component.ts | 3 +- .../metadata-information.component.spec.ts | 7 ++-- .../metadata-information.component.ts | 3 +- .../publication-information.component.spec.ts | 6 +-- .../publication-information.component.ts | 5 ++- .../publisher-policy.component.spec.ts | 11 +++-- .../publisher-policy.component.ts | 5 ++- .../section-sherpa-policies.component.html | 13 +++--- .../section-sherpa-policies.component.spec.ts | 22 ++++------ .../section-sherpa-policies.component.ts | 35 ++++++++++------ .../section-sherpa-policies.service.ts | 42 ------------------- src/app/submission/submission.module.ts | 36 +++++++++++----- src/assets/i18n/en.json5 | 6 ++- 17 files changed, 100 insertions(+), 122 deletions(-) delete mode 100644 src/app/submission/sections/sherpa-policies/section-sherpa-policies.service.ts diff --git a/src/app/core/submission/models/workspaceitem-section-sherpa-policies.model.ts b/src/app/core/submission/models/workspaceitem-section-sherpa-policies.model.ts index cbef185090..c57beadbb9 100644 --- a/src/app/core/submission/models/workspaceitem-section-sherpa-policies.model.ts +++ b/src/app/core/submission/models/workspaceitem-section-sherpa-policies.model.ts @@ -18,5 +18,5 @@ export interface WorkspaceitemSectionSherpaPoliciesObject { /** * The sherpa policies details */ - sherpaResponse: SherpaPoliciesDetailsObject[]; + sherpaResponse: SherpaPoliciesDetailsObject; } diff --git a/src/app/shared/mocks/section-sherpa-policies.service.mock.ts b/src/app/shared/mocks/section-sherpa-policies.service.mock.ts index 895e518d96..b4947ea5b4 100644 --- a/src/app/shared/mocks/section-sherpa-policies.service.mock.ts +++ b/src/app/shared/mocks/section-sherpa-policies.service.mock.ts @@ -1,11 +1,11 @@ -import { WorkspaceitemSectionSherpaPoliciesObject } from './../../core/submission/models/workspaceitem-section-sherpa-policies.model'; -import { SubmissionFormsModel } from '../../core/config/models/config-submission-forms.model'; -import { of as observableOf } from 'rxjs'; +import { + WorkspaceitemSectionSherpaPoliciesObject +} from '../../core/submission/models/workspaceitem-section-sherpa-policies.model'; -export const dataRes = { +export const SherpaDataResponse = { 'id': 'sherpaPolicies', 'retrievalTime': '2022-04-20T09:44:39.870+00:00', - 'sherpaResponse': [ + 'sherpaResponse': { 'error': false, 'message': null, @@ -98,11 +98,4 @@ export const dataRes = { 'inDOAJ': false }] } - ] } as WorkspaceitemSectionSherpaPoliciesObject; - -export function getSherpaPoliciesData() { - return jasmine.createSpyObj('SectionAccessesService', { - getSherpaPoliciesData: observableOf(dataRes), - }); -} diff --git a/src/app/submission/sections/sections-type.ts b/src/app/submission/sections/sections-type.ts index f998ef4554..6b6f839b7c 100644 --- a/src/app/submission/sections/sections-type.ts +++ b/src/app/submission/sections/sections-type.ts @@ -6,5 +6,5 @@ export enum SectionsType { CcLicense = 'cclicense', collection = 'collection', AccessesCondition = 'accessCondition', - SherpaPolicies = 'sherpaPolicies', + SherpaPolicies = 'sherpaPolicy', } diff --git a/src/app/submission/sections/sherpa-policies/content-accordion/content-accordion.component.spec.ts b/src/app/submission/sections/sherpa-policies/content-accordion/content-accordion.component.spec.ts index ec1180a6c9..382450fbd3 100644 --- a/src/app/submission/sections/sherpa-policies/content-accordion/content-accordion.component.spec.ts +++ b/src/app/submission/sections/sherpa-policies/content-accordion/content-accordion.component.spec.ts @@ -1,12 +1,13 @@ import { NgbAccordionModule } from '@ng-bootstrap/ng-bootstrap'; -import { TranslateLoaderMock } from './../../../../shared/testing/translate-loader.mock'; +import { TranslateLoaderMock } from '../../../../shared/mocks/translate-loader.mock'; import { ComponentFixture, TestBed } from '@angular/core/testing'; import { ContentAccordionComponent } from './content-accordion.component'; -import { dataRes } from './../../../../shared/mocks/section-sherpa-policies.service.mock'; + import { DebugElement } from '@angular/core'; import { By } from '@angular/platform-browser'; import { TranslateLoader, TranslateModule } from '@ngx-translate/core'; +import { SherpaDataResponse } from '../../../../shared/mocks/section-sherpa-policies.service.mock'; describe('ContentAccordionComponent', () => { let component: ContentAccordionComponent; @@ -33,7 +34,7 @@ describe('ContentAccordionComponent', () => { fixture = TestBed.createComponent(ContentAccordionComponent); component = fixture.componentInstance; de = fixture.debugElement; - component.version = dataRes.sherpaResponse[0].journals[0].policies[0].permittedVersions[0]; + component.version = SherpaDataResponse.sherpaResponse.journals[0].policies[0].permittedVersions[0]; fixture.detectChanges(); }); diff --git a/src/app/submission/sections/sherpa-policies/content-accordion/content-accordion.component.ts b/src/app/submission/sections/sherpa-policies/content-accordion/content-accordion.component.ts index 378f08c8bc..a2decc38e1 100644 --- a/src/app/submission/sections/sherpa-policies/content-accordion/content-accordion.component.ts +++ b/src/app/submission/sections/sherpa-policies/content-accordion/content-accordion.component.ts @@ -1,6 +1,7 @@ -import { PermittedVersions } from './../../../../core/submission/models/sherpa-policies-details.model'; import { Component, Input } from '@angular/core'; +import { PermittedVersions } from '../../../../core/submission/models/sherpa-policies-details.model'; + @Component({ selector: 'ds-content-accordion', templateUrl: './content-accordion.component.html', diff --git a/src/app/submission/sections/sherpa-policies/metadata-information/metadata-information.component.spec.ts b/src/app/submission/sections/sherpa-policies/metadata-information/metadata-information.component.spec.ts index b329fb1821..9a60a6d010 100644 --- a/src/app/submission/sections/sherpa-policies/metadata-information/metadata-information.component.spec.ts +++ b/src/app/submission/sections/sherpa-policies/metadata-information/metadata-information.component.spec.ts @@ -1,11 +1,12 @@ -import { TranslateLoaderMock } from './../../../../shared/testing/translate-loader.mock'; +import { TranslateLoaderMock } from '../../../../shared/testing/translate-loader.mock'; import { ComponentFixture, TestBed } from '@angular/core/testing'; import { MetadataInformationComponent } from './metadata-information.component'; -import { dataRes } from './../../../../shared/mocks/section-sherpa-policies.service.mock'; + import { DebugElement } from '@angular/core'; import { By } from '@angular/platform-browser'; import { TranslateLoader, TranslateModule } from '@ngx-translate/core'; +import { SherpaDataResponse } from '../../../../shared/mocks/section-sherpa-policies.service.mock'; describe('MetadataInformationComponent', () => { let component: MetadataInformationComponent; @@ -31,7 +32,7 @@ describe('MetadataInformationComponent', () => { fixture = TestBed.createComponent(MetadataInformationComponent); component = fixture.componentInstance; de = fixture.debugElement; - component.metadata = dataRes.sherpaResponse[0].metadata; + component.metadata = SherpaDataResponse.sherpaResponse.metadata; fixture.detectChanges(); }); diff --git a/src/app/submission/sections/sherpa-policies/metadata-information/metadata-information.component.ts b/src/app/submission/sections/sherpa-policies/metadata-information/metadata-information.component.ts index 8b85237762..cced669024 100644 --- a/src/app/submission/sections/sherpa-policies/metadata-information/metadata-information.component.ts +++ b/src/app/submission/sections/sherpa-policies/metadata-information/metadata-information.component.ts @@ -1,5 +1,6 @@ import { Component, Input } from '@angular/core'; -import { Metadata } from './../../../../core/submission/models/sherpa-policies-details.model'; + +import { Metadata } from '../../../../core/submission/models/sherpa-policies-details.model'; @Component({ selector: 'ds-metadata-information', diff --git a/src/app/submission/sections/sherpa-policies/publication-information/publication-information.component.spec.ts b/src/app/submission/sections/sherpa-policies/publication-information/publication-information.component.spec.ts index e1acc016ab..c5dc896858 100644 --- a/src/app/submission/sections/sherpa-policies/publication-information/publication-information.component.spec.ts +++ b/src/app/submission/sections/sherpa-policies/publication-information/publication-information.component.spec.ts @@ -1,11 +1,11 @@ -import { TranslateLoaderMock } from './../../../../shared/testing/translate-loader.mock'; +import { TranslateLoaderMock } from '../../../../shared/testing/translate-loader.mock'; import { ComponentFixture, TestBed } from '@angular/core/testing'; import { PublicationInformationComponent } from './publication-information.component'; -import { dataRes } from './../../../../shared/mocks/section-sherpa-policies.service.mock'; import { DebugElement } from '@angular/core'; import { By } from '@angular/platform-browser'; import { TranslateLoader, TranslateModule } from '@ngx-translate/core'; +import { SherpaDataResponse } from '../../../../shared/mocks/section-sherpa-policies.service.mock'; describe('PublicationInformationComponent', () => { let component: PublicationInformationComponent; @@ -32,7 +32,7 @@ describe('PublicationInformationComponent', () => { fixture = TestBed.createComponent(PublicationInformationComponent); component = fixture.componentInstance; de = fixture.debugElement; - component.journal = dataRes.sherpaResponse[0].journals[0]; + component.journal = SherpaDataResponse.sherpaResponse.journals[0]; fixture.detectChanges(); }); diff --git a/src/app/submission/sections/sherpa-policies/publication-information/publication-information.component.ts b/src/app/submission/sections/sherpa-policies/publication-information/publication-information.component.ts index a5306406af..54973eba02 100644 --- a/src/app/submission/sections/sherpa-policies/publication-information/publication-information.component.ts +++ b/src/app/submission/sections/sherpa-policies/publication-information/publication-information.component.ts @@ -1,5 +1,6 @@ -import { Component, Input, OnInit } from '@angular/core'; -import { Journal } from './../../../../core/submission/models/sherpa-policies-details.model'; +import { Component, Input } from '@angular/core'; + +import { Journal } from '../../../../core/submission/models/sherpa-policies-details.model'; @Component({ selector: 'ds-publication-information', diff --git a/src/app/submission/sections/sherpa-policies/publisher-policy/publisher-policy.component.spec.ts b/src/app/submission/sections/sherpa-policies/publisher-policy/publisher-policy.component.spec.ts index 9ba77adf94..da97f824b1 100644 --- a/src/app/submission/sections/sherpa-policies/publisher-policy/publisher-policy.component.spec.ts +++ b/src/app/submission/sections/sherpa-policies/publisher-policy/publisher-policy.component.spec.ts @@ -1,12 +1,11 @@ -import { TranslateLoaderMock } from './../../../../shared/testing/translate-loader.mock'; import { ComponentFixture, TestBed } from '@angular/core/testing'; - import { PublisherPolicyComponent } from './publisher-policy.component'; -import { dataRes } from './../../../../shared/mocks/section-sherpa-policies.service.mock'; import { By } from '@angular/platform-browser'; import { DebugElement } from '@angular/core'; -import { TranslateLoader, TranslateModule, TranslateService } from '@ngx-translate/core'; -import { getMockTranslateService } from '../../../../shared/mocks/translate.service.mock'; +import { TranslateLoader, TranslateModule } from '@ngx-translate/core'; + +import { SherpaDataResponse } from '../../../../shared/mocks/section-sherpa-policies.service.mock'; +import { TranslateLoaderMock } from '../../../../shared/mocks/translate-loader.mock'; describe('PublisherPolicyComponent', () => { let component: PublisherPolicyComponent; @@ -32,7 +31,7 @@ describe('PublisherPolicyComponent', () => { fixture = TestBed.createComponent(PublisherPolicyComponent); component = fixture.componentInstance; de = fixture.debugElement; - component.policy = dataRes.sherpaResponse[0].journals[0].policies[0]; + component.policy = SherpaDataResponse.sherpaResponse.journals[0].policies[0]; fixture.detectChanges(); }); diff --git a/src/app/submission/sections/sherpa-policies/publisher-policy/publisher-policy.component.ts b/src/app/submission/sections/sherpa-policies/publisher-policy/publisher-policy.component.ts index dcbc115ddd..639361beb0 100644 --- a/src/app/submission/sections/sherpa-policies/publisher-policy/publisher-policy.component.ts +++ b/src/app/submission/sections/sherpa-policies/publisher-policy/publisher-policy.component.ts @@ -1,5 +1,6 @@ -import { Policy } from './../../../../core/submission/models/sherpa-policies-details.model'; -import { Component, Input, OnInit } from '@angular/core'; +import { Component, Input } from '@angular/core'; + +import { Policy } from '../../../../core/submission/models/sherpa-policies-details.model'; @Component({ selector: 'ds-publisher-policy', diff --git a/src/app/submission/sections/sherpa-policies/section-sherpa-policies.component.html b/src/app/submission/sections/sherpa-policies/section-sherpa-policies.component.html index 6756793fd5..94553dd4c3 100644 --- a/src/app/submission/sections/sherpa-policies/section-sherpa-policies.component.html +++ b/src/app/submission/sections/sherpa-policies/section-sherpa-policies.component.html @@ -1,10 +1,13 @@ + + +
- + @@ -38,11 +41,11 @@
- +
- - + +
{{'submission.sections.sherpa.record.information' | translate}} @@ -51,4 +54,4 @@
-
\ No newline at end of file + diff --git a/src/app/submission/sections/sherpa-policies/section-sherpa-policies.component.spec.ts b/src/app/submission/sections/sherpa-policies/section-sherpa-policies.component.spec.ts index ce64406486..fb8f8ba355 100644 --- a/src/app/submission/sections/sherpa-policies/section-sherpa-policies.component.spec.ts +++ b/src/app/submission/sections/sherpa-policies/section-sherpa-policies.component.spec.ts @@ -1,25 +1,21 @@ import { NgbAccordionModule } from '@ng-bootstrap/ng-bootstrap'; -import { SubmissionServiceStub } from './../../../shared/testing/submission-service.stub'; -import { dataRes, getSherpaPoliciesData } from './../../../shared/mocks/section-sherpa-policies.service.mock'; +import { SubmissionServiceStub } from '../../../shared/testing/submission-service.stub'; +import { SherpaDataResponse } from '../../../shared/mocks/section-sherpa-policies.service.mock'; import { ComponentFixture, inject, TestBed } from '@angular/core/testing'; import { SectionsService } from '../sections.service'; import { SectionsServiceStub } from '../../../shared/testing/sections-service.stub'; - -import { FormBuilderService } from '../../../shared/form/builder/form-builder.service'; -import { getMockFormBuilderService } from '../../../shared/mocks/form-builder-service.mock'; import { JsonPatchOperationsBuilder } from '../../../core/json-patch/builder/json-patch-operations-builder'; -import { TranslateLoader, TranslateModule, TranslateService } from '@ngx-translate/core'; -import { getMockTranslateService } from '../../../shared/mocks/translate.service.mock'; +import { TranslateLoader, TranslateModule } from '@ngx-translate/core'; import { BrowserModule, By } from '@angular/platform-browser'; import { Store } from '@ngrx/store'; import { AppState } from '../../../app.reducer'; -import { SectionSherpaPoliciesService } from './section-sherpa-policies.service'; import { SubmissionSectionSherpaPoliciesComponent } from './section-sherpa-policies.component'; import { SubmissionService } from '../../submission.service'; import { DebugElement } from '@angular/core'; -import { TranslateLoaderMock } from 'src/app/shared/mocks/translate-loader.mock'; +import { TranslateLoaderMock } from '../../../shared/mocks/translate-loader.mock'; +import { of as observableOf } from 'rxjs'; describe('SubmissionSectionSherpaPoliciesComponent', () => { let component: SubmissionSectionSherpaPoliciesComponent; @@ -27,10 +23,6 @@ describe('SubmissionSectionSherpaPoliciesComponent', () => { let de: DebugElement; const sectionsServiceStub = new SectionsServiceStub(); - // const pathCombiner = new JsonPatchOperationPathCombiner('sections', sectionId, 'files', fileIndex); - - const builderService: FormBuilderService = getMockFormBuilderService(); - const sectionSherpaPoliciesService = getSherpaPoliciesData(); const operationsBuilder = jasmine.createSpyObj('operationsBuilder', { add: undefined, @@ -47,7 +39,7 @@ describe('SubmissionSectionSherpaPoliciesComponent', () => { sectionType: 'sherpaPolicies', collapsed: false, enabled: true, - data: dataRes, + data: SherpaDataResponse, errorsToShow: [], serverValidationErrors: [], isLoading: false, @@ -71,7 +63,6 @@ describe('SubmissionSectionSherpaPoliciesComponent', () => { declarations: [SubmissionSectionSherpaPoliciesComponent], providers: [ { provide: SectionsService, useValue: sectionsServiceStub }, - { provide: SectionSherpaPoliciesService, useValue: sectionSherpaPoliciesService }, { provide: JsonPatchOperationsBuilder, useValue: operationsBuilder }, { provide: SubmissionService, useValue: SubmissionServiceStub }, { provide: Store, useValue: storeStub }, @@ -86,6 +77,7 @@ describe('SubmissionSectionSherpaPoliciesComponent', () => { fixture = TestBed.createComponent(SubmissionSectionSherpaPoliciesComponent); component = fixture.componentInstance; de = fixture.debugElement; + sectionsServiceStub.getSectionData.and.returnValue(observableOf(SherpaDataResponse)) fixture.detectChanges(); })); diff --git a/src/app/submission/sections/sherpa-policies/section-sherpa-policies.component.ts b/src/app/submission/sections/sherpa-policies/section-sherpa-policies.component.ts index f5eaaa773a..d287a182ba 100644 --- a/src/app/submission/sections/sherpa-policies/section-sherpa-policies.component.ts +++ b/src/app/submission/sections/sherpa-policies/section-sherpa-policies.component.ts @@ -1,18 +1,19 @@ -import { JsonPatchOperationPathCombiner } from './../../../core/json-patch/builder/json-patch-operation-path-combiner'; -import { JsonPatchOperationsBuilder } from './../../../core/json-patch/builder/json-patch-operations-builder'; -import { WorkspaceitemSectionSherpaPoliciesObject } from './../../../core/submission/models/workspaceitem-section-sherpa-policies.model'; -import { SectionSherpaPoliciesService } from './section-sherpa-policies.service'; -import { Component, Inject, ViewChildren, QueryList } from '@angular/core'; +import { Component, Inject, QueryList, ViewChildren } from '@angular/core'; -import { Observable, of, Subscription } from 'rxjs'; +import { BehaviorSubject, Observable, of, Subscription } from 'rxjs'; +import { JsonPatchOperationPathCombiner } from '../../../core/json-patch/builder/json-patch-operation-path-combiner'; +import { JsonPatchOperationsBuilder } from '../../../core/json-patch/builder/json-patch-operations-builder'; +import { + WorkspaceitemSectionSherpaPoliciesObject +} from '../../../core/submission/models/workspaceitem-section-sherpa-policies.model'; import { renderSectionFor } from '../sections-decorator'; import { SectionsType } from '../sections-type'; import { SectionDataObject } from '../models/section-data.model'; import { SectionsService } from '../sections.service'; import { SectionModelComponent } from '../models/section.model'; import { SubmissionService } from '../../submission.service'; -import { hasValue } from '../../../shared/empty.util'; +import { hasValue, isEmpty } from '../../../shared/empty.util'; /** * This component represents a section for managing item's access conditions. @@ -31,7 +32,7 @@ export class SubmissionSectionSherpaPoliciesComponent extends SectionModelCompon * The accesses section data * @type {WorkspaceitemSectionAccessesObject} */ - public sherpaPoliciesData: WorkspaceitemSectionSherpaPoliciesObject; + public sherpaPoliciesData$: BehaviorSubject = new BehaviorSubject(null); /** * The [[JsonPatchOperationPathCombiner]] object @@ -50,14 +51,12 @@ export class SubmissionSectionSherpaPoliciesComponent extends SectionModelCompon * * @param {SectionsService} sectionService * @param {SectionDataObject} injectedSectionData - * @param {SectionSherpaPoliciesService} sectionSherpaPoliciesService * @param {JsonPatchOperationsBuilder} operationsBuilder * @param {SubmissionService} submissionService * @param {string} injectedSubmissionId */ constructor( protected sectionService: SectionsService, - private sectionSherpaPoliciesService: SectionSherpaPoliciesService, protected operationsBuilder: JsonPatchOperationsBuilder, private submissionService: SubmissionService, @Inject('sectionDataProvider') public injectedSectionData: SectionDataObject, @@ -88,11 +87,14 @@ export class SubmissionSectionSherpaPoliciesComponent extends SectionModelCompon * Initialize all instance variables and retrieve collection default access conditions */ protected onSectionInit(): void { + this.pathCombiner = new JsonPatchOperationPathCombiner('sections', this.sectionData.id); this.subs.push( - this.sectionSherpaPoliciesService.getSherpaPoliciesData(this.submissionId, this.sectionData.id).subscribe((sherpaPolicies: WorkspaceitemSectionSherpaPoliciesObject) => { - this.sherpaPoliciesData = sherpaPolicies; - }) + this.sectionService.getSectionData(this.submissionId, this.sectionData.id, this.sectionData.sectionType) + .subscribe((sherpaPolicies: WorkspaceitemSectionSherpaPoliciesObject) => { + this.sherpaPoliciesData$.next(sherpaPolicies); + console.log(this.sherpaPoliciesData$.value) + }) ); } @@ -106,6 +108,13 @@ export class SubmissionSectionSherpaPoliciesComponent extends SectionModelCompon return of(true); } + /** + * Check if section has no data + */ + hasNoData(): boolean { + return isEmpty(this.sherpaPoliciesData$.value); + } + /** * Refresh sherpa information */ diff --git a/src/app/submission/sections/sherpa-policies/section-sherpa-policies.service.ts b/src/app/submission/sections/sherpa-policies/section-sherpa-policies.service.ts deleted file mode 100644 index 4ddf4509cb..0000000000 --- a/src/app/submission/sections/sherpa-policies/section-sherpa-policies.service.ts +++ /dev/null @@ -1,42 +0,0 @@ -import { WorkspaceitemSectionSherpaPoliciesObject } from './../../../core/submission/models/workspaceitem-section-sherpa-policies.model'; -import { Injectable } from '@angular/core'; - -import { Observable } from 'rxjs'; -import { distinctUntilChanged, filter } from 'rxjs/operators'; -import { Store } from '@ngrx/store'; - -import { SubmissionState } from '../../submission.reducers'; -import { isNotUndefined } from '../../../shared/empty.util'; -import { submissionSectionDataFromIdSelector } from '../../selectors'; - -/** - * A service that provides methods to handle submission item's sherpa policies state. - */ -@Injectable() -export class SectionSherpaPoliciesService { - - /** - * Initialize service variables - * - * @param {Store} store - */ - constructor(private store: Store) { } - - - /** - * Return item's sherpa policies state. - * - * @param submissionId - * The submission id - * @param sectionId - * The section id - * @returns {Observable} - * Emits bitstream's metadata - */ - public getSherpaPoliciesData(submissionId: string, sectionId: string): Observable { - - return this.store.select(submissionSectionDataFromIdSelector(submissionId, sectionId)).pipe( - filter((state) => isNotUndefined(state)), - distinctUntilChanged()); - } -} diff --git a/src/app/submission/submission.module.ts b/src/app/submission/submission.module.ts index 85b8067d0e..b0b6d5195d 100644 --- a/src/app/submission/submission.module.ts +++ b/src/app/submission/submission.module.ts @@ -1,4 +1,3 @@ -import { SectionSherpaPoliciesService } from './sections/sherpa-policies/section-sherpa-policies.service'; import { NgModule } from '@angular/core'; import { CoreModule } from '../core/core.module'; import { SharedModule } from '../shared/shared.module'; @@ -23,15 +22,27 @@ import { SubmissionSectionLicenseComponent } from './sections/license/section-li import { SubmissionUploadsConfigService } from '../core/config/submission-uploads-config.service'; import { SubmissionEditComponent } from './edit/submission-edit.component'; import { SubmissionSectionUploadFileComponent } from './sections/upload/file/section-upload-file.component'; -import { SubmissionSectionUploadFileEditComponent } from './sections/upload/file/edit/section-upload-file-edit.component'; -import { SubmissionSectionUploadFileViewComponent } from './sections/upload/file/view/section-upload-file-view.component'; -import { SubmissionSectionUploadAccessConditionsComponent } from './sections/upload/accessConditions/submission-section-upload-access-conditions.component'; +import { + SubmissionSectionUploadFileEditComponent +} from './sections/upload/file/edit/section-upload-file-edit.component'; +import { + SubmissionSectionUploadFileViewComponent +} from './sections/upload/file/view/section-upload-file-view.component'; +import { + SubmissionSectionUploadAccessConditionsComponent +} from './sections/upload/accessConditions/submission-section-upload-access-conditions.component'; import { SubmissionSubmitComponent } from './submit/submission-submit.component'; import { storeModuleConfig } from '../app.reducer'; import { SubmissionImportExternalComponent } from './import-external/submission-import-external.component'; -import { SubmissionImportExternalSearchbarComponent } from './import-external/import-external-searchbar/submission-import-external-searchbar.component'; -import { SubmissionImportExternalPreviewComponent } from './import-external/import-external-preview/submission-import-external-preview.component'; -import { SubmissionImportExternalCollectionComponent } from './import-external/import-external-collection/submission-import-external-collection.component'; +import { + SubmissionImportExternalSearchbarComponent +} from './import-external/import-external-searchbar/submission-import-external-searchbar.component'; +import { + SubmissionImportExternalPreviewComponent +} from './import-external/import-external-preview/submission-import-external-preview.component'; +import { + SubmissionImportExternalCollectionComponent +} from './import-external/import-external-collection/submission-import-external-collection.component'; import { SubmissionSectionCcLicensesComponent } from './sections/cc-license/submission-section-cc-licenses.component'; import { JournalEntitiesModule } from '../entity-groups/journal-entities/journal-entities.module'; import { ResearchEntitiesModule } from '../entity-groups/research-entities/research-entities.module'; @@ -46,8 +57,12 @@ import { SectionAccessesService } from './sections/accesses/section-accesses.ser import { SubmissionSectionSherpaPoliciesComponent } from './sections/sherpa-policies/section-sherpa-policies.component'; import { ContentAccordionComponent } from './sections/sherpa-policies/content-accordion/content-accordion.component'; import { PublisherPolicyComponent } from './sections/sherpa-policies/publisher-policy/publisher-policy.component'; -import { PublicationInformationComponent } from './sections/sherpa-policies/publication-information/publication-information.component'; -import { MetadataInformationComponent } from './sections/sherpa-policies/metadata-information/metadata-information.component'; +import { + PublicationInformationComponent +} from './sections/sherpa-policies/publication-information/publication-information.component'; +import { + MetadataInformationComponent +} from './sections/sherpa-policies/metadata-information/metadata-information.component'; const ENTRY_COMPONENTS = [ // put only entry components that use custom decorator @@ -108,8 +123,7 @@ const DECLARATIONS = [ SectionsService, SubmissionUploadsConfigService, SubmissionAccessesConfigService, - SectionAccessesService, - SectionSherpaPoliciesService + SectionAccessesService ] }) diff --git a/src/assets/i18n/en.json5 b/src/assets/i18n/en.json5 index ec9bc5b3a0..d9f6523ed4 100644 --- a/src/assets/i18n/en.json5 +++ b/src/assets/i18n/en.json5 @@ -3874,10 +3874,14 @@ "submission.sections.submit.progressbar.license": "Deposit license", + "submission.sections.submit.progressbar.sherpapolicy": "Sherpa policies", + "submission.sections.submit.progressbar.upload": "Upload files", + "submission.sections.sherpa-policy.title-empty": "No information available", + "submission.sections.status.errors.title": "Errors", "submission.sections.status.valid.title": "Valid", @@ -3990,7 +3994,7 @@ "submission.sections.sherpa.publication.information": "Publication information", - + "submission.sections.sherpa.publication.information.title": "Title", "submission.sections.sherpa.publication.information.issns": "ISSNs", From e307c5de9fdb57809b30427237e0d24b63eb4026 Mon Sep 17 00:00:00 2001 From: Giuseppe Digilio Date: Wed, 27 Apr 2022 17:20:26 +0200 Subject: [PATCH 07/28] [CST-5270] add string type to attribute declaration --- src/app/shared/alert/alert.component.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/app/shared/alert/alert.component.ts b/src/app/shared/alert/alert.component.ts index 93535d2057..0fcce39d38 100644 --- a/src/app/shared/alert/alert.component.ts +++ b/src/app/shared/alert/alert.component.ts @@ -33,7 +33,7 @@ export class AlertComponent { /** * The alert type */ - @Input() type: AlertType; + @Input() type: AlertType|string; /** * An event fired when alert is dismissed. From a754a20ec6d7ca96a4b93421cf333dbdcb002ffa Mon Sep 17 00:00:00 2001 From: Rezart Vata Date: Thu, 28 Apr 2022 18:12:15 +0200 Subject: [PATCH 08/28] [CST-5270] Fixing ISSN removal and unit testing --- .../objects/submission-objects.effects.ts | 67 ++++++++------- .../section-sherpa-policies.component.html | 81 ++++++++++--------- .../section-sherpa-policies.component.spec.ts | 9 ++- .../section-sherpa-policies.component.ts | 24 ++++-- 4 files changed, 103 insertions(+), 78 deletions(-) diff --git a/src/app/submission/objects/submission-objects.effects.ts b/src/app/submission/objects/submission-objects.effects.ts index e79670306f..0c5f3fb61b 100644 --- a/src/app/submission/objects/submission-objects.effects.ts +++ b/src/app/submission/objects/submission-objects.effects.ts @@ -2,7 +2,7 @@ import { Injectable } from '@angular/core'; import { Actions, createEffect, ofType } from '@ngrx/effects'; import { Store } from '@ngrx/store'; import { TranslateService } from '@ngx-translate/core'; -import { isEqual, union } from 'lodash'; +import { isEqual, isUndefined, union } from 'lodash'; import { from as observableFrom, Observable, of as observableOf } from 'rxjs'; import { catchError, filter, map, mergeMap, switchMap, take, tap, withLatestFrom } from 'rxjs/operators'; @@ -43,7 +43,7 @@ import { UpdateSectionDataAction, UpdateSectionDataSuccessAction } from './submission-objects.actions'; -import { SubmissionObjectEntry} from './submission-objects.reducer'; +import { SubmissionObjectEntry } from './submission-objects.reducer'; import { Item } from '../../core/shared/item.model'; import { RemoteData } from '../../core/data/remote-data'; import { getFirstSucceededRemoteDataPayload } from '../../core/shared/operators'; @@ -60,7 +60,7 @@ export class SubmissionObjectEffects { /** * Dispatch a [InitSectionAction] for every submission sections and dispatch a [CompleteInitSubmissionFormAction] */ - loadForm$ = createEffect(() => this.actions$.pipe( + loadForm$ = createEffect(() => this.actions$.pipe( ofType(SubmissionObjectActionTypes.INIT_SUBMISSION_FORM), map((action: InitSubmissionFormAction) => { const definition = action.payload.submissionDefinition; @@ -104,7 +104,7 @@ export class SubmissionObjectEffects { /** * Dispatch a [InitSubmissionFormAction] */ - resetForm$ = createEffect(() => this.actions$.pipe( + resetForm$ = createEffect(() => this.actions$.pipe( ofType(SubmissionObjectActionTypes.RESET_SUBMISSION_FORM), map((action: ResetSubmissionFormAction) => new InitSubmissionFormAction( @@ -120,35 +120,35 @@ export class SubmissionObjectEffects { /** * Dispatch a [SaveSubmissionFormSuccessAction] or a [SaveSubmissionFormErrorAction] on error */ - saveSubmission$ = createEffect(() => this.actions$.pipe( + saveSubmission$ = createEffect(() => this.actions$.pipe( ofType(SubmissionObjectActionTypes.SAVE_SUBMISSION_FORM), switchMap((action: SaveSubmissionFormAction) => { return this.operationsService.jsonPatchByResourceType( this.submissionService.getSubmissionObjectLinkName(), action.payload.submissionId, 'sections').pipe( - map((response: SubmissionObject[]) => new SaveSubmissionFormSuccessAction(action.payload.submissionId, response, action.payload.isManual, action.payload.isManual)), - catchError(() => observableOf(new SaveSubmissionFormErrorAction(action.payload.submissionId)))); + map((response: SubmissionObject[]) => new SaveSubmissionFormSuccessAction(action.payload.submissionId, response, action.payload.isManual, action.payload.isManual)), + catchError(() => observableOf(new SaveSubmissionFormErrorAction(action.payload.submissionId)))); }))); /** * Dispatch a [SaveForLaterSubmissionFormSuccessAction] or a [SaveSubmissionFormErrorAction] on error */ - saveForLaterSubmission$ = createEffect(() => this.actions$.pipe( + saveForLaterSubmission$ = createEffect(() => this.actions$.pipe( ofType(SubmissionObjectActionTypes.SAVE_FOR_LATER_SUBMISSION_FORM), switchMap((action: SaveForLaterSubmissionFormAction) => { return this.operationsService.jsonPatchByResourceType( this.submissionService.getSubmissionObjectLinkName(), action.payload.submissionId, 'sections').pipe( - map((response: SubmissionObject[]) => new SaveForLaterSubmissionFormSuccessAction(action.payload.submissionId, response)), - catchError(() => observableOf(new SaveSubmissionFormErrorAction(action.payload.submissionId)))); + map((response: SubmissionObject[]) => new SaveForLaterSubmissionFormSuccessAction(action.payload.submissionId, response)), + catchError(() => observableOf(new SaveSubmissionFormErrorAction(action.payload.submissionId)))); }))); /** * Call parseSaveResponse and dispatch actions */ - saveSubmissionSuccess$ = createEffect(() => this.actions$.pipe( + saveSubmissionSuccess$ = createEffect(() => this.actions$.pipe( ofType(SubmissionObjectActionTypes.SAVE_SUBMISSION_FORM_SUCCESS), withLatestFrom(this.store$), map(([action, currentState]: [SaveSubmissionFormSuccessAction, any]) => { @@ -162,7 +162,7 @@ export class SubmissionObjectEffects { * Call parseSaveResponse and dispatch actions. * Notification system is forced to be disabled. */ - saveSubmissionSectionSuccess$ = createEffect(() => this.actions$.pipe( + saveSubmissionSectionSuccess$ = createEffect(() => this.actions$.pipe( ofType(SubmissionObjectActionTypes.SAVE_SUBMISSION_SECTION_FORM_SUCCESS), withLatestFrom(this.store$), map(([action, currentState]: [SaveSubmissionSectionFormSuccessAction, any]) => { @@ -174,7 +174,7 @@ export class SubmissionObjectEffects { /** * Dispatch a [SaveSubmissionSectionFormSuccessAction] or a [SaveSubmissionSectionFormErrorAction] on error */ - saveSection$ = createEffect(() => this.actions$.pipe( + saveSection$ = createEffect(() => this.actions$.pipe( ofType(SubmissionObjectActionTypes.SAVE_SUBMISSION_SECTION_FORM), switchMap((action: SaveSubmissionSectionFormAction) => { return this.operationsService.jsonPatchByResourceID( @@ -182,14 +182,14 @@ export class SubmissionObjectEffects { action.payload.submissionId, 'sections', action.payload.sectionId).pipe( - map((response: SubmissionObject[]) => new SaveSubmissionSectionFormSuccessAction(action.payload.submissionId, response)), - catchError(() => observableOf(new SaveSubmissionSectionFormErrorAction(action.payload.submissionId)))); + map((response: SubmissionObject[]) => new SaveSubmissionSectionFormSuccessAction(action.payload.submissionId, response)), + catchError(() => observableOf(new SaveSubmissionSectionFormErrorAction(action.payload.submissionId)))); }))); /** * Show a notification on error */ - saveError$ = createEffect(() => this.actions$.pipe( + saveError$ = createEffect(() => this.actions$.pipe( ofType(SubmissionObjectActionTypes.SAVE_SUBMISSION_FORM_ERROR, SubmissionObjectActionTypes.SAVE_SUBMISSION_SECTION_FORM_ERROR), withLatestFrom(this.store$), tap(() => this.notificationsService.error(null, this.translate.get('submission.sections.general.save_error_notice')))), { dispatch: false }); @@ -197,7 +197,7 @@ export class SubmissionObjectEffects { /** * Call parseSaveResponse and dispatch actions or dispatch [SaveSubmissionFormErrorAction] on error */ - saveAndDeposit$ = createEffect(() => this.actions$.pipe( + saveAndDeposit$ = createEffect(() => this.actions$.pipe( ofType(SubmissionObjectActionTypes.SAVE_AND_DEPOSIT_SUBMISSION), withLatestFrom(this.submissionService.hasUnsavedModification()), switchMap(([action, hasUnsavedModification]: [SaveAndDepositSubmissionAction, boolean]) => { @@ -233,7 +233,7 @@ export class SubmissionObjectEffects { /** * Dispatch a [DepositSubmissionSuccessAction] or a [DepositSubmissionErrorAction] on error */ - depositSubmission$ = createEffect(() => this.actions$.pipe( + depositSubmission$ = createEffect(() => this.actions$.pipe( ofType(SubmissionObjectActionTypes.DEPOSIT_SUBMISSION), withLatestFrom(this.store$), switchMap(([action, state]: [DepositSubmissionAction, any]) => { @@ -245,7 +245,7 @@ export class SubmissionObjectEffects { /** * Show a notification on success and redirect to MyDSpace page */ - saveForLaterSubmissionSuccess$ = createEffect(() => this.actions$.pipe( + saveForLaterSubmissionSuccess$ = createEffect(() => this.actions$.pipe( ofType(SubmissionObjectActionTypes.SAVE_FOR_LATER_SUBMISSION_FORM_SUCCESS), tap(() => this.notificationsService.success(null, this.translate.get('submission.sections.general.save_success_notice'))), tap(() => this.submissionService.redirectToMyDSpace())), { dispatch: false }); @@ -253,7 +253,7 @@ export class SubmissionObjectEffects { /** * Show a notification on success and redirect to MyDSpace page */ - depositSubmissionSuccess$ = createEffect(() => this.actions$.pipe( + depositSubmissionSuccess$ = createEffect(() => this.actions$.pipe( ofType(SubmissionObjectActionTypes.DEPOSIT_SUBMISSION_SUCCESS), tap(() => this.notificationsService.success(null, this.translate.get('submission.sections.general.deposit_success_notice'))), tap(() => this.submissionService.redirectToMyDSpace())), { dispatch: false }); @@ -261,14 +261,14 @@ export class SubmissionObjectEffects { /** * Show a notification on error */ - depositSubmissionError$ = createEffect(() => this.actions$.pipe( + depositSubmissionError$ = createEffect(() => this.actions$.pipe( ofType(SubmissionObjectActionTypes.DEPOSIT_SUBMISSION_ERROR), tap(() => this.notificationsService.error(null, this.translate.get('submission.sections.general.deposit_error_notice')))), { dispatch: false }); /** * Dispatch a [DiscardSubmissionSuccessAction] or a [DiscardSubmissionErrorAction] on error */ - discardSubmission$ = createEffect(() => this.actions$.pipe( + discardSubmission$ = createEffect(() => this.actions$.pipe( ofType(SubmissionObjectActionTypes.DISCARD_SUBMISSION), switchMap((action: DepositSubmissionAction) => { return this.submissionService.discardSubmission(action.payload.submissionId).pipe( @@ -279,7 +279,7 @@ export class SubmissionObjectEffects { /** * Adds all metadata an item to the SubmissionForm sections of the submission */ - addAllMetadataToSectionData = createEffect(() => this.actions$.pipe( + addAllMetadataToSectionData = createEffect(() => this.actions$.pipe( ofType(SubmissionObjectActionTypes.UPDATE_SECTION_DATA), switchMap((action: UpdateSectionDataAction) => { return this.sectionService.getSectionState(action.payload.submissionId, action.payload.sectionId, SectionsType.Upload) @@ -320,18 +320,18 @@ export class SubmissionObjectEffects { /** * Show a notification on error */ - discardSubmissionError$ = createEffect(() => this.actions$.pipe( + discardSubmissionError$ = createEffect(() => this.actions$.pipe( ofType(SubmissionObjectActionTypes.DISCARD_SUBMISSION_ERROR), tap(() => this.notificationsService.error(null, this.translate.get('submission.sections.general.discard_error_notice')))), { dispatch: false }); constructor(private actions$: Actions, - private notificationsService: NotificationsService, - private operationsService: SubmissionJsonPatchOperationsService, - private sectionService: SectionsService, - private store$: Store, - private submissionService: SubmissionService, - private submissionObjectService: SubmissionObjectDataService, - private translate: TranslateService) { + private notificationsService: NotificationsService, + private operationsService: SubmissionJsonPatchOperationsService, + private sectionService: SectionsService, + private store$: Store, + private submissionService: SubmissionService, + private submissionObjectService: SubmissionObjectDataService, + private translate: TranslateService) { } /** @@ -426,6 +426,11 @@ export class SubmissionObjectEffects { mappedActions.push(new UpdateSectionDataAction(submissionId, sectionId, sectionData, filteredErrors, sectionErrors)); } }); + let currentStateId = currentState.selfUrl.split('/')[currentState.selfUrl.split('/').length - 1]; + let currentResponseItem = response.find(item => item.id.toString() === currentStateId); + if (!isUndefined(currentState.sections.sherpaPolicies?.data) && isUndefined(currentResponseItem.sections.sherpaPolicies)) { + mappedActions.push(new UpdateSectionDataAction(submissionId, 'sherpaPolicies', null, [], [])); + } } return mappedActions; } diff --git a/src/app/submission/sections/sherpa-policies/section-sherpa-policies.component.html b/src/app/submission/sections/sherpa-policies/section-sherpa-policies.component.html index 94553dd4c3..b7b24ffcf0 100644 --- a/src/app/submission/sections/sherpa-policies/section-sherpa-policies.component.html +++ b/src/app/submission/sections/sherpa-policies/section-sherpa-policies.component.html @@ -1,57 +1,62 @@ -
+
- - - -
- - -
- {{'submission.sections.sherpa.publication.information' - | translate}} -
- - - -
- - + + +
- - + +
- {{'submission.sections.sherpa.publisher.policy' + {{'submission.sections.sherpa.publication.information' | translate}}
- +
+ + + +
+ + +
+ {{'submission.sections.sherpa.publisher.policy' + | translate}} +
+ + + +
+
+ + +
+ + +
+ {{'submission.sections.sherpa.record.information' + | translate}} +
+ + + +
- - -
- - -
- {{'submission.sections.sherpa.record.information' - | translate}} -
- - - -
-
+ \ No newline at end of file diff --git a/src/app/submission/sections/sherpa-policies/section-sherpa-policies.component.spec.ts b/src/app/submission/sections/sherpa-policies/section-sherpa-policies.component.spec.ts index fb8f8ba355..0637745939 100644 --- a/src/app/submission/sections/sherpa-policies/section-sherpa-policies.component.spec.ts +++ b/src/app/submission/sections/sherpa-policies/section-sherpa-policies.component.spec.ts @@ -1,7 +1,8 @@ +import { SharedModule } from './../../../shared/shared.module'; import { NgbAccordionModule } from '@ng-bootstrap/ng-bootstrap'; import { SubmissionServiceStub } from '../../../shared/testing/submission-service.stub'; import { SherpaDataResponse } from '../../../shared/mocks/section-sherpa-policies.service.mock'; -import { ComponentFixture, inject, TestBed } from '@angular/core/testing'; +import { ComponentFixture, inject, TestBed, fakeAsync, tick } from '@angular/core/testing'; import { SectionsService } from '../sections.service'; import { SectionsServiceStub } from '../../../shared/testing/sections-service.stub'; @@ -58,7 +59,8 @@ describe('SubmissionSectionSherpaPoliciesComponent', () => { useClass: TranslateLoaderMock } }), - NgbAccordionModule + NgbAccordionModule, + SharedModule ], declarations: [SubmissionSectionSherpaPoliciesComponent], providers: [ @@ -77,7 +79,7 @@ describe('SubmissionSectionSherpaPoliciesComponent', () => { fixture = TestBed.createComponent(SubmissionSectionSherpaPoliciesComponent); component = fixture.componentInstance; de = fixture.debugElement; - sectionsServiceStub.getSectionData.and.returnValue(observableOf(SherpaDataResponse)) + sectionsServiceStub.getSectionData.and.returnValue(observableOf(SherpaDataResponse)); fixture.detectChanges(); })); @@ -112,7 +114,6 @@ describe('SubmissionSectionSherpaPoliciesComponent', () => { it('when refresh button click operationsBuilder.remove should have been called', () => { de.query(By.css('.refresh-container > button')).nativeElement.click(); - fixture.detectChanges(); expect(operationsBuilder.remove).toHaveBeenCalled(); }); diff --git a/src/app/submission/sections/sherpa-policies/section-sherpa-policies.component.ts b/src/app/submission/sections/sherpa-policies/section-sherpa-policies.component.ts index d287a182ba..a56eb5f663 100644 --- a/src/app/submission/sections/sherpa-policies/section-sherpa-policies.component.ts +++ b/src/app/submission/sections/sherpa-policies/section-sherpa-policies.component.ts @@ -1,6 +1,6 @@ import { Component, Inject, QueryList, ViewChildren } from '@angular/core'; -import { BehaviorSubject, Observable, of, Subscription } from 'rxjs'; +import { BehaviorSubject, interval, Observable, of, Subscription } from 'rxjs'; import { JsonPatchOperationPathCombiner } from '../../../core/json-patch/builder/json-patch-operation-path-combiner'; import { JsonPatchOperationsBuilder } from '../../../core/json-patch/builder/json-patch-operations-builder'; @@ -14,6 +14,7 @@ import { SectionsService } from '../sections.service'; import { SectionModelComponent } from '../models/section.model'; import { SubmissionService } from '../../submission.service'; import { hasValue, isEmpty } from '../../../shared/empty.util'; +import { debounce, debounceTime, timeInterval } from 'rxjs/operators'; /** * This component represents a section for managing item's access conditions. @@ -77,9 +78,11 @@ export class SubmissionSectionSherpaPoliciesComponent extends SectionModelCompon * Expand all primary accordions */ ngAfterViewInit() { - this.acc.forEach(accordion => { - accordion.expandAll(); - }); + if (this.acc) { + this.acc.forEach(accordion => { + accordion.expandAll(); + }); + } } @@ -93,9 +96,20 @@ export class SubmissionSectionSherpaPoliciesComponent extends SectionModelCompon this.sectionService.getSectionData(this.submissionId, this.sectionData.id, this.sectionData.sectionType) .subscribe((sherpaPolicies: WorkspaceitemSectionSherpaPoliciesObject) => { this.sherpaPoliciesData$.next(sherpaPolicies); - console.log(this.sherpaPoliciesData$.value) }) ); + + this.subs.push( + this.sherpaPoliciesData$.pipe( + debounceTime(500) + ).subscribe((sherpaPolicies: WorkspaceitemSectionSherpaPoliciesObject) => { + if (this.acc) { + this.acc.forEach(accordion => { + accordion.expandAll(); + }); + } + }) + ); } /** From b023a5a03c428faffd64eff771811f59bc94fd25 Mon Sep 17 00:00:00 2001 From: Giuseppe Digilio Date: Thu, 28 Apr 2022 18:58:35 +0200 Subject: [PATCH 09/28] [CST-5270] Fix submission-objects.effects sherpa romeo customization --- .../objects/submission-objects.effects.ts | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/src/app/submission/objects/submission-objects.effects.ts b/src/app/submission/objects/submission-objects.effects.ts index 0c5f3fb61b..4a7907cab1 100644 --- a/src/app/submission/objects/submission-objects.effects.ts +++ b/src/app/submission/objects/submission-objects.effects.ts @@ -2,7 +2,7 @@ import { Injectable } from '@angular/core'; import { Actions, createEffect, ofType } from '@ngrx/effects'; import { Store } from '@ngrx/store'; import { TranslateService } from '@ngx-translate/core'; -import { isEqual, isUndefined, union } from 'lodash'; +import { findKey, isEqual, union } from 'lodash'; import { from as observableFrom, Observable, of as observableOf } from 'rxjs'; import { catchError, filter, map, mergeMap, switchMap, take, tap, withLatestFrom } from 'rxjs/operators'; @@ -425,12 +425,15 @@ export class SubmissionObjectEffects { const filteredErrors = filterErrors(sectionForm, sectionErrors, currentState.sections[sectionId].sectionType, showErrors); mappedActions.push(new UpdateSectionDataAction(submissionId, sectionId, sectionData, filteredErrors, sectionErrors)); } + + // Sherpa Policies section needs to be updated when the rest response section is empty + const sherpaPoliciesSectionId = findKey(currentState.sections, (section) => section.sectionType === SectionsType.SherpaPolicies); + if (isNotUndefined(sherpaPoliciesSectionId) && isNotEmpty(currentState.sections[sherpaPoliciesSectionId]?.data) + && isEmpty(sections[sherpaPoliciesSectionId])) { + mappedActions.push(new UpdateSectionDataAction(submissionId, sherpaPoliciesSectionId, null, [], [])); + } }); - let currentStateId = currentState.selfUrl.split('/')[currentState.selfUrl.split('/').length - 1]; - let currentResponseItem = response.find(item => item.id.toString() === currentStateId); - if (!isUndefined(currentState.sections.sherpaPolicies?.data) && isUndefined(currentResponseItem.sections.sherpaPolicies)) { - mappedActions.push(new UpdateSectionDataAction(submissionId, 'sherpaPolicies', null, [], [])); - } + } return mappedActions; } From d435d8eeb1762acd2d03893858609f42b29a9f9a Mon Sep 17 00:00:00 2001 From: Rezart Vata Date: Thu, 28 Apr 2022 19:07:38 +0200 Subject: [PATCH 10/28] [CST-5270] Fixed graphical changes requested --- .../content-accordion.component.html | 4 +-- .../section-sherpa-policies.component.html | 34 +++++++++---------- .../section-sherpa-policies.component.scss | 2 +- 3 files changed, 20 insertions(+), 20 deletions(-) diff --git a/src/app/submission/sections/sherpa-policies/content-accordion/content-accordion.component.html b/src/app/submission/sections/sherpa-policies/content-accordion/content-accordion.component.html index bec999603d..c2d7207c98 100644 --- a/src/app/submission/sections/sherpa-policies/content-accordion/content-accordion.component.html +++ b/src/app/submission/sections/sherpa-policies/content-accordion/content-accordion.component.html @@ -6,8 +6,8 @@ translate }}
- - + +
diff --git a/src/app/submission/sections/sherpa-policies/section-sherpa-policies.component.html b/src/app/submission/sections/sherpa-policies/section-sherpa-policies.component.html index b7b24ffcf0..f74e38bf8f 100644 --- a/src/app/submission/sections/sherpa-policies/section-sherpa-policies.component.html +++ b/src/app/submission/sections/sherpa-policies/section-sherpa-policies.component.html @@ -12,15 +12,15 @@ -
- - -
{{'submission.sections.sherpa.publication.information' | translate}} +
+ + +
@@ -29,15 +29,15 @@ -
- - -
{{'submission.sections.sherpa.publisher.policy' | translate}} +
+ + +
@@ -47,12 +47,12 @@
-
- - -
- {{'submission.sections.sherpa.record.information' + {{'submission.sections.sherpa.record.information' | translate}} +
+ + +
diff --git a/src/app/submission/sections/sherpa-policies/section-sherpa-policies.component.scss b/src/app/submission/sections/sherpa-policies/section-sherpa-policies.component.scss index 5a8e0e3c34..adaa627d56 100644 --- a/src/app/submission/sections/sherpa-policies/section-sherpa-policies.component.scss +++ b/src/app/submission/sections/sherpa-policies/section-sherpa-policies.component.scss @@ -12,7 +12,7 @@ button { text-align: left; padding: 0px; - width: auto; + // width: auto; font-weight: bold; .fas { From 8498504b939c5e184800fa030ff1e97d88b82a46 Mon Sep 17 00:00:00 2001 From: Giuseppe Digilio Date: Fri, 29 Apr 2022 16:14:47 +0200 Subject: [PATCH 11/28] [CST-5270] Add target blank for links --- .../metadata-information.component.html | 4 ++-- .../publication-information.component.html | 24 +++++++------------ .../publisher-policy.component.html | 4 ++-- 3 files changed, 13 insertions(+), 19 deletions(-) diff --git a/src/app/submission/sections/sherpa-policies/metadata-information/metadata-information.component.html b/src/app/submission/sections/sherpa-policies/metadata-information/metadata-information.component.html index bfbfe5f2fd..683821d62c 100644 --- a/src/app/submission/sections/sherpa-policies/metadata-information/metadata-information.component.html +++ b/src/app/submission/sections/sherpa-policies/metadata-information/metadata-information.component.html @@ -32,8 +32,8 @@
-
\ No newline at end of file +
diff --git a/src/app/submission/sections/sherpa-policies/publication-information/publication-information.component.html b/src/app/submission/sections/sherpa-policies/publication-information/publication-information.component.html index 2e6da459ae..079535b2fb 100644 --- a/src/app/submission/sections/sherpa-policies/publication-information/publication-information.component.html +++ b/src/app/submission/sections/sherpa-policies/publication-information/publication-information.component.html @@ -1,8 +1,7 @@
-

{{'submission.sections.sherpa.publication.information.title' - | translate}}

+

{{'submission.sections.sherpa.publication.information.title' | translate}}

{{title}} @@ -11,8 +10,7 @@

-

{{'submission.sections.sherpa.publication.information.issns' - | translate}}

+

{{'submission.sections.sherpa.publication.information.issns' | translate}}

{{issn}} @@ -21,12 +19,11 @@

-

{{'submission.sections.sherpa.publication.information.url' - | translate}}

+

{{'submission.sections.sherpa.publication.information.url' | translate}}

- + {{journal.url}}

@@ -34,12 +31,11 @@
-

{{'submission.sections.sherpa.publication.information.publishers' - | translate}}

+

{{'submission.sections.sherpa.publication.information.publishers' | translate}}

- + {{publisher.name}}

@@ -47,8 +43,7 @@
-

{{'submission.sections.sherpa.publication.information.romeoPub' - | translate}}

+

{{'submission.sections.sherpa.publication.information.romeoPub' | translate}}

@@ -58,8 +53,7 @@

-

{{'submission.sections.sherpa.publication.information.zetoPub' - | translate}}

+

{{'submission.sections.sherpa.publication.information.zetoPub' | translate}}

@@ -67,4 +61,4 @@

-
\ No newline at end of file +
diff --git a/src/app/submission/sections/sherpa-policies/publisher-policy/publisher-policy.component.html b/src/app/submission/sections/sherpa-policies/publisher-policy/publisher-policy.component.html index 4a03bae735..ada6613aa2 100644 --- a/src/app/submission/sections/sherpa-policies/publisher-policy/publisher-policy.component.html +++ b/src/app/submission/sections/sherpa-policies/publisher-policy/publisher-policy.component.html @@ -15,9 +15,9 @@

-
\ No newline at end of file +
From a03557fcada16ad6e42b50ae94b77c129329ee02 Mon Sep 17 00:00:00 2001 From: Rezart Vata Date: Wed, 18 May 2022 16:44:20 +0200 Subject: [PATCH 12/28] [CST-5270] fixed accordion issue and changed it to collapsable --- .../content-accordion.component.html | 119 +++++++++--------- .../content-accordion.component.spec.ts | 8 +- .../content-accordion.component.ts | 4 + .../section-sherpa-policies.component.html | 94 +++++++------- .../section-sherpa-policies.component.spec.ts | 12 +- .../section-sherpa-policies.component.ts | 30 +---- src/app/submission/submission.module.ts | 6 +- 7 files changed, 122 insertions(+), 151 deletions(-) diff --git a/src/app/submission/sections/sherpa-policies/content-accordion/content-accordion.component.html b/src/app/submission/sections/sherpa-policies/content-accordion/content-accordion.component.html index c2d7207c98..767bab0d98 100644 --- a/src/app/submission/sections/sherpa-policies/content-accordion/content-accordion.component.html +++ b/src/app/submission/sections/sherpa-policies/content-accordion/content-accordion.component.html @@ -1,63 +1,62 @@ - - - - - {{version.articleVersion | titlecase}} {{ 'submission.sections.sherpa.publisher.policy.version' | - translate }} - -
- - -
-
- -
-
-
-

{{ 'submission.sections.sherpa.publisher.policy.embargo' | translate }}

-
-
-

{{version.embargo.amount}} - {{version.embargo.units}}

- -

{{ 'submission.sections.sherpa.publisher.policy.noembargo' | translate }}

-
+
+
+ +
+ + +
+
+
+
+
+
+

{{ 'submission.sections.sherpa.publisher.policy.embargo' | translate }}

+
+
+

{{version.embargo.amount}} + {{version.embargo.units}}

+ +

{{ 'submission.sections.sherpa.publisher.policy.noembargo' | translate }}

+
-
-
-
-
-

{{ 'submission.sections.sherpa.publisher.policy.license' | translate }}

-
-
-

{{license}}

-
-
-
-
-

{{ 'submission.sections.sherpa.publisher.policy.prerequisites' | translate }}

-
-
-

{{prerequisite}}

-
-
-
-
-

{{ 'submission.sections.sherpa.publisher.policy.location' | translate }}

-
-
-

{{location}}

-
-
-
-
-

{{ 'submission.sections.sherpa.publisher.policy.conditions' | translate }}

-
-
-

{{condition}}

-
- - - \ No newline at end of file +
+
+

{{ 'submission.sections.sherpa.publisher.policy.license' | translate }}

+
+
+

{{license}}

+
+
+
+
+

{{ 'submission.sections.sherpa.publisher.policy.prerequisites' | translate }}

+
+
+

{{prerequisite}}

+
+
+
+
+

{{ 'submission.sections.sherpa.publisher.policy.location' | translate }}

+
+
+

{{location}}

+
+
+
+
+

{{ 'submission.sections.sherpa.publisher.policy.conditions' | translate }}

+
+
+

{{condition}}

+
+
+
+
+
\ No newline at end of file diff --git a/src/app/submission/sections/sherpa-policies/content-accordion/content-accordion.component.spec.ts b/src/app/submission/sections/sherpa-policies/content-accordion/content-accordion.component.spec.ts index 382450fbd3..b07674c40d 100644 --- a/src/app/submission/sections/sherpa-policies/content-accordion/content-accordion.component.spec.ts +++ b/src/app/submission/sections/sherpa-policies/content-accordion/content-accordion.component.spec.ts @@ -1,4 +1,4 @@ -import { NgbAccordionModule } from '@ng-bootstrap/ng-bootstrap'; +import { NgbCollapseModule } from '@ng-bootstrap/ng-bootstrap'; import { TranslateLoaderMock } from '../../../../shared/mocks/translate-loader.mock'; import { ComponentFixture, TestBed } from '@angular/core/testing'; @@ -23,7 +23,7 @@ describe('ContentAccordionComponent', () => { useClass: TranslateLoaderMock } }), - NgbAccordionModule + NgbCollapseModule ], declarations: [ContentAccordionComponent] }) @@ -42,10 +42,6 @@ describe('ContentAccordionComponent', () => { expect(component).toBeTruthy(); }); - it('should show accordion', () => { - expect(de.query(By.css('ngb-accordion'))).toBeTruthy(); - }); - it('should show 5 rows', () => { expect(de.queryAll(By.css('.row')).length).toEqual(5); }); diff --git a/src/app/submission/sections/sherpa-policies/content-accordion/content-accordion.component.ts b/src/app/submission/sections/sherpa-policies/content-accordion/content-accordion.component.ts index a2decc38e1..94d085db39 100644 --- a/src/app/submission/sections/sherpa-policies/content-accordion/content-accordion.component.ts +++ b/src/app/submission/sections/sherpa-policies/content-accordion/content-accordion.component.ts @@ -13,4 +13,8 @@ export class ContentAccordionComponent { */ @Input() version: PermittedVersions; + /** + * A boolean representing if div should start collapsed + */ + public isCollapsed = false; } diff --git a/src/app/submission/sections/sherpa-policies/section-sherpa-policies.component.html b/src/app/submission/sections/sherpa-policies/section-sherpa-policies.component.html index f74e38bf8f..1ebcfc26c8 100644 --- a/src/app/submission/sections/sherpa-policies/section-sherpa-policies.component.html +++ b/src/app/submission/sections/sherpa-policies/section-sherpa-policies.component.html @@ -7,56 +7,56 @@
- + - - - {{'submission.sections.sherpa.publication.information' - | translate}} -
- - +
+
+ +
+ +
- - - - - - - - - {{'submission.sections.sherpa.publisher.policy' - | translate}} -
- - -
-
- - - -
-
- - - - {{'submission.sections.sherpa.record.information' - | translate}} -
- -
-
- +
+ +
+
+
+
+ +
+ + +
+
+
+ +
+
+ + +
+
+ +
+ + +
+
+
- - +
+
- \ No newline at end of file + + \ No newline at end of file diff --git a/src/app/submission/sections/sherpa-policies/section-sherpa-policies.component.spec.ts b/src/app/submission/sections/sherpa-policies/section-sherpa-policies.component.spec.ts index 0637745939..30a50743b7 100644 --- a/src/app/submission/sections/sherpa-policies/section-sherpa-policies.component.spec.ts +++ b/src/app/submission/sections/sherpa-policies/section-sherpa-policies.component.spec.ts @@ -1,5 +1,5 @@ import { SharedModule } from './../../../shared/shared.module'; -import { NgbAccordionModule } from '@ng-bootstrap/ng-bootstrap'; +import { NgbCollapseModule } from '@ng-bootstrap/ng-bootstrap'; import { SubmissionServiceStub } from '../../../shared/testing/submission-service.stub'; import { SherpaDataResponse } from '../../../shared/mocks/section-sherpa-policies.service.mock'; import { ComponentFixture, inject, TestBed, fakeAsync, tick } from '@angular/core/testing'; @@ -59,7 +59,7 @@ describe('SubmissionSectionSherpaPoliciesComponent', () => { useClass: TranslateLoaderMock } }), - NgbAccordionModule, + NgbCollapseModule, SharedModule ], declarations: [SubmissionSectionSherpaPoliciesComponent], @@ -88,14 +88,6 @@ describe('SubmissionSectionSherpaPoliciesComponent', () => { expect(component).toBeTruthy(); }); - it('should show accordions', () => { - expect(de.query(By.css('ngb-accordion'))).toBeTruthy(); - }); - - it('should show expanded accordion', () => { - expect(component.acc.first.isExpanded('publication-information-0')).toBeTrue(); - }); - it('should show refresh button', () => { expect(de.query(By.css('.refresh-container > button'))).toBeTruthy(); }); diff --git a/src/app/submission/sections/sherpa-policies/section-sherpa-policies.component.ts b/src/app/submission/sections/sherpa-policies/section-sherpa-policies.component.ts index a56eb5f663..8e133224e9 100644 --- a/src/app/submission/sections/sherpa-policies/section-sherpa-policies.component.ts +++ b/src/app/submission/sections/sherpa-policies/section-sherpa-policies.component.ts @@ -27,8 +27,6 @@ import { debounce, debounceTime, timeInterval } from 'rxjs/operators'; @renderSectionFor(SectionsType.SherpaPolicies) export class SubmissionSectionSherpaPoliciesComponent extends SectionModelComponent { - @ViewChildren('acc', { emitDistinctChangesOnly: true }) acc: QueryList; - /** * The accesses section data * @type {WorkspaceitemSectionAccessesObject} @@ -47,6 +45,11 @@ export class SubmissionSectionSherpaPoliciesComponent extends SectionModelCompon */ protected subs: Subscription[] = []; + /** + * A boolean representing if div should start collapsed + */ + public isCollapsed = false; + /** * Initialize instance variables * @@ -74,17 +77,6 @@ export class SubmissionSectionSherpaPoliciesComponent extends SectionModelCompon .forEach((subscription) => subscription.unsubscribe()); } - /** - * Expand all primary accordions - */ - ngAfterViewInit() { - if (this.acc) { - this.acc.forEach(accordion => { - accordion.expandAll(); - }); - } - } - /** * Initialize all instance variables and retrieve collection default access conditions @@ -98,18 +90,6 @@ export class SubmissionSectionSherpaPoliciesComponent extends SectionModelCompon this.sherpaPoliciesData$.next(sherpaPolicies); }) ); - - this.subs.push( - this.sherpaPoliciesData$.pipe( - debounceTime(500) - ).subscribe((sherpaPolicies: WorkspaceitemSectionSherpaPoliciesObject) => { - if (this.acc) { - this.acc.forEach(accordion => { - accordion.expandAll(); - }); - } - }) - ); } /** diff --git a/src/app/submission/submission.module.ts b/src/app/submission/submission.module.ts index b0b6d5195d..c25dab2624 100644 --- a/src/app/submission/submission.module.ts +++ b/src/app/submission/submission.module.ts @@ -50,7 +50,7 @@ import { ThemedSubmissionEditComponent } from './edit/themed-submission-edit.com import { ThemedSubmissionSubmitComponent } from './submit/themed-submission-submit.component'; import { ThemedSubmissionImportExternalComponent } from './import-external/themed-submission-import-external.component'; import { FormModule } from '../shared/form/form.module'; -import { NgbAccordionModule, NgbModalModule } from '@ng-bootstrap/ng-bootstrap'; +import { NgbCollapseModule, NgbModalModule } from '@ng-bootstrap/ng-bootstrap'; import { SubmissionSectionAccessesComponent } from './sections/accesses/section-accesses.component'; import { SubmissionAccessesConfigService } from '../core/config/submission-accesses-config.service'; import { SectionAccessesService } from './sections/accesses/section-accesses.service'; @@ -113,8 +113,8 @@ const DECLARATIONS = [ JournalEntitiesModule.withEntryComponents(), ResearchEntitiesModule.withEntryComponents(), FormModule, - NgbAccordionModule, - NgbModalModule + NgbModalModule, + NgbCollapseModule, ], declarations: DECLARATIONS, exports: DECLARATIONS, From cba7a60476b49da669cb157a7a04f20c43d644ea Mon Sep 17 00:00:00 2001 From: Rezart Vata Date: Thu, 19 May 2022 15:55:05 +0200 Subject: [PATCH 13/28] [CST-5270] fixing module accordion --- src/app/submission/submission.module.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/app/submission/submission.module.ts b/src/app/submission/submission.module.ts index c25dab2624..dce3d18afc 100644 --- a/src/app/submission/submission.module.ts +++ b/src/app/submission/submission.module.ts @@ -50,7 +50,7 @@ import { ThemedSubmissionEditComponent } from './edit/themed-submission-edit.com import { ThemedSubmissionSubmitComponent } from './submit/themed-submission-submit.component'; import { ThemedSubmissionImportExternalComponent } from './import-external/themed-submission-import-external.component'; import { FormModule } from '../shared/form/form.module'; -import { NgbCollapseModule, NgbModalModule } from '@ng-bootstrap/ng-bootstrap'; +import { NgbCollapseModule, NgbModalModule, NgbAccordionModule } from '@ng-bootstrap/ng-bootstrap'; import { SubmissionSectionAccessesComponent } from './sections/accesses/section-accesses.component'; import { SubmissionAccessesConfigService } from '../core/config/submission-accesses-config.service'; import { SectionAccessesService } from './sections/accesses/section-accesses.service'; @@ -115,6 +115,7 @@ const DECLARATIONS = [ FormModule, NgbModalModule, NgbCollapseModule, + NgbAccordionModule ], declarations: DECLARATIONS, exports: DECLARATIONS, From 166f4c3b25f5c0756d64df3204d999c5c1e90781 Mon Sep 17 00:00:00 2001 From: Rezart Vata Date: Mon, 23 May 2022 17:39:36 +0200 Subject: [PATCH 14/28] [CST-5270] Finished functionalities --- .../section-container.component.html | 63 +++++++++---------- .../submission/sections/sections.directive.ts | 17 ++++- .../submission/sections/sections.service.ts | 28 ++++++--- .../content-accordion.component.html | 62 +++++++++++++----- .../content-accordion.component.scss | 33 ---------- .../content-accordion.component.ts | 5 +- .../metadata-information.component.html | 10 +-- .../metadata-information.component.ts | 3 + .../publication-information.component.html | 16 ++--- .../publication-information.component.ts | 3 + .../publisher-policy.component.html | 4 +- .../publisher-policy.component.ts | 3 + .../section-sherpa-policies.component.scss | 32 ---------- .../section-sherpa-policies.component.ts | 3 +- src/assets/i18n/en.json5 | 11 ++-- 15 files changed, 145 insertions(+), 148 deletions(-) diff --git a/src/app/submission/sections/container/section-container.component.html b/src/app/submission/sections/container/section-container.component.html index e7a9d141c7..95ed9289c9 100644 --- a/src/app/submission/sections/container/section-container.component.html +++ b/src/app/submission/sections/container/section-container.component.html @@ -1,52 +1,49 @@ -
- +
+ - {{ 'submission.sections.'+sectionData.header | translate }} + {{ 'submission.sections.'+sectionData.header | translate + }}
- +
-
+
-
+
\ No newline at end of file diff --git a/src/app/submission/sections/sections.directive.ts b/src/app/submission/sections/sections.directive.ts index 3ffb317b15..d82cff82d6 100644 --- a/src/app/submission/sections/sections.directive.ts +++ b/src/app/submission/sections/sections.directive.ts @@ -94,8 +94,8 @@ export class SectionsDirective implements OnDestroy, OnInit { * @param {SectionsService} sectionService */ constructor(private changeDetectorRef: ChangeDetectorRef, - private submissionService: SubmissionService, - private sectionService: SectionsService) { + private submissionService: SubmissionService, + private sectionService: SectionsService) { } /** @@ -272,6 +272,19 @@ export class SectionsDirective implements OnDestroy, OnInit { } } + + /** + * Check if section is information + * + * @returns {Observable} + * Emits true whenever section is information + */ + public isInfo(): boolean { + return this.sectionService.getIsInformational(this.sectionType); + } + + + /** * Remove error from list * diff --git a/src/app/submission/sections/sections.service.ts b/src/app/submission/sections/sections.service.ts index 64f9e2efcd..56b2356ed7 100644 --- a/src/app/submission/sections/sections.service.ts +++ b/src/app/submission/sections/sections.service.ts @@ -60,11 +60,11 @@ export class SectionsService { * @param {TranslateService} translate */ constructor(private formService: FormService, - private notificationsService: NotificationsService, - private scrollToService: ScrollToService, - private submissionService: SubmissionService, - private store: Store, - private translate: TranslateService) { + private notificationsService: NotificationsService, + private scrollToService: ScrollToService, + private submissionService: SubmissionService, + private store: Store, + private translate: TranslateService) { } /** @@ -197,7 +197,7 @@ export class SectionsService { path: pathCombiner.getPath(error.fieldId.replace(/\_/g, '.')).path, message: error.message } as SubmissionSectionError)) - .filter((sectionError: SubmissionSectionError) => findIndex(state.errorsToShow, {path: sectionError.path}) === -1); + .filter((sectionError: SubmissionSectionError) => findIndex(state.errorsToShow, { path: sectionError.path }) === -1); return [...state.errorsToShow, ...sectionErrors]; }) )) @@ -262,7 +262,7 @@ export class SectionsService { } }), distinctUntilChanged() - ); + ); } /** @@ -371,7 +371,7 @@ export class SectionsService { return this.store.select(submissionObjectFromIdSelector(submissionId)).pipe( filter((submissionState: SubmissionObjectEntry) => isNotUndefined(submissionState)), map((submissionState: SubmissionObjectEntry) => { - return isNotUndefined(submissionState.sections) && isNotUndefined(findKey(submissionState.sections, {sectionType: sectionType})); + return isNotUndefined(submissionState.sections) && isNotUndefined(findKey(submissionState.sections, { sectionType: sectionType })); }), distinctUntilChanged()); } @@ -514,4 +514,16 @@ export class SectionsService { return metadata; } + /** + * Return if the section is an informational type section. + * @param sectionType + */ + public getIsInformational(sectionType: SectionsType): boolean { + if (sectionType === SectionsType.SherpaPolicies) { + return true; + } else { + return false; + } + } + } diff --git a/src/app/submission/sections/sherpa-policies/content-accordion/content-accordion.component.html b/src/app/submission/sections/sherpa-policies/content-accordion/content-accordion.component.html index 767bab0d98..0b52c8341d 100644 --- a/src/app/submission/sections/sherpa-policies/content-accordion/content-accordion.component.html +++ b/src/app/submission/sections/sherpa-policies/content-accordion/content-accordion.component.html @@ -1,20 +1,45 @@
- +
+ +
+ {{version.embargo.amount}} + {{version.embargo.units[1]}} + + {{ + 'submission.sections.sherpa.publisher.policy.noembargo' | translate }} + + + + + + {{version.locations[0]}} +{{version.locations.length-1}} + + + {{ + 'submission.sections.sherpa.publisher.policy.nolocation' | translate }} + + +
+
-
-
+
+
-

{{ 'submission.sections.sherpa.publisher.policy.embargo' | translate }}

+

{{ + 'submission.sections.sherpa.publisher.policy.embargo' | translate }}

{{version.embargo.amount}} @@ -22,36 +47,39 @@

{{ 'submission.sections.sherpa.publisher.policy.noembargo' | translate }}

-
-
+
-

{{ 'submission.sections.sherpa.publisher.policy.license' | translate }}

+

{{ + 'submission.sections.sherpa.publisher.policy.license' | translate }}

{{license}}

-
+
-

{{ 'submission.sections.sherpa.publisher.policy.prerequisites' | translate }}

+

{{ + 'submission.sections.sherpa.publisher.policy.prerequisites' | translate }}

{{prerequisite}}

-
+
-

{{ 'submission.sections.sherpa.publisher.policy.location' | translate }}

+

{{ + 'submission.sections.sherpa.publisher.policy.location' | translate }}

{{location}}

-
+
-

{{ 'submission.sections.sherpa.publisher.policy.conditions' | translate }}

+

{{ + 'submission.sections.sherpa.publisher.policy.conditions' | translate }}

{{condition}}

diff --git a/src/app/submission/sections/sherpa-policies/content-accordion/content-accordion.component.scss b/src/app/submission/sections/sherpa-policies/content-accordion/content-accordion.component.scss index b18e7d3781..e69de29bb2 100644 --- a/src/app/submission/sections/sherpa-policies/content-accordion/content-accordion.component.scss +++ b/src/app/submission/sections/sherpa-policies/content-accordion/content-accordion.component.scss @@ -1,33 +0,0 @@ -:host ::ng-deep { - .card { - border: none; - margin-bottom: 20px; - border-bottom: 1px solid rgba(0, 0, 0, 0.125); - - .card-header { - border: none; - background-color: transparent; - border-top: 1px solid rgba(0, 0, 0, 0.125); - - button { - text-align: left; - padding: 0px; - width: 100%; - color: #000; - font-weight: 600; - - .fas { - background: #fff; - color: #000; - margin-right: 10px; - height: 1.25em; - display: flex; - align-items: center; - justify-content: center; - font-size: 12px; - } - } - } - } - -} \ No newline at end of file diff --git a/src/app/submission/sections/sherpa-policies/content-accordion/content-accordion.component.ts b/src/app/submission/sections/sherpa-policies/content-accordion/content-accordion.component.ts index 94d085db39..0e7bc863ad 100644 --- a/src/app/submission/sections/sherpa-policies/content-accordion/content-accordion.component.ts +++ b/src/app/submission/sections/sherpa-policies/content-accordion/content-accordion.component.ts @@ -2,6 +2,9 @@ import { Component, Input } from '@angular/core'; import { PermittedVersions } from '../../../../core/submission/models/sherpa-policies-details.model'; +/** + * This component represents a section that contains the inner accordions for the publisher policy versions. + */ @Component({ selector: 'ds-content-accordion', templateUrl: './content-accordion.component.html', @@ -16,5 +19,5 @@ export class ContentAccordionComponent { /** * A boolean representing if div should start collapsed */ - public isCollapsed = false; + public isCollapsed = true; } diff --git a/src/app/submission/sections/sherpa-policies/metadata-information/metadata-information.component.html b/src/app/submission/sections/sherpa-policies/metadata-information/metadata-information.component.html index 683821d62c..15dd4d7286 100644 --- a/src/app/submission/sections/sherpa-policies/metadata-information/metadata-information.component.html +++ b/src/app/submission/sections/sherpa-policies/metadata-information/metadata-information.component.html @@ -1,5 +1,5 @@
-
+

{{ 'submission.sections.sherpa.record.information.id' | translate }}

@@ -8,7 +8,7 @@

-
+

{{ 'submission.sections.sherpa.record.information.date.created' | translate }}

@@ -17,7 +17,7 @@

-
+

{{ 'submission.sections.sherpa.record.information.date.modified' | translate }}

@@ -26,7 +26,7 @@

-
+

{{ 'submission.sections.sherpa.record.information.uri' | translate }}

@@ -36,4 +36,4 @@

-
+
\ No newline at end of file diff --git a/src/app/submission/sections/sherpa-policies/metadata-information/metadata-information.component.ts b/src/app/submission/sections/sherpa-policies/metadata-information/metadata-information.component.ts index cced669024..307c18d8cc 100644 --- a/src/app/submission/sections/sherpa-policies/metadata-information/metadata-information.component.ts +++ b/src/app/submission/sections/sherpa-policies/metadata-information/metadata-information.component.ts @@ -2,6 +2,9 @@ import { Component, Input } from '@angular/core'; import { Metadata } from '../../../../core/submission/models/sherpa-policies-details.model'; +/** + * This component represents a section that contains the matadata informations. + */ @Component({ selector: 'ds-metadata-information', templateUrl: './metadata-information.component.html', diff --git a/src/app/submission/sections/sherpa-policies/publication-information/publication-information.component.html b/src/app/submission/sections/sherpa-policies/publication-information/publication-information.component.html index 079535b2fb..3c35da8f08 100644 --- a/src/app/submission/sections/sherpa-policies/publication-information/publication-information.component.html +++ b/src/app/submission/sections/sherpa-policies/publication-information/publication-information.component.html @@ -1,5 +1,5 @@
-
+

{{'submission.sections.sherpa.publication.information.title' | translate}}

@@ -8,7 +8,7 @@

-
+

{{'submission.sections.sherpa.publication.information.issns' | translate}}

@@ -17,7 +17,7 @@

-
+

{{'submission.sections.sherpa.publication.information.url' | translate}}

@@ -29,7 +29,7 @@

-
+

{{'submission.sections.sherpa.publication.information.publishers' | translate}}

@@ -41,7 +41,7 @@

-
+

{{'submission.sections.sherpa.publication.information.romeoPub' | translate}}

@@ -51,9 +51,9 @@

-
+
-

{{'submission.sections.sherpa.publication.information.zetoPub' | translate}}

+

{{'submission.sections.sherpa.publication.information.zetoPub' | translate}}

@@ -61,4 +61,4 @@

-
+
\ No newline at end of file diff --git a/src/app/submission/sections/sherpa-policies/publication-information/publication-information.component.ts b/src/app/submission/sections/sherpa-policies/publication-information/publication-information.component.ts index 54973eba02..cfe42adf7b 100644 --- a/src/app/submission/sections/sherpa-policies/publication-information/publication-information.component.ts +++ b/src/app/submission/sections/sherpa-policies/publication-information/publication-information.component.ts @@ -2,6 +2,9 @@ import { Component, Input } from '@angular/core'; import { Journal } from '../../../../core/submission/models/sherpa-policies-details.model'; +/** + * This component represents a section that contains the journal publication information. + */ @Component({ selector: 'ds-publication-information', templateUrl: './publication-information.component.html', diff --git a/src/app/submission/sections/sherpa-policies/publisher-policy/publisher-policy.component.html b/src/app/submission/sections/sherpa-policies/publisher-policy/publisher-policy.component.html index ada6613aa2..24e3b09762 100644 --- a/src/app/submission/sections/sherpa-policies/publisher-policy/publisher-policy.component.html +++ b/src/app/submission/sections/sherpa-policies/publisher-policy/publisher-policy.component.html @@ -8,7 +8,7 @@
-
+

{{'submission.sections.sherpa.publisher.policy.more.information' | translate}} @@ -20,4 +20,4 @@

-
+
\ No newline at end of file diff --git a/src/app/submission/sections/sherpa-policies/publisher-policy/publisher-policy.component.ts b/src/app/submission/sections/sherpa-policies/publisher-policy/publisher-policy.component.ts index 639361beb0..42d755d5b1 100644 --- a/src/app/submission/sections/sherpa-policies/publisher-policy/publisher-policy.component.ts +++ b/src/app/submission/sections/sherpa-policies/publisher-policy/publisher-policy.component.ts @@ -2,6 +2,9 @@ import { Component, Input } from '@angular/core'; import { Policy } from '../../../../core/submission/models/sherpa-policies-details.model'; +/** + * This component represents a section that contains the publisher policy informations. + */ @Component({ selector: 'ds-publisher-policy', templateUrl: './publisher-policy.component.html', diff --git a/src/app/submission/sections/sherpa-policies/section-sherpa-policies.component.scss b/src/app/submission/sections/sherpa-policies/section-sherpa-policies.component.scss index adaa627d56..c68df78fca 100644 --- a/src/app/submission/sections/sherpa-policies/section-sherpa-policies.component.scss +++ b/src/app/submission/sections/sherpa-policies/section-sherpa-policies.component.scss @@ -1,35 +1,3 @@ -:host ::ng-deep { - .card { - border: none; - margin-bottom: 20px; - border-bottom: 1px solid rgba(0, 0, 0, 0.125); - - .card-header { - border: none; - background-color: transparent; - border-top: 1px solid rgba(0, 0, 0, 0.125); - - button { - text-align: left; - padding: 0px; - // width: auto; - font-weight: bold; - - .fas { - background: #207698; - color: #fff; - margin-right: 10px; - height: 1.25em; - display: flex; - align-items: center; - justify-content: center; - } - } - } - } - -} - .refresh-container { display: flex; justify-content: right; diff --git a/src/app/submission/sections/sherpa-policies/section-sherpa-policies.component.ts b/src/app/submission/sections/sherpa-policies/section-sherpa-policies.component.ts index 8e133224e9..3861bd1217 100644 --- a/src/app/submission/sections/sherpa-policies/section-sherpa-policies.component.ts +++ b/src/app/submission/sections/sherpa-policies/section-sherpa-policies.component.ts @@ -14,10 +14,9 @@ import { SectionsService } from '../sections.service'; import { SectionModelComponent } from '../models/section.model'; import { SubmissionService } from '../../submission.service'; import { hasValue, isEmpty } from '../../../shared/empty.util'; -import { debounce, debounceTime, timeInterval } from 'rxjs/operators'; /** - * This component represents a section for managing item's access conditions. + * This component represents a section for the sherpa policy informations structure. */ @Component({ selector: 'ds-section-sherpa-policies', diff --git a/src/assets/i18n/en.json5 b/src/assets/i18n/en.json5 index d9f6523ed4..9f5ba5c8b1 100644 --- a/src/assets/i18n/en.json5 +++ b/src/assets/i18n/en.json5 @@ -3894,6 +3894,10 @@ "submission.sections.status.warnings.aria": "has warnings", + "submission.sections.status.info.title": "Additional Information", + + "submission.sections.status.info.aria": "Additional Information", + "submission.sections.toggle.open": "Open section", "submission.sections.toggle.close": "Close section", @@ -4020,6 +4024,8 @@ "submission.sections.sherpa.publisher.policy.noembargo": "No Embargo", + "submission.sections.sherpa.publisher.policy.nolocation": "None", + "submission.sections.sherpa.publisher.policy.license": "License", "submission.sections.sherpa.publisher.policy.prerequisites": "Prerequisites", @@ -4042,11 +4048,6 @@ - - - - - "submission.submit.breadcrumbs": "New submission", "submission.submit.title": "New submission", From 268ee04d1e17532f1d79b7f4d95f207c61e270eb Mon Sep 17 00:00:00 2001 From: Rezart Vata Date: Mon, 23 May 2022 19:05:03 +0200 Subject: [PATCH 15/28] [CST-5270] Fixes requested as improvements --- .../publisher-policy/publisher-policy.component.html | 4 +++- .../publisher-policy/publisher-policy.component.ts | 8 ++++++++ .../section-sherpa-policies.component.html | 7 ++++++- .../section-sherpa-policies.component.ts | 10 +++++++++- src/assets/i18n/en.json5 | 2 ++ 5 files changed, 28 insertions(+), 3 deletions(-) diff --git a/src/app/submission/sections/sherpa-policies/publisher-policy/publisher-policy.component.html b/src/app/submission/sections/sherpa-policies/publisher-policy/publisher-policy.component.html index 24e3b09762..dc3cf8b737 100644 --- a/src/app/submission/sections/sherpa-policies/publisher-policy/publisher-policy.component.html +++ b/src/app/submission/sections/sherpa-policies/publisher-policy/publisher-policy.component.html @@ -2,7 +2,9 @@

- {{'submission.sections.sherpa.publisher.policy.openaccess' | translate}} + +

diff --git a/src/app/submission/sections/sherpa-policies/publisher-policy/publisher-policy.component.ts b/src/app/submission/sections/sherpa-policies/publisher-policy/publisher-policy.component.ts index 42d755d5b1..65d044f30c 100644 --- a/src/app/submission/sections/sherpa-policies/publisher-policy/publisher-policy.component.ts +++ b/src/app/submission/sections/sherpa-policies/publisher-policy/publisher-policy.component.ts @@ -1,6 +1,7 @@ import { Component, Input } from '@angular/core'; import { Policy } from '../../../../core/submission/models/sherpa-policies-details.model'; +import { AlertType } from './../../../../shared/alert/aletr-type'; /** * This component represents a section that contains the publisher policy informations. @@ -17,4 +18,11 @@ export class PublisherPolicyComponent { */ @Input() policy: Policy; + + /** + * The AlertType enumeration + * @type {AlertType} + */ + public AlertTypeEnum = AlertType; + } diff --git a/src/app/submission/sections/sherpa-policies/section-sherpa-policies.component.html b/src/app/submission/sections/sherpa-policies/section-sherpa-policies.component.html index 1ebcfc26c8..c135e0941a 100644 --- a/src/app/submission/sections/sherpa-policies/section-sherpa-policies.component.html +++ b/src/app/submission/sections/sherpa-policies/section-sherpa-policies.component.html @@ -8,7 +8,7 @@
- +
@@ -59,4 +59,9 @@
+ + + + \ No newline at end of file diff --git a/src/app/submission/sections/sherpa-policies/section-sherpa-policies.component.ts b/src/app/submission/sections/sherpa-policies/section-sherpa-policies.component.ts index 3861bd1217..e4bbebc617 100644 --- a/src/app/submission/sections/sherpa-policies/section-sherpa-policies.component.ts +++ b/src/app/submission/sections/sherpa-policies/section-sherpa-policies.component.ts @@ -1,3 +1,4 @@ +import { AlertType } from './../../../shared/alert/aletr-type'; import { Component, Inject, QueryList, ViewChildren } from '@angular/core'; import { BehaviorSubject, interval, Observable, of, Subscription } from 'rxjs'; @@ -49,6 +50,13 @@ export class SubmissionSectionSherpaPoliciesComponent extends SectionModelCompon */ public isCollapsed = false; + + /** + * The AlertType enumeration + * @type {AlertType} + */ + public AlertTypeEnum = AlertType; + /** * Initialize instance variables * @@ -71,6 +79,7 @@ export class SubmissionSectionSherpaPoliciesComponent extends SectionModelCompon * Unsubscribe from all subscriptions */ onSectionDestroy() { + this.subs .filter((subscription) => hasValue(subscription)) .forEach((subscription) => subscription.unsubscribe()); @@ -81,7 +90,6 @@ export class SubmissionSectionSherpaPoliciesComponent extends SectionModelCompon * Initialize all instance variables and retrieve collection default access conditions */ protected onSectionInit(): void { - this.pathCombiner = new JsonPatchOperationPathCombiner('sections', this.sectionData.id); this.subs.push( this.sectionService.getSectionData(this.submissionId, this.sectionData.id, this.sectionData.sectionType) diff --git a/src/assets/i18n/en.json5 b/src/assets/i18n/en.json5 index 9f5ba5c8b1..447af4dcf5 100644 --- a/src/assets/i18n/en.json5 +++ b/src/assets/i18n/en.json5 @@ -4046,6 +4046,8 @@ "submission.sections.sherpa.record.information.uri": "URI", + "submission.sections.sherpa.error.message": "There was an error retrieving sherpa informations", + "submission.submit.breadcrumbs": "New submission", From 87d015371cc476ce93ff88aaff57f445e13d69a0 Mon Sep 17 00:00:00 2001 From: Giuseppe Digilio Date: Tue, 24 May 2022 09:19:02 +0200 Subject: [PATCH 16/28] [CST-5270] use bootstrap classes --- .../sherpa-policies/section-sherpa-policies.component.html | 4 ++-- .../sherpa-policies/section-sherpa-policies.component.scss | 4 ---- 2 files changed, 2 insertions(+), 6 deletions(-) diff --git a/src/app/submission/sections/sherpa-policies/section-sherpa-policies.component.html b/src/app/submission/sections/sherpa-policies/section-sherpa-policies.component.html index c135e0941a..a7e024ee15 100644 --- a/src/app/submission/sections/sherpa-policies/section-sherpa-policies.component.html +++ b/src/app/submission/sections/sherpa-policies/section-sherpa-policies.component.html @@ -1,7 +1,7 @@ -
+
@@ -64,4 +64,4 @@ [content]="!!sherpaData.message ? sherpaData.message : 'submission.sections.sherpa.error.message'| translate"> - \ No newline at end of file + diff --git a/src/app/submission/sections/sherpa-policies/section-sherpa-policies.component.scss b/src/app/submission/sections/sherpa-policies/section-sherpa-policies.component.scss index c68df78fca..e69de29bb2 100644 --- a/src/app/submission/sections/sherpa-policies/section-sherpa-policies.component.scss +++ b/src/app/submission/sections/sherpa-policies/section-sherpa-policies.component.scss @@ -1,4 +0,0 @@ -.refresh-container { - display: flex; - justify-content: right; -} \ No newline at end of file From 53851ba18ee92f76cdbe07ae6904abf211c92ffa Mon Sep 17 00:00:00 2001 From: Rezart Vata Date: Tue, 24 May 2022 12:28:21 +0200 Subject: [PATCH 17/28] [CST-5270] Fix unit testing --- .../section-sherpa-policies.service.mock.ts | 180 +++++++++--------- .../shared/testing/sections-service.stub.ts | 1 + .../content-accordion.component.spec.ts | 9 + 3 files changed, 100 insertions(+), 90 deletions(-) diff --git a/src/app/shared/mocks/section-sherpa-policies.service.mock.ts b/src/app/shared/mocks/section-sherpa-policies.service.mock.ts index b4947ea5b4..9308325682 100644 --- a/src/app/shared/mocks/section-sherpa-policies.service.mock.ts +++ b/src/app/shared/mocks/section-sherpa-policies.service.mock.ts @@ -6,96 +6,96 @@ export const SherpaDataResponse = { 'id': 'sherpaPolicies', 'retrievalTime': '2022-04-20T09:44:39.870+00:00', 'sherpaResponse': - { - 'error': false, - 'message': null, - 'metadata': { - 'id': 23803, - 'uri': 'http://v2.sherpa.ac.uk/id/publication/23803', - 'dateCreated': '2012-11-20 14:51:52', - 'dateModified': '2020-03-06 11:25:54', - 'inDOAJ': false, - 'publiclyVisible': true + { + 'error': false, + 'message': null, + 'metadata': { + 'id': 23803, + 'uri': 'http://v2.sherpa.ac.uk/id/publication/23803', + 'dateCreated': '2012-11-20 14:51:52', + 'dateModified': '2020-03-06 11:25:54', + 'inDOAJ': false, + 'publiclyVisible': true + }, + 'journals': [{ + 'titles': ['The Lancet', 'Lancet'], + 'url': 'http://www.thelancet.com/journals/lancet/issue/current', + 'issns': ['0140-6736', '1474-547X'], + 'romeoPub': 'Elsevier: The Lancet', + 'zetoPub': 'Elsevier: The Lancet', + 'publisher': { + 'name': 'Elsevier', + 'relationshipType': null, + 'country': null, + 'uri': 'http://www.elsevier.com/', + 'identifier': null, + 'publicationCount': 0, + 'paidAccessDescription': 'Open access', + 'paidAccessUrl': 'https://www.elsevier.com/about/open-science/open-access' }, - 'journals': [{ - 'titles': ['The Lancet', 'Lancet'], - 'url': 'http://www.thelancet.com/journals/lancet/issue/current', - 'issns': ['0140-6736', '1474-547X'], - 'romeoPub': 'Elsevier: The Lancet', - 'zetoPub': 'Elsevier: The Lancet', - 'publisher': { - 'name': 'Elsevier', - 'relationshipType': null, - 'country': null, - 'uri': 'http://www.elsevier.com/', - 'identifier': null, - 'publicationCount': 0, - 'paidAccessDescription': 'Open access', - 'paidAccessUrl': 'https://www.elsevier.com/about/open-science/open-access' + 'publishers': [{ + 'name': 'Elsevier', + 'relationshipType': null, + 'country': null, + 'uri': 'http://www.elsevier.com/', + 'identifier': null, + 'publicationCount': 0, + 'paidAccessDescription': 'Open access', + 'paidAccessUrl': 'https://www.elsevier.com/about/open-science/open-access' + }], + 'policies': [{ + 'id': 0, + 'openAccessPermitted': false, + 'uri': null, + 'internalMoniker': 'Lancet', + 'permittedVersions': [{ + 'articleVersion': 'submitted', + 'option': 1, + 'conditions': ['Upon publication publisher copyright and source must be acknowledged', 'Upon publication must link to publisher version'], + 'prerequisites': [], + 'locations': ['Author\'s Homepage', 'Preprint Repository'], + 'licenses': [], + 'embargo': null + }, { + 'articleVersion': 'accepted', + 'option': 1, + 'conditions': ['Publisher copyright and source must be acknowledged', 'Must link to publisher version'], + 'prerequisites': [], + 'locations': ['Author\'s Homepage', 'Institutional Website'], + 'licenses': ['CC BY-NC-ND'], + 'embargo': null + }, { + 'articleVersion': 'accepted', + 'option': 2, + 'conditions': ['Publisher copyright and source must be acknowledged', 'Must link to publisher version'], + 'prerequisites': ['If Required by Funder'], + 'locations': ['Non-Commercial Repository'], + 'licenses': ['CC BY-NC-ND'], + 'embargo': { amount: 6, units: 'Months' } + }, { + 'articleVersion': 'accepted', + 'option': 3, + 'conditions': ['Publisher copyright and source must be acknowledged', 'Must link to publisher version'], + 'prerequisites': [], + 'locations': ['Non-Commercial Repository'], + 'licenses': [], + 'embargo': null + }], + 'urls': { + 'http://download.thelancet.com/flatcontentassets/authors/lancet-information-for-authors.pdf': 'Guidelines for Authors', + 'http://www.thelancet.com/journals/lancet/article/PIIS0140-6736%2813%2960720-5/fulltext': 'The Lancet journals welcome a new open access policy', + 'http://www.thelancet.com/lancet-information-for-authors/after-publication': 'What happens after publication?', + 'http://www.thelancet.com/lancet/information-for-authors/disclosure-of-results': 'Disclosure of results before publication', + 'https://www.elsevier.com/__data/assets/pdf_file/0005/78476/external-embargo-list.pdf': 'Journal Embargo Period List', + 'https://www.elsevier.com/__data/assets/pdf_file/0011/78473/UK-Embargo-Periods.pdf': 'Journal Embargo List for UK Authors' }, - 'publishers': [{ - 'name': 'Elsevier', - 'relationshipType': null, - 'country': null, - 'uri': 'http://www.elsevier.com/', - 'identifier': null, - 'publicationCount': 0, - 'paidAccessDescription': 'Open access', - 'paidAccessUrl': 'https://www.elsevier.com/about/open-science/open-access' - }], - 'policies': [{ - 'id': 0, - 'openAccessPermitted': false, - 'uri': null, - 'internalMoniker': 'Lancet', - 'permittedVersions': [{ - 'articleVersion': 'submitted', - 'option': 1, - 'conditions': ['Upon publication publisher copyright and source must be acknowledged', 'Upon publication must link to publisher version'], - 'prerequisites': [], - 'locations': ['Author\'s Homepage', 'Preprint Repository'], - 'licenses': [], - 'embargo': null - }, { - 'articleVersion': 'accepted', - 'option': 1, - 'conditions': ['Publisher copyright and source must be acknowledged', 'Must link to publisher version'], - 'prerequisites': [], - 'locations': ['Author\'s Homepage', 'Institutional Website'], - 'licenses': ['CC BY-NC-ND'], - 'embargo': null - }, { - 'articleVersion': 'accepted', - 'option': 2, - 'conditions': ['Publisher copyright and source must be acknowledged', 'Must link to publisher version'], - 'prerequisites': ['If Required by Funder'], - 'locations': ['Non-Commercial Repository'], - 'licenses': ['CC BY-NC-ND'], - 'embargo': null - }, { - 'articleVersion': 'accepted', - 'option': 3, - 'conditions': ['Publisher copyright and source must be acknowledged', 'Must link to publisher version'], - 'prerequisites': [], - 'locations': ['Non-Commercial Repository'], - 'licenses': [], - 'embargo': null - }], - 'urls': { - 'http://download.thelancet.com/flatcontentassets/authors/lancet-information-for-authors.pdf': 'Guidelines for Authors', - 'http://www.thelancet.com/journals/lancet/article/PIIS0140-6736%2813%2960720-5/fulltext': 'The Lancet journals welcome a new open access policy', - 'http://www.thelancet.com/lancet-information-for-authors/after-publication': 'What happens after publication?', - 'http://www.thelancet.com/lancet/information-for-authors/disclosure-of-results': 'Disclosure of results before publication', - 'https://www.elsevier.com/__data/assets/pdf_file/0005/78476/external-embargo-list.pdf': 'Journal Embargo Period List', - 'https://www.elsevier.com/__data/assets/pdf_file/0011/78473/UK-Embargo-Periods.pdf': 'Journal Embargo List for UK Authors' - }, - 'openAccessProhibited': false, - 'publicationCount': 0, - 'preArchiving': 'can', - 'postArchiving': 'can', - 'pubArchiving': 'cannot' - }], - 'inDOAJ': false - }] - } + 'openAccessProhibited': false, + 'publicationCount': 0, + 'preArchiving': 'can', + 'postArchiving': 'can', + 'pubArchiving': 'cannot' + }], + 'inDOAJ': false + }] + } } as WorkspaceitemSectionSherpaPoliciesObject; diff --git a/src/app/shared/testing/sections-service.stub.ts b/src/app/shared/testing/sections-service.stub.ts index 1628453bc8..b687c512c2 100644 --- a/src/app/shared/testing/sections-service.stub.ts +++ b/src/app/shared/testing/sections-service.stub.ts @@ -20,4 +20,5 @@ export class SectionsServiceStub { computeSectionConfiguredMetadata = jasmine.createSpy('computeSectionConfiguredMetadata'); getShownSectionErrors = jasmine.createSpy('getShownSectionErrors'); getSectionServerErrors = jasmine.createSpy('getSectionServerErrors'); + getIsInformational = jasmine.createSpy('getIsInformational'); } diff --git a/src/app/submission/sections/sherpa-policies/content-accordion/content-accordion.component.spec.ts b/src/app/submission/sections/sherpa-policies/content-accordion/content-accordion.component.spec.ts index b07674c40d..b65cb5e00f 100644 --- a/src/app/submission/sections/sherpa-policies/content-accordion/content-accordion.component.spec.ts +++ b/src/app/submission/sections/sherpa-policies/content-accordion/content-accordion.component.spec.ts @@ -34,6 +34,7 @@ describe('ContentAccordionComponent', () => { fixture = TestBed.createComponent(ContentAccordionComponent); component = fixture.componentInstance; de = fixture.debugElement; + component.isCollapsed = false; component.version = SherpaDataResponse.sherpaResponse.journals[0].policies[0].permittedVersions[0]; fixture.detectChanges(); }); @@ -42,7 +43,15 @@ describe('ContentAccordionComponent', () => { expect(component).toBeTruthy(); }); + it('should show 2 rows', () => { + component.version = SherpaDataResponse.sherpaResponse.journals[0].policies[0].permittedVersions[0]; + fixture.detectChanges(); + expect(de.queryAll(By.css('.row')).length).toEqual(2); + }); + it('should show 5 rows', () => { + component.version = SherpaDataResponse.sherpaResponse.journals[0].policies[0].permittedVersions[2]; + fixture.detectChanges(); expect(de.queryAll(By.css('.row')).length).toEqual(5); }); }); From 5842d83e915997048d023ab701764d003e74b4f7 Mon Sep 17 00:00:00 2001 From: Rezart Vata Date: Tue, 24 May 2022 12:34:44 +0200 Subject: [PATCH 18/28] [CST-5270] add class needed for unit testing --- .../sherpa-policies/section-sherpa-policies.component.html | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/app/submission/sections/sherpa-policies/section-sherpa-policies.component.html b/src/app/submission/sections/sherpa-policies/section-sherpa-policies.component.html index a7e024ee15..3372fe3005 100644 --- a/src/app/submission/sections/sherpa-policies/section-sherpa-policies.component.html +++ b/src/app/submission/sections/sherpa-policies/section-sherpa-policies.component.html @@ -1,7 +1,7 @@ -
+
@@ -64,4 +64,4 @@ [content]="!!sherpaData.message ? sherpaData.message : 'submission.sections.sherpa.error.message'| translate"> - + \ No newline at end of file From d1f8bb6d7b04035729875c5053de47ea0904fbf2 Mon Sep 17 00:00:00 2001 From: Giuseppe Digilio Date: Tue, 24 May 2022 16:05:21 +0200 Subject: [PATCH 19/28] [CST-5270] use data-test as css selector for unit test --- .../section-sherpa-policies.component.html | 6 +++--- .../section-sherpa-policies.component.spec.ts | 8 ++++---- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/app/submission/sections/sherpa-policies/section-sherpa-policies.component.html b/src/app/submission/sections/sherpa-policies/section-sherpa-policies.component.html index 3372fe3005..b7a42df702 100644 --- a/src/app/submission/sections/sherpa-policies/section-sherpa-policies.component.html +++ b/src/app/submission/sections/sherpa-policies/section-sherpa-policies.component.html @@ -1,8 +1,8 @@ -
-
@@ -64,4 +64,4 @@ [content]="!!sherpaData.message ? sherpaData.message : 'submission.sections.sherpa.error.message'| translate"> - \ No newline at end of file + diff --git a/src/app/submission/sections/sherpa-policies/section-sherpa-policies.component.spec.ts b/src/app/submission/sections/sherpa-policies/section-sherpa-policies.component.spec.ts index 30a50743b7..fe70f3e068 100644 --- a/src/app/submission/sections/sherpa-policies/section-sherpa-policies.component.spec.ts +++ b/src/app/submission/sections/sherpa-policies/section-sherpa-policies.component.spec.ts @@ -1,8 +1,8 @@ -import { SharedModule } from './../../../shared/shared.module'; +import { SharedModule } from '../../../shared/shared.module'; import { NgbCollapseModule } from '@ng-bootstrap/ng-bootstrap'; import { SubmissionServiceStub } from '../../../shared/testing/submission-service.stub'; import { SherpaDataResponse } from '../../../shared/mocks/section-sherpa-policies.service.mock'; -import { ComponentFixture, inject, TestBed, fakeAsync, tick } from '@angular/core/testing'; +import { ComponentFixture, inject, TestBed } from '@angular/core/testing'; import { SectionsService } from '../sections.service'; import { SectionsServiceStub } from '../../../shared/testing/sections-service.stub'; @@ -89,7 +89,7 @@ describe('SubmissionSectionSherpaPoliciesComponent', () => { }); it('should show refresh button', () => { - expect(de.query(By.css('.refresh-container > button'))).toBeTruthy(); + expect(de.query(By.css('[data-test="refresh-btn"]'))).toBeTruthy(); }); it('should show publisher information', () => { @@ -105,7 +105,7 @@ describe('SubmissionSectionSherpaPoliciesComponent', () => { }); it('when refresh button click operationsBuilder.remove should have been called', () => { - de.query(By.css('.refresh-container > button')).nativeElement.click(); + de.query(By.css('[data-test="refresh-btn"]')).nativeElement.click(); expect(operationsBuilder.remove).toHaveBeenCalled(); }); From 98b1667ca7ff5965dd5fa8889f32806aec8eed20 Mon Sep 17 00:00:00 2001 From: Giuseppe Digilio Date: Wed, 25 May 2022 09:24:14 +0200 Subject: [PATCH 20/28] [CST-5270] Fix LGTM alerts --- .../publisher-policy/publisher-policy.component.ts | 2 +- .../sherpa-policies/section-sherpa-policies.component.ts | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/app/submission/sections/sherpa-policies/publisher-policy/publisher-policy.component.ts b/src/app/submission/sections/sherpa-policies/publisher-policy/publisher-policy.component.ts index 65d044f30c..96ada3904c 100644 --- a/src/app/submission/sections/sherpa-policies/publisher-policy/publisher-policy.component.ts +++ b/src/app/submission/sections/sherpa-policies/publisher-policy/publisher-policy.component.ts @@ -1,7 +1,7 @@ import { Component, Input } from '@angular/core'; import { Policy } from '../../../../core/submission/models/sherpa-policies-details.model'; -import { AlertType } from './../../../../shared/alert/aletr-type'; +import { AlertType } from '../../../../shared/alert/aletr-type'; /** * This component represents a section that contains the publisher policy informations. diff --git a/src/app/submission/sections/sherpa-policies/section-sherpa-policies.component.ts b/src/app/submission/sections/sherpa-policies/section-sherpa-policies.component.ts index e4bbebc617..e55b75146f 100644 --- a/src/app/submission/sections/sherpa-policies/section-sherpa-policies.component.ts +++ b/src/app/submission/sections/sherpa-policies/section-sherpa-policies.component.ts @@ -1,7 +1,7 @@ -import { AlertType } from './../../../shared/alert/aletr-type'; -import { Component, Inject, QueryList, ViewChildren } from '@angular/core'; +import { AlertType } from '../../../shared/alert/aletr-type'; +import { Component, Inject } from '@angular/core'; -import { BehaviorSubject, interval, Observable, of, Subscription } from 'rxjs'; +import { BehaviorSubject, Observable, of, Subscription } from 'rxjs'; import { JsonPatchOperationPathCombiner } from '../../../core/json-patch/builder/json-patch-operation-path-combiner'; import { JsonPatchOperationsBuilder } from '../../../core/json-patch/builder/json-patch-operations-builder'; From d297eb708d247939f404d39ca660f4e30ce83679 Mon Sep 17 00:00:00 2001 From: Rezart Vata Date: Wed, 25 May 2022 18:20:13 +0200 Subject: [PATCH 21/28] [CST-5270] fix issue when no info --- .../sherpa-policies/section-sherpa-policies.component.html | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/app/submission/sections/sherpa-policies/section-sherpa-policies.component.html b/src/app/submission/sections/sherpa-policies/section-sherpa-policies.component.html index b7a42df702..2ec72f7935 100644 --- a/src/app/submission/sections/sherpa-policies/section-sherpa-policies.component.html +++ b/src/app/submission/sections/sherpa-policies/section-sherpa-policies.component.html @@ -8,7 +8,7 @@
- +
@@ -59,9 +59,9 @@
- + - + \ No newline at end of file From d75136408b2cb831caadfc2225b66abd07f70da9 Mon Sep 17 00:00:00 2001 From: Rezart Vata Date: Thu, 2 Jun 2022 12:49:53 +0200 Subject: [PATCH 22/28] [CST-5270] small fix for unit selection --- .../content-accordion/content-accordion.component.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/app/submission/sections/sherpa-policies/content-accordion/content-accordion.component.html b/src/app/submission/sections/sherpa-policies/content-accordion/content-accordion.component.html index 0b52c8341d..3d4fba5cea 100644 --- a/src/app/submission/sections/sherpa-policies/content-accordion/content-accordion.component.html +++ b/src/app/submission/sections/sherpa-policies/content-accordion/content-accordion.component.html @@ -10,7 +10,7 @@
{{version.embargo.amount}} - {{version.embargo.units[1]}} + {{version.embargo?.units[0]}} {{ 'submission.sections.sherpa.publisher.policy.noembargo' | translate }} From 3c6a41f82a273856807f6b51b379a601da661b70 Mon Sep 17 00:00:00 2001 From: Rezart Vata Date: Fri, 3 Jun 2022 17:49:15 +0200 Subject: [PATCH 23/28] [CST-5270] Improvement requested from pull-1633 --- .../container/section-container.component.html | 7 ++++--- .../container/section-container.component.scss | 10 +++++++++- .../publisher-policy.component.html | 9 --------- .../section-sherpa-policies.component.html | 17 ++++++++++++++--- .../section-sherpa-policies.component.scss | 3 +++ src/assets/i18n/en.json5 | 6 ++++-- 6 files changed, 34 insertions(+), 18 deletions(-) diff --git a/src/app/submission/sections/container/section-container.component.html b/src/app/submission/sections/container/section-container.component.html index 95ed9289c9..0d61bb42db 100644 --- a/src/app/submission/sections/container/section-container.component.html +++ b/src/app/submission/sections/container/section-container.component.html @@ -3,9 +3,10 @@ [submissionId]="submissionId" [sectionType]="sectionData.sectionType" [sectionId]="sectionData.id"> - + - {{ 'submission.sections.'+sectionData.header | translate + {{ + 'submission.sections.'+sectionData.header | translate }}
- -
-
-

- - -

-
-
diff --git a/src/app/submission/sections/sherpa-policies/section-sherpa-policies.component.html b/src/app/submission/sections/sherpa-policies/section-sherpa-policies.component.html index 2ec72f7935..aa6aed8bcf 100644 --- a/src/app/submission/sections/sherpa-policies/section-sherpa-policies.component.html +++ b/src/app/submission/sections/sherpa-policies/section-sherpa-policies.component.html @@ -1,7 +1,18 @@ - - + -
+
+ + {{'submission.sections.sherpa-policy.title-empty' | translate}} + +
+ +
+
+ + {{'submission.sections.sherpa.publisher.policy.description' | translate}} + +
diff --git a/src/app/submission/sections/sherpa-policies/section-sherpa-policies.component.scss b/src/app/submission/sections/sherpa-policies/section-sherpa-policies.component.scss index e69de29bb2..7aaa67e700 100644 --- a/src/app/submission/sections/sherpa-policies/section-sherpa-policies.component.scss +++ b/src/app/submission/sections/sherpa-policies/section-sherpa-policies.component.scss @@ -0,0 +1,3 @@ +.text-information-section { + flex: 1; +} \ No newline at end of file diff --git a/src/assets/i18n/en.json5 b/src/assets/i18n/en.json5 index 1f071ceacc..760724b595 100644 --- a/src/assets/i18n/en.json5 +++ b/src/assets/i18n/en.json5 @@ -4001,9 +4001,10 @@ "submission.sections.submit.progressbar.upload": "Upload files", + "submission.sections.submit.progressbar.sherpaPolicies": "Publisher open access policy information", - "submission.sections.sherpa-policy.title-empty": "No information available", + "submission.sections.sherpa-policy.title-empty": "No publisher policy information available. If your work has an associated ISSN, please enter it above to see any related publisher open access policies.", "submission.sections.status.errors.title": "Errors", @@ -4134,9 +4135,10 @@ "submission.sections.sherpa.publication.information.zetoPub": "Zeto Pub", - "submission.sections.sherpa.publisher.policy": "Publisher Policy", + "submission.sections.sherpa.publisher.policy.description": "The below information was found via Sherpa Romeo. Based on the policies of your publisher, it provides advice regarding whether an embargo may be necessary and/or which files you are allowed to upload. If you have questions, please contact your site administrator via the feedback form in the footer.", + "submission.sections.sherpa.publisher.policy.openaccess": "Open Access pathways permitted by this journal's policy are listed below by article version. Click on a pathway for a more detailed view", "submission.sections.sherpa.publisher.policy.more.information": "For more information, please see the following links:", From 6db5cff4262f47c054f2b7435a2a7785088d10b6 Mon Sep 17 00:00:00 2001 From: Rezart Vata Date: Fri, 3 Jun 2022 17:55:13 +0200 Subject: [PATCH 24/28] [CST-5270] fix testing --- .../publisher-policy/publisher-policy.component.spec.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/app/submission/sections/sherpa-policies/publisher-policy/publisher-policy.component.spec.ts b/src/app/submission/sections/sherpa-policies/publisher-policy/publisher-policy.component.spec.ts index da97f824b1..3e2c33481a 100644 --- a/src/app/submission/sections/sherpa-policies/publisher-policy/publisher-policy.component.spec.ts +++ b/src/app/submission/sections/sherpa-policies/publisher-policy/publisher-policy.component.spec.ts @@ -43,7 +43,7 @@ describe('PublisherPolicyComponent', () => { expect(de.query(By.css('ds-content-accordion'))).toBeTruthy(); }); - it('should show 2 rows', () => { - expect(de.queryAll(By.css('.row')).length).toEqual(2); + it('should show 1 row', () => { + expect(de.queryAll(By.css('.row')).length).toEqual(1); }); }); From 377214c9966995f22905224a6ebd844ff7d20b4f Mon Sep 17 00:00:00 2001 From: Rezart Vata Date: Mon, 6 Jun 2022 13:20:16 +0200 Subject: [PATCH 25/28] [CST-5270] Finished improvements --- .../container/section-container.component.html | 9 +++++---- .../container/section-container.component.scss | 8 -------- .../section-sherpa-policies.component.html | 14 ++++---------- 3 files changed, 9 insertions(+), 22 deletions(-) diff --git a/src/app/submission/sections/container/section-container.component.html b/src/app/submission/sections/container/section-container.component.html index 0d61bb42db..e6ae9d1b9c 100644 --- a/src/app/submission/sections/container/section-container.component.html +++ b/src/app/submission/sections/container/section-container.component.html @@ -3,9 +3,9 @@ [submissionId]="submissionId" [sectionType]="sectionData.sectionType" [sectionId]="sectionData.id"> - + - {{ + {{ 'submission.sections.'+sectionData.header | translate }}
@@ -21,13 +21,14 @@ class="fas fa-check-circle text-success mr-3" title="{{'submission.sections.status.valid.title' | translate}}" role="img" [attr.aria-label]="'submission.sections.status.valid.aria' | translate"> - - + - --> + + -
- - {{'submission.sections.sherpa-policy.title-empty' | translate}} - -
- -
+
{{'submission.sections.sherpa.publisher.policy.description' | translate}}
-
From dd049270a7e654098104c07f7ab454bb590707c6 Mon Sep 17 00:00:00 2001 From: Giuseppe Digilio Date: Mon, 6 Jun 2022 15:58:06 +0200 Subject: [PATCH 26/28] [CST-5270] add info alert for section info message --- .../section-sherpa-policies.component.html | 24 +++++++++---------- .../section-sherpa-policies.component.scss | 3 --- 2 files changed, 12 insertions(+), 15 deletions(-) diff --git a/src/app/submission/sections/sherpa-policies/section-sherpa-policies.component.html b/src/app/submission/sections/sherpa-policies/section-sherpa-policies.component.html index 56b28d5eda..4b636ee46e 100644 --- a/src/app/submission/sections/sherpa-policies/section-sherpa-policies.component.html +++ b/src/app/submission/sections/sherpa-policies/section-sherpa-policies.component.html @@ -1,22 +1,22 @@ -
-
- - {{'submission.sections.sherpa.publisher.policy.description' | translate}} - -
- +
-
+
-
+