From 35582794ddf4095728d84c41bc0aa623d12c7b89 Mon Sep 17 00:00:00 2001 From: NazarMykhalkevych Date: Mon, 8 Sep 2025 22:54:55 +0300 Subject: [PATCH] fix(redirect): fixed redirect after registration --- .../justification-review.component.ts | 4 +- .../justification-step.component.ts | 2 +- .../metadata/metadata.component.html | 1 + .../components/metadata/metadata.component.ts | 2 + ...ries-affiliated-institution.component.html | 18 +++++++ ...ries-affiliated-institution.component.scss | 0 ...s-affiliated-institution.component.spec.ts | 22 +++++++++ ...stries-affiliated-institution.component.ts | 47 +++++++++++++++++++ .../components/review/review.component.ts | 2 +- .../shared/services/institutions.service.ts | 1 + src/assets/i18n/en.json | 1 + 11 files changed, 96 insertions(+), 4 deletions(-) create mode 100644 src/app/features/registries/components/metadata/registries-affiliated-institution/registries-affiliated-institution.component.html create mode 100644 src/app/features/registries/components/metadata/registries-affiliated-institution/registries-affiliated-institution.component.scss create mode 100644 src/app/features/registries/components/metadata/registries-affiliated-institution/registries-affiliated-institution.component.spec.ts create mode 100644 src/app/features/registries/components/metadata/registries-affiliated-institution/registries-affiliated-institution.component.ts diff --git a/src/app/features/registries/components/justification-review/justification-review.component.ts b/src/app/features/registries/components/justification-review/justification-review.component.ts index 902859c73..bba04e1a0 100644 --- a/src/app/features/registries/components/justification-review/justification-review.component.ts +++ b/src/app/features/registries/components/justification-review/justification-review.component.ts @@ -109,7 +109,7 @@ export class JustificationReviewComponent { next: () => { this.toastService.showSuccess('registries.justification.successDeleteDraft'); this.actions.clearState(); - this.router.navigateByUrl(`/registries/${registrationId}/overview`); + this.router.navigateByUrl(`/${registrationId}/overview`); }, }); }, @@ -120,7 +120,7 @@ export class JustificationReviewComponent { this.actions.handleSchemaResponse(this.revisionId, SchemaActionTrigger.Approve).subscribe({ next: () => { this.toastService.showSuccess('registries.justification.successAccept'); - this.router.navigateByUrl(`/registries/${this.schemaResponse()?.registrationId}/overview`); + this.router.navigateByUrl(`/${this.schemaResponse()?.registrationId}/overview`); }, }); } diff --git a/src/app/features/registries/components/justification-step/justification-step.component.ts b/src/app/features/registries/components/justification-step/justification-step.component.ts index 9122fa622..13e523d07 100644 --- a/src/app/features/registries/components/justification-step/justification-step.component.ts +++ b/src/app/features/registries/components/justification-step/justification-step.component.ts @@ -97,7 +97,7 @@ export class JustificationStepComponent implements OnDestroy { this.isDraftDeleted = true; this.actions.clearState(); this.toastService.showSuccess('registries.justification.successDeleteDraft'); - this.router.navigateByUrl(`/registries/${registrationId}/overview`); + this.router.navigateByUrl(`/${registrationId}/overview`); }, }); }, diff --git a/src/app/features/registries/components/metadata/metadata.component.html b/src/app/features/registries/components/metadata/metadata.component.html index 4adf7ea04..c877f627a 100644 --- a/src/app/features/registries/components/metadata/metadata.component.html +++ b/src/app/features/registries/components/metadata/metadata.component.html @@ -33,6 +33,7 @@

{{ 'registries.metadata.title' | translate }}

