From 2fa12b6ceaab3c83ab1a2e00ff3856d65d58b44d Mon Sep 17 00:00:00 2001 From: Roma Date: Thu, 2 Oct 2025 15:43:43 +0300 Subject: [PATCH 1/4] fix(preprint-stepper): Selecting all institutions by default --- .../preprint-submission-item.component.html | 2 +- .../registry-submission-item.component.html | 2 +- ...rints-affiliated-institutions.component.ts | 23 +++++++++++++++---- .../preprints-metadata-step.component.html | 2 +- .../preprint-stepper.actions.ts | 8 ++++++- .../preprint-stepper.model.ts | 1 + .../preprint-stepper.selectors.ts | 5 ++++ .../preprint-stepper.state.ts | 7 ++++++ .../store/preprint/preprint.state.ts | 9 ++++---- .../registry-make-decision.component.html | 2 +- 10 files changed, 46 insertions(+), 15 deletions(-) diff --git a/src/app/features/moderation/components/preprint-submission-item/preprint-submission-item.component.html b/src/app/features/moderation/components/preprint-submission-item/preprint-submission-item.component.html index 9c19352c6..318026f85 100644 --- a/src/app/features/moderation/components/preprint-submission-item/preprint-submission-item.component.html +++ b/src/app/features/moderation/components/preprint-submission-item/preprint-submission-item.component.html @@ -15,7 +15,7 @@ {{ actionLabel[action.toState] | translate }} {{ action.dateModified | dateAgo }} {{ 'moderation.submissionReview.by' | translate }} - {{ action.creator.name }} + {{ action.creator?.name }} @if (action.comment.length) { - {{ action.comment }} diff --git a/src/app/features/moderation/components/registry-submission-item/registry-submission-item.component.html b/src/app/features/moderation/components/registry-submission-item/registry-submission-item.component.html index 4e07e2027..b6cfcac27 100644 --- a/src/app/features/moderation/components/registry-submission-item/registry-submission-item.component.html +++ b/src/app/features/moderation/components/registry-submission-item/registry-submission-item.component.html @@ -31,7 +31,7 @@

{{ submission().title }}

{{ registryActionLabel[action.toState] | translate }} {{ action.dateModified | dateAgo }} {{ 'moderation.submissionReview.by' | translate }} - {{ action.creator.name }} + {{ action.creator?.name }} @if (action.toState === registryActionState.Accepted) { {{ 'moderation.withNoEmbargo' | translate }} diff --git a/src/app/features/preprints/components/stepper/preprints-metadata-step/preprints-affiliated-institutions/preprints-affiliated-institutions.component.ts b/src/app/features/preprints/components/stepper/preprints-metadata-step/preprints-affiliated-institutions/preprints-affiliated-institutions.component.ts index 1d456a86b..4d57e1de4 100644 --- a/src/app/features/preprints/components/stepper/preprints-metadata-step/preprints-affiliated-institutions/preprints-affiliated-institutions.component.ts +++ b/src/app/features/preprints/components/stepper/preprints-metadata-step/preprints-affiliated-institutions/preprints-affiliated-institutions.component.ts @@ -6,7 +6,9 @@ import { Card } from 'primeng/card'; import { ChangeDetectionStrategy, Component, effect, input, OnInit, signal } from '@angular/core'; -import { PreprintProviderDetails } from '@osf/features/preprints/models'; +import { ReviewsState } from '@osf/features/preprints/enums'; +import { Preprint, PreprintProviderDetails } from '@osf/features/preprints/models'; +import { PreprintStepperSelectors, SetInstitutionsChanged } from '@osf/features/preprints/store/preprint-stepper'; import { AffiliatedInstitutionSelectComponent } from '@osf/shared/components'; import { ResourceType } from '@osf/shared/enums'; import { Institution } from '@osf/shared/models'; @@ -26,7 +28,7 @@ import { }) export class PreprintsAffiliatedInstitutionsComponent implements OnInit { provider = input.required(); - preprintId = input(); + preprint = input.required(); selectedInstitutions = signal([]); @@ -35,11 +37,13 @@ export class PreprintsAffiliatedInstitutionsComponent implements OnInit { resourceInstitutions = select(InstitutionsSelectors.getResourceInstitutions); areResourceInstitutionsLoading = select(InstitutionsSelectors.areResourceInstitutionsLoading); areResourceInstitutionsSubmitting = select(InstitutionsSelectors.areResourceInstitutionsSubmitting); + institutionsChanged = select(PreprintStepperSelectors.getInstitutionsChanged); private readonly actions = createDispatchMap({ fetchUserInstitutions: FetchUserInstitutions, fetchResourceInstitutions: FetchResourceInstitutions, updateResourceInstitutions: UpdateResourceInstitutions, + setInstitutionsChanged: SetInstitutionsChanged, }); constructor() { @@ -49,15 +53,24 @@ export class PreprintsAffiliatedInstitutionsComponent implements OnInit { this.selectedInstitutions.set([...resourceInstitutions]); } }); + + effect(() => { + const userInstitutions = this.userInstitutions(); + const isCreateFlow = this.preprint()?.reviewsState === ReviewsState.Initial; + + if (userInstitutions.length > 0 && isCreateFlow && !this.institutionsChanged()) { + this.actions.setInstitutionsChanged(true); + this.onInstitutionsChange(userInstitutions); + } + }); } ngOnInit() { this.actions.fetchUserInstitutions(); - this.actions.fetchResourceInstitutions(this.preprintId()!, ResourceType.Preprint); + this.actions.fetchResourceInstitutions(this.preprint()!.id, ResourceType.Preprint); } onInstitutionsChange(institutions: Institution[]): void { - this.selectedInstitutions.set(institutions); - this.actions.updateResourceInstitutions(this.preprintId()!, ResourceType.Preprint, institutions); + this.actions.updateResourceInstitutions(this.preprint()!.id, ResourceType.Preprint, institutions); } } diff --git a/src/app/features/preprints/components/stepper/preprints-metadata-step/preprints-metadata-step.component.html b/src/app/features/preprints/components/stepper/preprints-metadata-step/preprints-metadata-step.component.html index dec11eca6..67e0dd488 100644 --- a/src/app/features/preprints/components/stepper/preprints-metadata-step/preprints-metadata-step.component.html +++ b/src/app/features/preprints/components/stepper/preprints-metadata-step/preprints-metadata-step.component.html @@ -24,7 +24,7 @@

