From c3eee8d0415b792584d905b59053f3e11f610803 Mon Sep 17 00:00:00 2001 From: nsemets Date: Tue, 21 Oct 2025 16:43:39 +0300 Subject: [PATCH] fix(preprints): added check for review workflow null --- ...nts-affiliated-institutions.component.html | 44 ++++++++++--------- .../review-step/review-step.component.ts | 6 +++ .../create-new-version.component.ts | 12 ++--- .../preprints/services/preprints.service.ts | 1 + .../preprint-stepper.state.ts | 5 +++ ...filiated-institution-select.component.html | 32 +++++++------- 6 files changed, 56 insertions(+), 44 deletions(-) diff --git a/src/app/features/preprints/components/stepper/preprints-metadata-step/preprints-affiliated-institutions/preprints-affiliated-institutions.component.html b/src/app/features/preprints/components/stepper/preprints-metadata-step/preprints-affiliated-institutions/preprints-affiliated-institutions.component.html index f8611ac37..090082de5 100644 --- a/src/app/features/preprints/components/stepper/preprints-metadata-step/preprints-affiliated-institutions/preprints-affiliated-institutions.component.html +++ b/src/app/features/preprints/components/stepper/preprints-metadata-step/preprints-affiliated-institutions/preprints-affiliated-institutions.component.html @@ -1,23 +1,25 @@ - -
-

{{ 'preprints.preprintStepper.metadata.affiliatedInstitutionsTitle' | translate }}

-

- -
- + >

+ +
+ +
-
-
+ +} diff --git a/src/app/features/preprints/components/stepper/review-step/review-step.component.ts b/src/app/features/preprints/components/stepper/review-step/review-step.component.ts index 8ea0371d7..132fa9dde 100644 --- a/src/app/features/preprints/components/stepper/review-step/review-step.component.ts +++ b/src/app/features/preprints/components/stepper/review-step/review-step.component.ts @@ -20,6 +20,7 @@ import { FetchPreprintProject, PreprintStepperSelectors, SubmitPreprint, + UpdatePreprint, UpdatePrimaryFileRelationship, } from '@osf/features/preprints/store/preprint-stepper'; import { @@ -66,6 +67,7 @@ export class ReviewStepComponent implements OnInit { submitPreprint: SubmitPreprint, fetchResourceInstitutions: FetchResourceInstitutions, updatePrimaryFileRelationship: UpdatePrimaryFileRelationship, + updatePreprint: UpdatePreprint, }); provider = input.required(); @@ -101,6 +103,10 @@ export class ReviewStepComponent implements OnInit { .updatePrimaryFileRelationship(preprintFile?.id ?? preprint.primaryFileId) .pipe( switchMap(() => { + if (!this.provider()?.reviewsWorkflow) { + return this.actions.updatePreprint(preprint.id, { isPublished: true }); + } + if (preprint.reviewsState !== ReviewsState.Accepted) { return this.actions.submitPreprint(); } diff --git a/src/app/features/preprints/pages/create-new-version/create-new-version.component.ts b/src/app/features/preprints/pages/create-new-version/create-new-version.component.ts index c56f1c596..8a6b43c3a 100644 --- a/src/app/features/preprints/pages/create-new-version/create-new-version.component.ts +++ b/src/app/features/preprints/pages/create-new-version/create-new-version.component.ts @@ -85,6 +85,12 @@ export class CreateNewVersionComponent implements OnInit, OnDestroy, CanDeactiva }); } + @HostListener('window:beforeunload', ['$event']) + onBeforeUnload($event: BeforeUnloadEvent): boolean { + $event.preventDefault(); + return false; + } + ngOnInit() { this.actions.getPreprintProviderById(this.providerId()); this.actions.fetchPreprint(this.preprintId()); @@ -118,10 +124,4 @@ export class CreateNewVersionComponent implements OnInit, OnDestroy, CanDeactiva const id = this.preprintId().split('_')[0]; this.router.navigate([id]); } - - @HostListener('window:beforeunload', ['$event']) - public onBeforeUnload($event: BeforeUnloadEvent): boolean { - $event.preventDefault(); - return false; - } } diff --git a/src/app/features/preprints/services/preprints.service.ts b/src/app/features/preprints/services/preprints.service.ts index f65ad8ef1..bbb327aed 100644 --- a/src/app/features/preprints/services/preprints.service.ts +++ b/src/app/features/preprints/services/preprints.service.ts @@ -52,6 +52,7 @@ export class PreprintsService { preregLinks: 'prereg_links', whyNoPrereg: 'why_no_prereg', preregLinkInfo: 'prereg_link_info', + isPublished: 'is_published', }; createPreprint(title: string, abstract: string, providerId: string) { diff --git a/src/app/features/preprints/store/preprint-stepper/preprint-stepper.state.ts b/src/app/features/preprints/store/preprint-stepper/preprint-stepper.state.ts index b7ce8fb31..35cb73caf 100644 --- a/src/app/features/preprints/store/preprint-stepper/preprint-stepper.state.ts +++ b/src/app/features/preprints/store/preprint-stepper/preprint-stepper.state.ts @@ -134,6 +134,10 @@ export class PreprintStepperState { return this.preprintsService.updatePreprint(action.id, action.payload).pipe( tap((preprint) => { + if (action.payload.isPublished) { + ctx.setState(patch({ hasBeenSubmitted: true })); + } + ctx.setState(patch({ preprint: patch({ isSubmitting: false, data: preprint }) })); }), catchError((error) => handleSectionError(ctx, 'preprint', error)) @@ -497,6 +501,7 @@ export class PreprintStepperState { submitPreprint(ctx: StateContext) { const createdPreprintId = ctx.getState().preprint.data!.id; ctx.setState(patch({ preprint: patch({ isSubmitting: true }) })); + return this.preprintsService.submitPreprint(createdPreprintId).pipe( tap(() => { ctx.setState(patch({ preprint: patch({ isSubmitting: false }), hasBeenSubmitted: true })); diff --git a/src/app/shared/components/affiliated-institution-select/affiliated-institution-select.component.html b/src/app/shared/components/affiliated-institution-select/affiliated-institution-select.component.html index f40a6da50..bed10a3a0 100644 --- a/src/app/shared/components/affiliated-institution-select/affiliated-institution-select.component.html +++ b/src/app/shared/components/affiliated-institution-select/affiliated-institution-select.component.html @@ -2,23 +2,21 @@ } @else {
-
-
- - -
+
+ +