+ diff --git a/src/app/features/registries/components/metadata/metadata.component.ts b/src/app/features/registries/components/metadata/metadata.component.ts index 3e3031fd8..a07c22f01 100644 --- a/src/app/features/registries/components/metadata/metadata.component.ts +++ b/src/app/features/registries/components/metadata/metadata.component.ts @@ -23,6 +23,7 @@ import { ContributorsSelectors, SubjectsSelectors } from '@osf/shared/stores'; import { ClearState, DeleteDraft, RegistriesSelectors, UpdateDraft, UpdateStepValidation } from '../../store'; import { ContributorsComponent } from './contributors/contributors.component'; +import { RegistriesAffiliatedInstitutionComponent } from './registries-affiliated-institution/registries-affiliated-institution.component'; import { RegistriesLicenseComponent } from './registries-license/registries-license.component'; import { RegistriesSubjectsComponent } from './registries-subjects/registries-subjects.component'; import { RegistriesTagsComponent } from './registries-tags/registries-tags.component'; @@ -40,6 +41,7 @@ import { RegistriesTagsComponent } from './registries-tags/registries-tags.compo RegistriesSubjectsComponent, RegistriesTagsComponent, RegistriesLicenseComponent, + RegistriesAffiliatedInstitutionComponent, Message, ], templateUrl: './metadata.component.html', diff --git a/src/app/features/registries/components/metadata/registries-affiliated-institution/registries-affiliated-institution.component.html b/src/app/features/registries/components/metadata/registries-affiliated-institution/registries-affiliated-institution.component.html new file mode 100644 index 000000000..529dd73f8 --- /dev/null +++ b/src/app/features/registries/components/metadata/registries-affiliated-institution/registries-affiliated-institution.component.html @@ -0,0 +1,18 @@ + +
+

{{ 'project.overview.metadata.affiliatedInstitutions' | translate }}

+

+ {{ 'project.overview.metadata.affiliatedInstitutionsDescription' | translate }} +