{{ 'shared.license.title' | translate }}

- +
diff --git a/src/app/features/preprints/store/preprint-stepper/preprint-stepper.actions.ts b/src/app/features/preprints/store/preprint-stepper/preprint-stepper.actions.ts index 7bb5f5720..6dffe263b 100644 --- a/src/app/features/preprints/store/preprint-stepper/preprint-stepper.actions.ts +++ b/src/app/features/preprints/store/preprint-stepper/preprint-stepper.actions.ts @@ -148,7 +148,13 @@ export class DeletePreprint { } export class SetCurrentFolder { - static readonly type = '[Submit Preprint] Set Current Folder'; + static readonly type = '[Preprint Stepper] Set Current Folder'; constructor(public folder: OsfFile | null) {} } + +export class SetInstitutionsChanged { + static readonly type = '[Preprint Stepper] Set Institutions Changed'; + + constructor(public institutionsChanged: boolean) {} +} diff --git a/src/app/features/preprints/store/preprint-stepper/preprint-stepper.model.ts b/src/app/features/preprints/store/preprint-stepper/preprint-stepper.model.ts index f760130c0..49863430d 100644 --- a/src/app/features/preprints/store/preprint-stepper/preprint-stepper.model.ts +++ b/src/app/features/preprints/store/preprint-stepper/preprint-stepper.model.ts @@ -16,4 +16,5 @@ export interface PreprintStepperStateModel { currentFolder: OsfFile | null; preprintProject: AsyncStateModel; hasBeenSubmitted: boolean; + institutionsChanged: boolean; } diff --git a/src/app/features/preprints/store/preprint-stepper/preprint-stepper.selectors.ts b/src/app/features/preprints/store/preprint-stepper/preprint-stepper.selectors.ts index b2c8852dc..c4195b83d 100644 --- a/src/app/features/preprints/store/preprint-stepper/preprint-stepper.selectors.ts +++ b/src/app/features/preprints/store/preprint-stepper/preprint-stepper.selectors.ts @@ -87,4 +87,9 @@ export class PreprintStepperSelectors { static getCurrentFolder(state: PreprintStepperStateModel) { return state.currentFolder; } + + @Selector([PreprintStepperState]) + static getInstitutionsChanged(state: PreprintStepperStateModel) { + return state.institutionsChanged; + } } 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 1d9d31541..38e4e7dd4 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 @@ -40,6 +40,7 @@ import { ReuploadFile, SaveLicense, SetCurrentFolder, + SetInstitutionsChanged, SetSelectedPreprintFileSource, SetSelectedPreprintProviderId, SubmitPreprint, @@ -89,6 +90,7 @@ const DefaultState: PreprintStepperStateModel = { }, hasBeenSubmitted: false, currentFolder: null, + institutionsChanged: false, }; @State({ @@ -525,4 +527,9 @@ export class PreprintStepperState { setCurrentFolder(ctx: StateContext, action: SetCurrentFolder) { ctx.patchState({ currentFolder: action.folder }); } + + @Action(SetInstitutionsChanged) + setInstitutionsChanged(ctx: StateContext, action: SetInstitutionsChanged) { + ctx.patchState({ institutionsChanged: action.institutionsChanged }); + } } diff --git a/src/app/features/preprints/store/preprint/preprint.state.ts b/src/app/features/preprints/store/preprint/preprint.state.ts index f68e61b83..4e7a27651 100644 --- a/src/app/features/preprints/store/preprint/preprint.state.ts +++ b/src/app/features/preprints/store/preprint/preprint.state.ts @@ -1,4 +1,4 @@ -import { Action, State, StateContext, Store } from '@ngxs/store'; +import { Action, State, StateContext } from '@ngxs/store'; import { append, patch } from '@ngxs/store/operators'; import { tap } from 'rxjs'; @@ -32,7 +32,6 @@ import { DefaultState, PreprintStateModel } from './preprint.model'; }) @Injectable() export class PreprintState { - private store = inject(Store); private preprintsService = inject(PreprintsService); private fileService = inject(FilesService); @@ -73,9 +72,9 @@ export class PreprintState { tap((preprint) => { ctx.setState(patch({ preprint: patch({ isLoading: false, data: preprint }) })); if (!preprint.dateWithdrawn) { - this.store.dispatch(new FetchPreprintFile()); + ctx.dispatch(new FetchPreprintFile()); } - this.store.dispatch(new FetchPreprintVersionIds()); + ctx.dispatch(new FetchPreprintVersionIds()); }), catchError((error) => handleSectionError(ctx, 'preprint', error)) ); @@ -90,7 +89,7 @@ export class PreprintState { return this.fileService.getFileById(preprintFileId!).pipe( tap((file) => { ctx.setState(patch({ preprintFile: patch({ isLoading: false, data: file }) })); - this.store.dispatch(new FetchPreprintFileVersions()); + ctx.dispatch(new FetchPreprintFileVersions()); }), catchError((error) => handleSectionError(ctx, 'preprintFile', error)) ); diff --git a/src/app/features/registry/components/registry-make-decision/registry-make-decision.component.html b/src/app/features/registry/components/registry-make-decision/registry-make-decision.component.html index 8b4e8c8c0..67a1aa5c9 100644 --- a/src/app/features/registry/components/registry-make-decision/registry-make-decision.component.html +++ b/src/app/features/registry/components/registry-make-decision/registry-make-decision.component.html @@ -14,7 +14,7 @@ } {{ action.dateModified | dateAgo }} {{ 'moderation.submissionReview.by' | translate }} - {{ action.creator.name }} + {{ action.creator?.name }} @if (embargoEndDate) { {{ 'moderation.submissionReview.embargoEnding' | translate }} {{ embargoEndDate | date: 'shortDate' }} From 00effe45db098e7a81d14d841c8d828e7279307b Mon Sep 17 00:00:00 2001 From: Roma Date: Thu, 2 Oct 2025 15:48:43 +0300 Subject: [PATCH 2/4] fix(resource-card): Made data-resources urls open in a new tab --- .../data-resources/data-resources.component.html | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/app/shared/components/data-resources/data-resources.component.html b/src/app/shared/components/data-resources/data-resources.component.html index 1dd648d0d..b7a706e9e 100644 --- a/src/app/shared/components/data-resources/data-resources.component.html +++ b/src/app/shared/components/data-resources/data-resources.component.html @@ -1,12 +1,12 @@
- +

{{ 'resourceCard.resources.data' | translate }}

- + + +

{{ 'resourceCard.resources.papers' | translate }}

- +

{{ 'preprints.details.originalPublicationDate' | translate }}

- {{ preprintValue.originalPublicationDate | date: 'MMM d, y, h:mm a' }} + {{ preprintValue.originalPublicationDate | date: 'MMMM d, y' }} } From 82c2686a8cd1628b293c55a78a4c18fef02f5e61 Mon Sep 17 00:00:00 2001 From: Roma Date: Thu, 2 Oct 2025 16:15:19 +0300 Subject: [PATCH 4/4] fix(global-search-filters): Using the deepest property path label for filter --- src/app/shared/mappers/filters/filters.mapper.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/app/shared/mappers/filters/filters.mapper.ts b/src/app/shared/mappers/filters/filters.mapper.ts index 5c4e721e5..05e104a93 100644 --- a/src/app/shared/mappers/filters/filters.mapper.ts +++ b/src/app/shared/mappers/filters/filters.mapper.ts @@ -22,7 +22,7 @@ export function MapFilters(indexCardSearchResponseJsonApi: IndexCardSearchRespon export function RelatedPropertyPathMapper(relatedPropertyPath: RelatedPropertyPathDataJsonApi): DiscoverableFilter { const key = relatedPropertyPath.attributes.propertyPathKey; const operator = relatedPropertyPath.attributes.suggestedFilterOperator as FilterOperator; - const propertyPath = relatedPropertyPath.attributes.propertyPath?.[0]; + const propertyPath = relatedPropertyPath.attributes.propertyPath?.at(-1); const label = propertyPath?.displayLabel?.[0]?.['@value'] ?? key; const description = propertyPath?.description?.[0]?.['@value'];