Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,23 +1,25 @@
<p-card>
<div>
<h2>{{ 'preprints.preprintStepper.metadata.affiliatedInstitutionsTitle' | translate }}</h2>
<p
class="mt-3"
[innerHTML]="
'preprints.preprintStepper.metadata.affiliatedInstitutionsDescription'
| translate: { preprintWord: provider()?.preprintWord }
"
></p>

<div class="mt-4">
<osf-affiliated-institution-select
[institutions]="userInstitutions()"
[isLoading]="
areUserInstitutionsLoading() || areResourceInstitutionsLoading() || areResourceInstitutionsSubmitting()
@if (userInstitutions().length) {
<p-card>
<div>
<h2>{{ 'preprints.preprintStepper.metadata.affiliatedInstitutionsTitle' | translate }}</h2>
<p
class="mt-3"
[innerHTML]="
'preprints.preprintStepper.metadata.affiliatedInstitutionsDescription'
| translate: { preprintWord: provider()?.preprintWord }
"
[selectedInstitutions]="selectedInstitutions()"
(selectedInstitutionsChange)="onInstitutionsChange($event)"
/>
></p>

<div class="mt-4">
<osf-affiliated-institution-select
[institutions]="userInstitutions()"
[isLoading]="
areUserInstitutionsLoading() || areResourceInstitutionsLoading() || areResourceInstitutionsSubmitting()
"
[selectedInstitutions]="selectedInstitutions()"
(selectedInstitutionsChange)="onInstitutionsChange($event)"
/>
</div>
</div>
</div>
</p-card>
</p-card>
}
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import {
FetchPreprintProject,
PreprintStepperSelectors,
SubmitPreprint,
UpdatePreprint,
UpdatePrimaryFileRelationship,
} from '@osf/features/preprints/store/preprint-stepper';
import {
Expand Down Expand Up @@ -66,6 +67,7 @@ export class ReviewStepComponent implements OnInit {
submitPreprint: SubmitPreprint,
fetchResourceInstitutions: FetchResourceInstitutions,
updatePrimaryFileRelationship: UpdatePrimaryFileRelationship,
updatePreprint: UpdatePreprint,
});

provider = input.required<PreprintProviderDetails | undefined>();
Expand Down Expand Up @@ -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();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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());
Expand Down Expand Up @@ -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;
}
}
1 change: 1 addition & 0 deletions src/app/features/preprints/services/preprints.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand Down Expand Up @@ -497,6 +501,7 @@ export class PreprintStepperState {
submitPreprint(ctx: StateContext<PreprintStepperStateModel>) {
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 }));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,23 +2,21 @@
<p-skeleton width="100%" height="3.2rem" />
} @else {
<div class="flex flex-column gap-2">
<div class="relative">
<div class="flex gap-4 absolute top-0 right-0">
<p-button
severity="secondary"
[label]="'myProjects.createProject.affiliation.selectAll' | translate"
[disabled]="isSelectAllDisabled()"
(onClick)="selectAll()"
(keydown.enter)="selectAll()"
/>
<p-button
severity="secondary"
[label]="'myProjects.createProject.affiliation.removeAll' | translate"
[disabled]="isRemoveAllDisabled()"
(onClick)="removeAll()"
(keydown.enter)="removeAll()"
/>
</div>
<div class="flex gap-4">
<p-button
severity="secondary"
[label]="'myProjects.createProject.affiliation.selectAll' | translate"
[disabled]="isSelectAllDisabled()"
(onClick)="selectAll()"
(keydown.enter)="selectAll()"
/>
<p-button
severity="secondary"
[label]="'myProjects.createProject.affiliation.removeAll' | translate"
[disabled]="isRemoveAllDisabled()"
(onClick)="removeAll()"
(keydown.enter)="removeAll()"
/>
</div>

<div class="flex gap-2" role="group" aria-label="Affiliations">
Expand Down
Loading