+ @if (userInstitutions().length) { +
+ +
+ } @else { +

{{ 'project.overview.metadata.noAffiliatedInstitutions' | translate }}

+ } +
+
diff --git a/src/app/features/registries/components/metadata/registries-affiliated-institution/registries-affiliated-institution.component.scss b/src/app/features/registries/components/metadata/registries-affiliated-institution/registries-affiliated-institution.component.scss new file mode 100644 index 000000000..e69de29bb diff --git a/src/app/features/registries/components/metadata/registries-affiliated-institution/registries-affiliated-institution.component.spec.ts b/src/app/features/registries/components/metadata/registries-affiliated-institution/registries-affiliated-institution.component.spec.ts new file mode 100644 index 000000000..425c0d8af --- /dev/null +++ b/src/app/features/registries/components/metadata/registries-affiliated-institution/registries-affiliated-institution.component.spec.ts @@ -0,0 +1,22 @@ +import { ComponentFixture, TestBed } from '@angular/core/testing'; + +import { RegistriesAffiliatedInstitutionComponent } from './registries-affiliated-institution.component'; + +describe.skip('RegistriesAffiliatedInstitutionComponent', () => { + let component: RegistriesAffiliatedInstitutionComponent; + let fixture: ComponentFixture; + + beforeEach(async () => { + await TestBed.configureTestingModule({ + imports: [RegistriesAffiliatedInstitutionComponent], + }).compileComponents(); + + fixture = TestBed.createComponent(RegistriesAffiliatedInstitutionComponent); + component = fixture.componentInstance; + fixture.detectChanges(); + }); + + it('should create', () => { + expect(component).toBeTruthy(); + }); +}); diff --git a/src/app/features/registries/components/metadata/registries-affiliated-institution/registries-affiliated-institution.component.ts b/src/app/features/registries/components/metadata/registries-affiliated-institution/registries-affiliated-institution.component.ts new file mode 100644 index 000000000..b0162d55a --- /dev/null +++ b/src/app/features/registries/components/metadata/registries-affiliated-institution/registries-affiliated-institution.component.ts @@ -0,0 +1,47 @@ +import { createDispatchMap, select } from '@ngxs/store'; + +import { TranslatePipe } from '@ngx-translate/core'; + +import { Card } from 'primeng/card'; + +import { ChangeDetectionStrategy, Component, inject, OnInit } from '@angular/core'; +import { ActivatedRoute } from '@angular/router'; + +import { AffiliatedInstitutionSelectComponent } from '@osf/shared/components'; +import { ResourceType } from '@osf/shared/enums'; +import { Institution } from '@osf/shared/models'; +import { + FetchResourceInstitutions, + FetchUserInstitutions, + InstitutionsSelectors, + UpdateResourceInstitutions, +} from '@osf/shared/stores'; + +@Component({ + selector: 'osf-registries-affiliated-institution', + imports: [Card, AffiliatedInstitutionSelectComponent, TranslatePipe], + templateUrl: './registries-affiliated-institution.component.html', + styleUrl: './registries-affiliated-institution.component.scss', + changeDetection: ChangeDetectionStrategy.OnPush, +}) +export class RegistriesAffiliatedInstitutionComponent implements OnInit { + private readonly route = inject(ActivatedRoute); + private readonly draftId = this.route.snapshot.params['id']; + readonly userInstitutions = select(InstitutionsSelectors.getUserInstitutions); + readonly areResourceInstitutionsLoading = select(InstitutionsSelectors.areResourceInstitutionsLoading); + + private actions = createDispatchMap({ + fetchUserInstitutions: FetchUserInstitutions, + fetchResourceInstitutions: FetchResourceInstitutions, + updateResourceInstitutions: UpdateResourceInstitutions, + }); + + ngOnInit() { + this.actions.fetchUserInstitutions(); + this.actions.fetchResourceInstitutions(this.draftId, ResourceType.DraftRegistration); + } + + institutionsSelected(institutions: Institution[]) { + this.actions.updateResourceInstitutions(this.draftId, ResourceType.DraftRegistration, institutions); + } +} diff --git a/src/app/features/registries/components/review/review.component.ts b/src/app/features/registries/components/review/review.component.ts index 33d5387af..716114d5f 100644 --- a/src/app/features/registries/components/review/review.component.ts +++ b/src/app/features/registries/components/review/review.component.ts @@ -193,7 +193,7 @@ export class ReviewComponent { .onClose.subscribe((res) => { if (res) { this.toastService.showSuccess('registries.review.confirmation.successMessage'); - this.router.navigate([`registries/${this.newRegistration()?.id}/overview`]); + this.router.navigate([`/${this.newRegistration()?.id}/overview`]); } else { if (this.components()?.length) { this.openSelectComponentsForRegistrationDialog(); diff --git a/src/app/shared/services/institutions.service.ts b/src/app/shared/services/institutions.service.ts index d3cec04a1..c3756dbf5 100644 --- a/src/app/shared/services/institutions.service.ts +++ b/src/app/shared/services/institutions.service.ts @@ -26,6 +26,7 @@ export class InstitutionsService { [ResourceType.Agent, 'users'], [ResourceType.Project, 'nodes'], [ResourceType.Registration, 'registrations'], + [ResourceType.DraftRegistration, 'draft_registrations'], ]); getInstitutions(pageNumber: number, pageSize: number, searchValue?: string): Observable { diff --git a/src/assets/i18n/en.json b/src/assets/i18n/en.json index a6e08287f..17f2cb6bd 100644 --- a/src/assets/i18n/en.json +++ b/src/assets/i18n/en.json @@ -608,6 +608,7 @@ "citeAs": "Cite as:", "noCitationStylesFound": "No results found", "affiliatedInstitutions": "Affiliated Institutions", + "affiliatedInstitutionsDescription": "This is a service provided by the OSF and is automatically applied to your registration. If you are not sure if your institution has signed up for this service, you can look for their name in this list.", "noDescription": "No description", "noLicense": "No License", "noPublicationDoi": "No Publication DOI",