diff --git a/src/app/features/analytics/components/view-duplicates/view-duplicates.component.html b/src/app/features/analytics/components/view-duplicates/view-duplicates.component.html index 18386fbb6..42599a247 100644 --- a/src/app/features/analytics/components/view-duplicates/view-duplicates.component.html +++ b/src/app/features/analytics/components/view-duplicates/view-duplicates.component.html @@ -54,12 +54,8 @@

{{ 'common.labels.contributors' | translate }}: - @for (contributor of duplicate.contributors; track contributor.id) { -
- {{ contributor.fullName }} - {{ $last ? '' : ',' }} -
- } + +
diff --git a/src/app/features/analytics/components/view-duplicates/view-duplicates.component.spec.ts b/src/app/features/analytics/components/view-duplicates/view-duplicates.component.spec.ts index ce5f41d11..325254d6f 100644 --- a/src/app/features/analytics/components/view-duplicates/view-duplicates.component.spec.ts +++ b/src/app/features/analytics/components/view-duplicates/view-duplicates.component.spec.ts @@ -14,6 +14,7 @@ import { ResourceType } from '@osf/shared/enums'; import { IS_SMALL } from '@osf/shared/helpers'; import { DuplicatesSelectors } from '@osf/shared/stores'; import { + ContributorsListComponent, CustomPaginatorComponent, IconComponent, LoadingSpinnerComponent, @@ -52,7 +53,8 @@ describe('Component: View Duplicates', () => { TruncatedTextComponent, LoadingSpinnerComponent, CustomPaginatorComponent, - IconComponent + IconComponent, + ContributorsListComponent ), ], providers: [ diff --git a/src/app/features/analytics/components/view-duplicates/view-duplicates.component.ts b/src/app/features/analytics/components/view-duplicates/view-duplicates.component.ts index bea1cb9c1..0641302f2 100644 --- a/src/app/features/analytics/components/view-duplicates/view-duplicates.component.ts +++ b/src/app/features/analytics/components/view-duplicates/view-duplicates.component.ts @@ -31,6 +31,7 @@ import { RegistryOverviewSelectors, } from '@osf/features/registry/store/registry-overview'; import { + ContributorsListComponent, CustomPaginatorComponent, IconComponent, LoadingSpinnerComponent, @@ -56,6 +57,7 @@ import { ClearDuplicates, DuplicatesSelectors, GetAllDuplicates } from '@osf/sha RouterLink, CustomPaginatorComponent, IconComponent, + ContributorsListComponent, ], templateUrl: './view-duplicates.component.html', styleUrl: './view-duplicates.component.scss', diff --git a/src/app/features/collections/components/add-to-collection/project-contributors-step/project-contributors-step.component.html b/src/app/features/collections/components/add-to-collection/project-contributors-step/project-contributors-step.component.html index f0715c95f..be4fd3586 100644 --- a/src/app/features/collections/components/add-to-collection/project-contributors-step/project-contributors-step.component.html +++ b/src/app/features/collections/components/add-to-collection/project-contributors-step/project-contributors-step.component.html @@ -37,12 +37,12 @@

{{ 'collections.addToCollection.projectContributors' | translate }}

- + >
{ beforeEach(async () => { await TestBed.configureTestingModule({ - imports: [ProjectContributorsStepComponent, MockComponent(ContributorsListComponent), MockPipe(TranslatePipe)], + imports: [ProjectContributorsStepComponent, MockComponent(ContributorsTableComponent), MockPipe(TranslatePipe)], providers: [ provideHttpClient(), provideHttpClientTesting(), diff --git a/src/app/features/collections/components/add-to-collection/project-contributors-step/project-contributors-step.component.ts b/src/app/features/collections/components/add-to-collection/project-contributors-step/project-contributors-step.component.ts index dfa1bad79..bee98ce2d 100644 --- a/src/app/features/collections/components/add-to-collection/project-contributors-step/project-contributors-step.component.ts +++ b/src/app/features/collections/components/add-to-collection/project-contributors-step/project-contributors-step.component.ts @@ -17,7 +17,7 @@ import { InfoIconComponent } from '@osf/shared/components'; import { AddContributorDialogComponent, AddUnregisteredContributorDialogComponent, - ContributorsListComponent, + ContributorsTableComponent, } from '@osf/shared/components/contributors'; import { AddContributorType, ResourceType } from '@osf/shared/enums'; import { findChangedItems } from '@osf/shared/helpers'; @@ -33,7 +33,7 @@ import { @Component({ selector: 'osf-project-contributors-step', - imports: [Button, Step, StepItem, StepPanel, Tooltip, TranslatePipe, ContributorsListComponent, InfoIconComponent], + imports: [Button, Step, StepItem, StepPanel, Tooltip, TranslatePipe, ContributorsTableComponent, InfoIconComponent], templateUrl: './project-contributors-step.component.html', styleUrl: './project-contributors-step.component.scss', providers: [DialogService], diff --git a/src/app/features/collections/components/collections-search-result-card/collections-search-result-card.component.html b/src/app/features/collections/components/collections-search-result-card/collections-search-result-card.component.html index f9c7095e3..fa1b1557a 100644 --- a/src/app/features/collections/components/collections-search-result-card/collections-search-result-card.component.html +++ b/src/app/features/collections/components/collections-search-result-card/collections-search-result-card.component.html @@ -4,15 +4,15 @@

{{ item?.title }}

-

- {{ 'collections.common.by' | translate }} - @for (contributor of item?.contributors; track contributor.id) { - - {{ contributor.fullName }}{{ $last ? '' : ', ' }} - - } -

+ +
+

{{ 'collections.common.by' | translate }}

+ + +
+

{{ item?.description }}

+

{{ 'collections.common.dateCreated' | translate }} {{ item?.dateCreated | date: 'longDate' }} @@ -20,6 +20,7 @@ {{ 'collections.common.dateModified' | translate }} {{ item?.dateModified | date: 'longDate' }}

+
@for (attribute of presentSubmissionAttributes(); track attribute.key) { @if (!$first) { diff --git a/src/app/features/collections/components/collections-search-result-card/collections-search-result-card.component.spec.ts b/src/app/features/collections/components/collections-search-result-card/collections-search-result-card.component.spec.ts index 90af63040..6ca878645 100644 --- a/src/app/features/collections/components/collections-search-result-card/collections-search-result-card.component.spec.ts +++ b/src/app/features/collections/components/collections-search-result-card/collections-search-result-card.component.spec.ts @@ -1,10 +1,12 @@ import { TranslatePipe } from '@ngx-translate/core'; -import { MockPipes } from 'ng-mocks'; +import { MockComponent, MockPipes } from 'ng-mocks'; import { DatePipe } from '@angular/common'; import { ComponentRef } from '@angular/core'; import { ComponentFixture, TestBed } from '@angular/core/testing'; +import { ContributorsListComponent } from '@osf/shared/components'; + import { CollectionsSearchResultCardComponent } from './collections-search-result-card.component'; describe('CollectionsResultCardComponent', () => { @@ -14,7 +16,11 @@ describe('CollectionsResultCardComponent', () => { beforeEach(async () => { await TestBed.configureTestingModule({ - imports: [CollectionsSearchResultCardComponent, MockPipes(TranslatePipe, DatePipe)], + imports: [ + CollectionsSearchResultCardComponent, + MockPipes(TranslatePipe, DatePipe), + MockComponent(ContributorsListComponent), + ], }).compileComponents(); fixture = TestBed.createComponent(CollectionsSearchResultCardComponent); diff --git a/src/app/features/collections/components/collections-search-result-card/collections-search-result-card.component.ts b/src/app/features/collections/components/collections-search-result-card/collections-search-result-card.component.ts index 5054515c7..21dcb74d7 100644 --- a/src/app/features/collections/components/collections-search-result-card/collections-search-result-card.component.ts +++ b/src/app/features/collections/components/collections-search-result-card/collections-search-result-card.component.ts @@ -2,14 +2,14 @@ import { TranslatePipe } from '@ngx-translate/core'; import { DatePipe } from '@angular/common'; import { ChangeDetectionStrategy, Component, computed, input } from '@angular/core'; -import { RouterLink } from '@angular/router'; import { collectionFilterNames } from '@osf/features/collections/constants'; +import { ContributorsListComponent } from '@osf/shared/components'; import { CollectionSubmissionWithGuid } from '@shared/models'; @Component({ selector: 'osf-collections-search-result-card', - imports: [DatePipe, TranslatePipe, RouterLink], + imports: [DatePipe, TranslatePipe, ContributorsListComponent], templateUrl: './collections-search-result-card.component.html', styleUrl: './collections-search-result-card.component.scss', changeDetection: ChangeDetectionStrategy.OnPush, diff --git a/src/app/features/files/components/file-resource-metadata/file-resource-metadata.component.html b/src/app/features/files/components/file-resource-metadata/file-resource-metadata.component.html index 06b9f50c5..33fb23863 100644 --- a/src/app/features/files/components/file-resource-metadata/file-resource-metadata.component.html +++ b/src/app/features/files/components/file-resource-metadata/file-resource-metadata.component.html @@ -98,18 +98,11 @@

{{ 'files.detail.resourceMetadata.fields.dateModified' | translate }}

@if (isResourceContributorsLoading()) { } @else { - @if (contributors()?.length && !hasViewOnly()) { + @if (contributors().length && !hasViewOnly()) {
-

{{ 'files.detail.resourceMetadata.fields.contributors' | translate }}

+

{{ 'common.labels.contributors' | translate }}

-
- @for (contributor of contributors(); track $index) { - {{ contributor.fullName }} - @if (!$last) { - - } - } -
+
} } diff --git a/src/app/features/files/components/file-resource-metadata/file-resource-metadata.component.ts b/src/app/features/files/components/file-resource-metadata/file-resource-metadata.component.ts index adcaaab74..4239a1cbe 100644 --- a/src/app/features/files/components/file-resource-metadata/file-resource-metadata.component.ts +++ b/src/app/features/files/components/file-resource-metadata/file-resource-metadata.component.ts @@ -6,15 +6,16 @@ import { Skeleton } from 'primeng/skeleton'; import { DatePipe } from '@angular/common'; import { ChangeDetectionStrategy, Component, computed, inject, input } from '@angular/core'; -import { Router, RouterLink } from '@angular/router'; +import { Router } from '@angular/router'; +import { ContributorsListComponent } from '@osf/shared/components'; import { hasViewOnlyParam } from '@osf/shared/helpers'; import { FilesSelectors } from '../../store'; @Component({ selector: 'osf-file-resource-metadata', - imports: [DatePipe, TranslatePipe, Skeleton, RouterLink], + imports: [DatePipe, TranslatePipe, Skeleton, ContributorsListComponent], templateUrl: './file-resource-metadata.component.html', styleUrl: './file-resource-metadata.component.scss', changeDetection: ChangeDetectionStrategy.OnPush, diff --git a/src/app/features/files/store/files.model.ts b/src/app/features/files/store/files.model.ts index 5f6109aa9..a0ff947ba 100644 --- a/src/app/features/files/store/files.model.ts +++ b/src/app/features/files/store/files.model.ts @@ -17,7 +17,7 @@ export interface FilesStateModel { openedFile: AsyncStateModel; fileMetadata: AsyncStateModel; resourceMetadata: AsyncStateModel; - contributors: AsyncStateModel[] | null>; + contributors: AsyncStateModel; fileRevisions: AsyncStateModel; tags: AsyncStateModel; rootFolders: AsyncStateModel; diff --git a/src/app/features/files/store/files.selectors.ts b/src/app/features/files/store/files.selectors.ts index fa0e13d88..f2750ad17 100644 --- a/src/app/features/files/store/files.selectors.ts +++ b/src/app/features/files/store/files.selectors.ts @@ -90,8 +90,8 @@ export class FilesSelectors { } @Selector([FilesState]) - static getContributors(state: FilesStateModel): Partial[] | null { - return state.contributors.data; + static getContributors(state: FilesStateModel): ContributorModel[] { + return state.contributors.data || []; } @Selector([FilesState]) diff --git a/src/app/features/metadata/components/metadata-contributors/metadata-contributors.component.html b/src/app/features/metadata/components/metadata-contributors/metadata-contributors.component.html index 85addb385..e7956426c 100644 --- a/src/app/features/metadata/components/metadata-contributors/metadata-contributors.component.html +++ b/src/app/features/metadata/components/metadata-contributors/metadata-contributors.component.html @@ -14,14 +14,7 @@

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

@if (contributors()) {
- @for (contributor of contributors(); track contributor.id) { -
- - {{ contributor.fullName }} - - {{ $last ? '' : ',' }} -
- } +
} diff --git a/src/app/features/metadata/components/metadata-contributors/metadata-contributors.component.spec.ts b/src/app/features/metadata/components/metadata-contributors/metadata-contributors.component.spec.ts index dd353aa61..4594fb46b 100644 --- a/src/app/features/metadata/components/metadata-contributors/metadata-contributors.component.spec.ts +++ b/src/app/features/metadata/components/metadata-contributors/metadata-contributors.component.spec.ts @@ -1,8 +1,9 @@ -import { MockProvider } from 'ng-mocks'; +import { MockComponent, MockProvider } from 'ng-mocks'; import { ComponentFixture, TestBed } from '@angular/core/testing'; import { ActivatedRoute } from '@angular/router'; +import { ContributorsListComponent } from '@osf/shared/components'; import { ContributorModel } from '@osf/shared/models'; import { MOCK_CONTRIBUTOR, TranslateServiceMock } from '@shared/mocks'; @@ -16,7 +17,7 @@ describe('MetadataContributorsComponent', () => { beforeEach(async () => { await TestBed.configureTestingModule({ - imports: [MetadataContributorsComponent], + imports: [MetadataContributorsComponent, MockComponent(ContributorsListComponent)], providers: [TranslateServiceMock, MockProvider(ActivatedRoute)], }).compileComponents(); diff --git a/src/app/features/metadata/components/metadata-contributors/metadata-contributors.component.ts b/src/app/features/metadata/components/metadata-contributors/metadata-contributors.component.ts index 843e7b16e..461edea00 100644 --- a/src/app/features/metadata/components/metadata-contributors/metadata-contributors.component.ts +++ b/src/app/features/metadata/components/metadata-contributors/metadata-contributors.component.ts @@ -4,13 +4,13 @@ import { Button } from 'primeng/button'; import { Card } from 'primeng/card'; import { ChangeDetectionStrategy, Component, input, output } from '@angular/core'; -import { RouterLink } from '@angular/router'; +import { ContributorsListComponent } from '@osf/shared/components'; import { ContributorModel } from '@osf/shared/models'; @Component({ selector: 'osf-metadata-contributors', - imports: [Button, Card, TranslatePipe, RouterLink], + imports: [Button, Card, TranslatePipe, ContributorsListComponent], templateUrl: './metadata-contributors.component.html', changeDetection: ChangeDetectionStrategy.OnPush, }) diff --git a/src/app/features/metadata/dialogs/contributors-dialog/contributors-dialog.component.html b/src/app/features/metadata/dialogs/contributors-dialog/contributors-dialog.component.html index 247ac204d..6b4f2d8ea 100644 --- a/src/app/features/metadata/dialogs/contributors-dialog/contributors-dialog.component.html +++ b/src/app/features/metadata/dialogs/contributors-dialog/contributors-dialog.component.html @@ -14,7 +14,7 @@
- + > @if (hasChanges) {
diff --git a/src/app/features/metadata/dialogs/contributors-dialog/contributors-dialog.component.ts b/src/app/features/metadata/dialogs/contributors-dialog/contributors-dialog.component.ts index 2849253a3..3d8963356 100644 --- a/src/app/features/metadata/dialogs/contributors-dialog/contributors-dialog.component.ts +++ b/src/app/features/metadata/dialogs/contributors-dialog/contributors-dialog.component.ts @@ -25,7 +25,7 @@ import { SearchInputComponent } from '@osf/shared/components'; import { AddContributorDialogComponent, AddUnregisteredContributorDialogComponent, - ContributorsListComponent, + ContributorsTableComponent, } from '@osf/shared/components/contributors'; import { AddContributorType, ContributorPermission, ResourceType } from '@osf/shared/enums'; import { findChangedItems } from '@osf/shared/helpers'; @@ -43,7 +43,7 @@ import { @Component({ selector: 'osf-contributors-dialog', - imports: [Button, SearchInputComponent, TranslatePipe, FormsModule, ContributorsListComponent], + imports: [Button, SearchInputComponent, TranslatePipe, FormsModule, ContributorsTableComponent], templateUrl: './contributors-dialog.component.html', changeDetection: ChangeDetectionStrategy.OnPush, providers: [DialogService], diff --git a/src/app/features/my-projects/mappers/my-resources.mapper.ts b/src/app/features/my-projects/mappers/my-resources.mapper.ts index 7b89a4af5..d70c19be9 100644 --- a/src/app/features/my-projects/mappers/my-resources.mapper.ts +++ b/src/app/features/my-projects/mappers/my-resources.mapper.ts @@ -10,7 +10,7 @@ export class MyResourcesMapper { dateCreated: response.attributes.date_created, dateModified: response.attributes.date_modified, isPublic: response.attributes.public, - contributors: ContributorsMapper.getContributorShortInfo(response.embeds?.bibliographic_contributors?.data), + contributors: ContributorsMapper.getContributors(response.embeds?.bibliographic_contributors?.data), }; } } diff --git a/src/app/features/preprints/components/preprint-details/general-information/general-information.component.html b/src/app/features/preprints/components/preprint-details/general-information/general-information.component.html index baa5c1279..b0df7c2b1 100644 --- a/src/app/features/preprints/components/preprint-details/general-information/general-information.component.html +++ b/src/app/features/preprints/components/preprint-details/general-information/general-information.component.html @@ -25,18 +25,7 @@

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

{{ 'preprints.preprintStepper.review.sections.metadata.authors' | translate }}

- @for (contributor of bibliographicContributors(); track contributor.id) { -
- @if (contributor.isUnregisteredContributor) { - {{ contributor.fullName }} - } @else { - - {{ contributor.fullName }} - - } - {{ $last ? '' : ',' }} -
- } + @if (areContributorsLoading()) { diff --git a/src/app/features/preprints/components/preprint-details/general-information/general-information.component.spec.ts b/src/app/features/preprints/components/preprint-details/general-information/general-information.component.spec.ts index a99d42f8f..edbbe811f 100644 --- a/src/app/features/preprints/components/preprint-details/general-information/general-information.component.spec.ts +++ b/src/app/features/preprints/components/preprint-details/general-information/general-information.component.spec.ts @@ -3,13 +3,19 @@ import { MockComponents, MockProvider } from 'ng-mocks'; import { ComponentFixture, TestBed } from '@angular/core/testing'; import { ENVIRONMENT } from '@core/provider/environment.provider'; -import { PreprintDoiSectionComponent } from '@osf/features/preprints/components/preprint-details/preprint-doi-section/preprint-doi-section.component'; import { PreprintProviderDetails } from '@osf/features/preprints/models'; import { PreprintSelectors } from '@osf/features/preprints/store/preprint'; -import { AffiliatedInstitutionsViewComponent, IconComponent, TruncatedTextComponent } from '@shared/components'; +import { + AffiliatedInstitutionsViewComponent, + ContributorsListComponent, + IconComponent, + TruncatedTextComponent, +} from '@shared/components'; import { MOCK_CONTRIBUTOR, MOCK_INSTITUTION } from '@shared/mocks'; import { ContributorsSelectors, InstitutionsSelectors } from '@shared/stores'; +import { PreprintDoiSectionComponent } from '../preprint-doi-section/preprint-doi-section.component'; + import { GeneralInformationComponent } from './general-information.component'; import { PREPRINT_MOCK } from '@testing/mocks/preprint.mock'; @@ -36,7 +42,8 @@ describe('GeneralInformationComponent', () => { TruncatedTextComponent, PreprintDoiSectionComponent, IconComponent, - AffiliatedInstitutionsViewComponent + AffiliatedInstitutionsViewComponent, + ContributorsListComponent ), ], providers: [ diff --git a/src/app/features/preprints/components/preprint-details/general-information/general-information.component.ts b/src/app/features/preprints/components/preprint-details/general-information/general-information.component.ts index 3ec595538..c7fdf8ed9 100644 --- a/src/app/features/preprints/components/preprint-details/general-information/general-information.component.ts +++ b/src/app/features/preprints/components/preprint-details/general-information/general-information.component.ts @@ -7,14 +7,18 @@ import { Skeleton } from 'primeng/skeleton'; import { ChangeDetectionStrategy, Component, computed, effect, inject, input, OnDestroy, output } from '@angular/core'; import { FormsModule } from '@angular/forms'; -import { RouterLink } from '@angular/router'; import { ENVIRONMENT } from '@core/provider/environment.provider'; import { PreprintDoiSectionComponent } from '@osf/features/preprints/components/preprint-details/preprint-doi-section/preprint-doi-section.component'; import { ApplicabilityStatus, PreregLinkInfo } from '@osf/features/preprints/enums'; import { PreprintProviderDetails } from '@osf/features/preprints/models'; import { FetchPreprintById, PreprintSelectors } from '@osf/features/preprints/store/preprint'; -import { AffiliatedInstitutionsViewComponent, IconComponent, TruncatedTextComponent } from '@shared/components'; +import { + AffiliatedInstitutionsViewComponent, + ContributorsListComponent, + IconComponent, + TruncatedTextComponent, +} from '@shared/components'; import { ResourceType } from '@shared/enums'; import { ContributorsSelectors, GetAllContributors, ResetContributorsState } from '@shared/stores'; import { FetchResourceInstitutions, InstitutionsSelectors } from '@shared/stores/institutions'; @@ -30,7 +34,7 @@ import { FetchResourceInstitutions, InstitutionsSelectors } from '@shared/stores PreprintDoiSectionComponent, IconComponent, AffiliatedInstitutionsViewComponent, - RouterLink, + ContributorsListComponent, ], templateUrl: './general-information.component.html', styleUrl: './general-information.component.scss', diff --git a/src/app/features/preprints/components/preprint-details/preprint-tombstone/preprint-tombstone.component.html b/src/app/features/preprints/components/preprint-details/preprint-tombstone/preprint-tombstone.component.html index a1b192429..b562db252 100644 --- a/src/app/features/preprints/components/preprint-details/preprint-tombstone/preprint-tombstone.component.html +++ b/src/app/features/preprints/components/preprint-details/preprint-tombstone/preprint-tombstone.component.html @@ -13,12 +13,7 @@

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

{{ 'preprints.preprintStepper.review.sections.metadata.authors' | translate }}

- @for (contributor of bibliographicContributors(); track contributor.id) { -
- {{ contributor.fullName }} - {{ $last ? '' : ',' }} -
- } + @if (areContributorsLoading()) { diff --git a/src/app/features/preprints/components/preprint-details/preprint-tombstone/preprint-tombstone.component.spec.ts b/src/app/features/preprints/components/preprint-details/preprint-tombstone/preprint-tombstone.component.spec.ts index 3ef8fe1ce..e552b32e5 100644 --- a/src/app/features/preprints/components/preprint-details/preprint-tombstone/preprint-tombstone.component.spec.ts +++ b/src/app/features/preprints/components/preprint-details/preprint-tombstone/preprint-tombstone.component.spec.ts @@ -2,13 +2,14 @@ import { MockComponents, MockPipes } from 'ng-mocks'; import { ComponentFixture, TestBed } from '@angular/core/testing'; -import { PreprintDoiSectionComponent } from '@osf/features/preprints/components/preprint-details/preprint-doi-section/preprint-doi-section.component'; import { PreprintProviderDetails } from '@osf/features/preprints/models'; import { PreprintSelectors } from '@osf/features/preprints/store/preprint'; +import { ContributorsListComponent, TruncatedTextComponent } from '@osf/shared/components'; +import { MOCK_CONTRIBUTOR } from '@osf/shared/mocks'; +import { InterpolatePipe } from '@osf/shared/pipes'; import { ContributorsSelectors, SubjectsSelectors } from '@osf/shared/stores'; -import { TruncatedTextComponent } from '@shared/components'; -import { MOCK_CONTRIBUTOR } from '@shared/mocks'; -import { InterpolatePipe } from '@shared/pipes'; + +import { PreprintDoiSectionComponent } from '../preprint-doi-section/preprint-doi-section.component'; import { PreprintTombstoneComponent } from './preprint-tombstone.component'; @@ -33,7 +34,7 @@ describe('PreprintTombstoneComponent', () => { imports: [ PreprintTombstoneComponent, OSFTestingModule, - ...MockComponents(PreprintDoiSectionComponent, TruncatedTextComponent), + ...MockComponents(PreprintDoiSectionComponent, TruncatedTextComponent, ContributorsListComponent), MockPipes(InterpolatePipe), ], providers: [ diff --git a/src/app/features/preprints/components/preprint-details/preprint-tombstone/preprint-tombstone.component.ts b/src/app/features/preprints/components/preprint-details/preprint-tombstone/preprint-tombstone.component.ts index f096332b7..3e13d7895 100644 --- a/src/app/features/preprints/components/preprint-details/preprint-tombstone/preprint-tombstone.component.ts +++ b/src/app/features/preprints/components/preprint-details/preprint-tombstone/preprint-tombstone.component.ts @@ -9,12 +9,11 @@ import { Tag } from 'primeng/tag'; import { DatePipe } from '@angular/common'; import { ChangeDetectionStrategy, Component, computed, effect, input, OnDestroy, output } from '@angular/core'; -import { RouterLink } from '@angular/router'; import { ApplicabilityStatus, PreregLinkInfo } from '@osf/features/preprints/enums'; import { PreprintProviderDetails } from '@osf/features/preprints/models'; import { FetchPreprintById, PreprintSelectors } from '@osf/features/preprints/store/preprint'; -import { TruncatedTextComponent } from '@osf/shared/components'; +import { ContributorsListComponent, TruncatedTextComponent } from '@osf/shared/components'; import { ResourceType } from '@osf/shared/enums'; import { InterpolatePipe } from '@osf/shared/pipes'; import { @@ -42,7 +41,7 @@ import { PreprintDoiSectionComponent } from '../preprint-doi-section/preprint-do AccordionHeader, InterpolatePipe, DatePipe, - RouterLink, + ContributorsListComponent, ], templateUrl: './preprint-tombstone.component.html', styleUrl: './preprint-tombstone.component.scss', diff --git a/src/app/features/preprints/components/stepper/metadata-step/contributors/contributors.component.html b/src/app/features/preprints/components/stepper/metadata-step/contributors/contributors.component.html index 5db80a58c..046e8821e 100644 --- a/src/app/features/preprints/components/stepper/metadata-step/contributors/contributors.component.html +++ b/src/app/features/preprints/components/stepper/metadata-step/contributors/contributors.component.html @@ -7,7 +7,7 @@

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

- { confirmationServiceMock = CustomConfirmationServiceMockBuilder.create().build(); await TestBed.configureTestingModule({ - imports: [ContributorsComponent, OSFTestingModule, MockComponent(ContributorsListComponent)], + imports: [ContributorsComponent, OSFTestingModule, MockComponent(ContributorsTableComponent)], providers: [ MockProvider(ToastService, toastServiceMock), MockProvider(CustomConfirmationService, confirmationServiceMock), diff --git a/src/app/features/preprints/components/stepper/metadata-step/contributors/contributors.component.ts b/src/app/features/preprints/components/stepper/metadata-step/contributors/contributors.component.ts index 47dc7ee9c..50d28844b 100644 --- a/src/app/features/preprints/components/stepper/metadata-step/contributors/contributors.component.ts +++ b/src/app/features/preprints/components/stepper/metadata-step/contributors/contributors.component.ts @@ -28,7 +28,7 @@ import { UserSelectors } from '@core/store/user'; import { AddContributorDialogComponent, AddUnregisteredContributorDialogComponent, - ContributorsListComponent, + ContributorsTableComponent, } from '@osf/shared/components/contributors'; import { AddContributorType, ContributorPermission, ResourceType } from '@osf/shared/enums'; import { findChangedItems } from '@osf/shared/helpers'; @@ -44,7 +44,7 @@ import { @Component({ selector: 'osf-preprint-contributors', - imports: [FormsModule, TableModule, ContributorsListComponent, TranslatePipe, Card, Button, Message], + imports: [FormsModule, TableModule, ContributorsTableComponent, TranslatePipe, Card, Button, Message], templateUrl: './contributors.component.html', styleUrl: './contributors.component.scss', changeDetection: ChangeDetectionStrategy.OnPush, diff --git a/src/app/features/preprints/components/stepper/review-step/review-step.component.html b/src/app/features/preprints/components/stepper/review-step/review-step.component.html index 77ef78227..72ac9e0a7 100644 --- a/src/app/features/preprints/components/stepper/review-step/review-step.component.html +++ b/src/app/features/preprints/components/stepper/review-step/review-step.component.html @@ -60,22 +60,9 @@

{{ 'preprints.preprintStepper.common.labels.abstract' | translate }}

{{ 'preprints.preprintStepper.review.sections.metadata.title' | translate }}

-

{{ 'preprints.preprintStepper.review.sections.metadata.contributors' | translate }}

+

{{ 'common.labels.contributors' | translate }}

-
- @for (contributor of bibliographicContributors(); track contributor.id) { -
- @if (contributor.isUnregisteredContributor) { - {{ contributor.fullName }} - } @else { - - {{ contributor.fullName }} - - } - {{ $last ? '' : ',' }} -
- } -
+
@if (affiliatedInstitutions().length) { 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 b0e69aa0d..2dff893db 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 @@ -9,7 +9,7 @@ import { Tag } from 'primeng/tag'; import { DatePipe, TitleCasePipe } from '@angular/common'; import { ChangeDetectionStrategy, Component, computed, inject, input, OnInit } from '@angular/core'; -import { Router, RouterLink } from '@angular/router'; +import { Router } from '@angular/router'; import { ApplicabilityStatus, PreregLinkInfo } from '@osf/features/preprints/enums'; import { PreprintProviderDetails } from '@osf/features/preprints/models'; @@ -19,7 +19,11 @@ import { PreprintStepperSelectors, SubmitPreprint, } from '@osf/features/preprints/store/preprint-stepper'; -import { AffiliatedInstitutionsViewComponent, TruncatedTextComponent } from '@shared/components'; +import { + AffiliatedInstitutionsViewComponent, + ContributorsListComponent, + TruncatedTextComponent, +} from '@shared/components'; import { ResourceType } from '@shared/enums'; import { InterpolatePipe } from '@shared/pipes'; import { ToastService } from '@shared/services'; @@ -42,7 +46,7 @@ import { FetchResourceInstitutions, InstitutionsSelectors } from '@shared/stores AccordionPanel, InterpolatePipe, AffiliatedInstitutionsViewComponent, - RouterLink, + ContributorsListComponent, ], templateUrl: './review-step.component.html', styleUrl: './review-step.component.scss', diff --git a/src/app/features/project/contributors/contributors.component.html b/src/app/features/project/contributors/contributors.component.html index 058c25eb1..3656fe9c5 100644 --- a/src/app/features/project/contributors/contributors.component.html +++ b/src/app/features/project/contributors/contributors.component.html @@ -59,7 +59,7 @@

{{ 'navigation.contributors' | translate }

- {{ 'navigation.contributors' | translate } [currentUserId]="currentUser()?.id" [showCurator]="true" (remove)="removeContributor($event)" - > + > @if (hasChanges) {
diff --git a/src/app/features/project/contributors/contributors.component.ts b/src/app/features/project/contributors/contributors.component.ts index 0cfc2beb0..6059f9773 100644 --- a/src/app/features/project/contributors/contributors.component.ts +++ b/src/app/features/project/contributors/contributors.component.ts @@ -28,7 +28,7 @@ import { SearchInputComponent, ViewOnlyTableComponent } from '@osf/shared/compon import { AddContributorDialogComponent, AddUnregisteredContributorDialogComponent, - ContributorsListComponent, + ContributorsTableComponent, } from '@osf/shared/components/contributors'; import { BIBLIOGRAPHY_OPTIONS, PERMISSION_OPTIONS } from '@osf/shared/constants'; import { AddContributorType, ContributorPermission, ResourceType } from '@osf/shared/enums'; @@ -70,7 +70,7 @@ import { ResourceInfoModel } from './models'; TranslatePipe, FormsModule, TableModule, - ContributorsListComponent, + ContributorsTableComponent, ViewOnlyTableComponent, ], templateUrl: './contributors.component.html', diff --git a/src/app/features/project/linked-services/linked-services.component.html b/src/app/features/project/linked-services/linked-services.component.html index 833c79190..108b08e48 100644 --- a/src/app/features/project/linked-services/linked-services.component.html +++ b/src/app/features/project/linked-services/linked-services.component.html @@ -44,7 +44,7 @@ @if (canManageAddons()) {

{{ 'project.linkedServices.redirectMessage' | translate }} - + {{ 'project.linkedServices.addonsLink' | translate }} {{ 'project.linkedServices.redirectMessageSuffix' | translate }} diff --git a/src/app/features/project/overview/components/link-resource-dialog/link-resource-dialog.component.html b/src/app/features/project/overview/components/link-resource-dialog/link-resource-dialog.component.html index 4bfe7bf31..edd7e4238 100644 --- a/src/app/features/project/overview/components/link-resource-dialog/link-resource-dialog.component.html +++ b/src/app/features/project/overview/components/link-resource-dialog/link-resource-dialog.component.html @@ -84,7 +84,7 @@ {{ item.dateCreated | date: 'MMM d, y' }} {{ item.dateModified | date: 'MMM d, y' }} - @for (contributor of item.contributors; track contributor.fullName) { + @for (contributor of item.contributors; track contributor.id) { {{ contributor.fullName }}{{ $last ? '' : ', ' }} } diff --git a/src/app/features/project/overview/components/linked-resources/linked-resources.component.html b/src/app/features/project/overview/components/linked-resources/linked-resources.component.html index 55736a974..d67f342a0 100644 --- a/src/app/features/project/overview/components/linked-resources/linked-resources.component.html +++ b/src/app/features/project/overview/components/linked-resources/linked-resources.component.html @@ -38,12 +38,8 @@

{{ 'common.labels.contributors' | translate }}:

- @for (contributor of linkedResource.contributors; track contributor.id) { -
- {{ contributor.fullName }} - {{ $last ? '' : ',' }} -
- } + +
diff --git a/src/app/features/project/overview/components/linked-resources/linked-resources.component.ts b/src/app/features/project/overview/components/linked-resources/linked-resources.component.ts index 914fba9f7..94c34efa2 100644 --- a/src/app/features/project/overview/components/linked-resources/linked-resources.component.ts +++ b/src/app/features/project/overview/components/linked-resources/linked-resources.component.ts @@ -8,9 +8,8 @@ import { Skeleton } from 'primeng/skeleton'; import { ChangeDetectionStrategy, Component, inject, input } from '@angular/core'; import { toSignal } from '@angular/core/rxjs-interop'; -import { RouterLink } from '@angular/router'; -import { IconComponent, TruncatedTextComponent } from '@osf/shared/components'; +import { ContributorsListComponent, IconComponent, TruncatedTextComponent } from '@osf/shared/components'; import { IS_MEDIUM } from '@osf/shared/helpers'; import { NodeLinksSelectors } from '@osf/shared/stores'; @@ -19,7 +18,7 @@ import { LinkResourceDialogComponent } from '../link-resource-dialog/link-resour @Component({ selector: 'osf-linked-resources', - imports: [Button, Skeleton, TranslatePipe, TruncatedTextComponent, IconComponent, RouterLink], + imports: [Button, Skeleton, TranslatePipe, TruncatedTextComponent, IconComponent, ContributorsListComponent], templateUrl: './linked-resources.component.html', styleUrl: './linked-resources.component.scss', providers: [DialogService], @@ -51,7 +50,7 @@ export class LinkedResourcesComponent { openDeleteResourceModal(resourceId: string): void { const dialogWidth = this.isMedium() ? '650px' : '95vw'; - const currentLink = this.getCurrentResourceNodeLink(resourceId); + const currentLink = this.linkedResources().find((resource) => resource.id === resourceId); if (!currentLink) return; @@ -67,8 +66,4 @@ export class LinkedResourcesComponent { }, }); } - - private getCurrentResourceNodeLink(resourceId: string) { - return this.linkedResources().find((resource) => resource.id === resourceId); - } } diff --git a/src/app/features/project/overview/components/overview-components/overview-components.component.html b/src/app/features/project/overview/components/overview-components/overview-components.component.html index 89086356a..72656da99 100644 --- a/src/app/features/project/overview/components/overview-components/overview-components.component.html +++ b/src/app/features/project/overview/components/overview-components/overview-components.component.html @@ -53,12 +53,7 @@

- @for (contributor of component.contributors; track contributor.id) { -
- {{ contributor.fullName }} - {{ $last ? '' : ',' }} -
- } +
diff --git a/src/app/features/project/overview/components/overview-components/overview-components.component.ts b/src/app/features/project/overview/components/overview-components/overview-components.component.ts index edc6e4ba3..d04e23a9d 100644 --- a/src/app/features/project/overview/components/overview-components/overview-components.component.ts +++ b/src/app/features/project/overview/components/overview-components/overview-components.component.ts @@ -9,10 +9,10 @@ import { Skeleton } from 'primeng/skeleton'; import { ChangeDetectionStrategy, Component, computed, inject, input } from '@angular/core'; import { toSignal } from '@angular/core/rxjs-interop'; -import { Router, RouterLink } from '@angular/router'; +import { Router } from '@angular/router'; import { UserSelectors } from '@core/store/user'; -import { IconComponent, TruncatedTextComponent } from '@osf/shared/components'; +import { ContributorsListComponent, IconComponent, TruncatedTextComponent } from '@osf/shared/components'; import { ResourceType, UserPermissions } from '@osf/shared/enums'; import { IS_XSMALL } from '@osf/shared/helpers'; import { ComponentOverview } from '@shared/models'; @@ -23,7 +23,7 @@ import { DeleteComponentDialogComponent } from '../delete-component-dialog/delet @Component({ selector: 'osf-project-components', - imports: [Button, Menu, Skeleton, TranslatePipe, TruncatedTextComponent, IconComponent, RouterLink], + imports: [Button, Menu, Skeleton, TranslatePipe, TruncatedTextComponent, IconComponent, ContributorsListComponent], templateUrl: './overview-components.component.html', styleUrl: './overview-components.component.scss', changeDetection: ChangeDetectionStrategy.OnPush, @@ -70,7 +70,7 @@ export class OverviewComponentsComponent { get isCurrentUserContributor() { return (component: ComponentOverview) => { const userId = this.currentUserId(); - return userId ? component.contributors.some((contributor) => contributor.id === userId) : false; + return userId ? component.contributors.some((contributor) => contributor.userId === userId) : false; }; } diff --git a/src/app/features/project/overview/mappers/project-overview.mapper.ts b/src/app/features/project/overview/mappers/project-overview.mapper.ts index 7473ac0af..88de48c72 100644 --- a/src/app/features/project/overview/mappers/project-overview.mapper.ts +++ b/src/app/features/project/overview/mappers/project-overview.mapper.ts @@ -1,4 +1,4 @@ -import { InstitutionsMapper } from '@shared/mappers'; +import { ContributorsMapper, InstitutionsMapper } from '@shared/mappers'; import { LicenseModel } from '@shared/models'; import { ProjectOverview, ProjectOverviewGetResponseJsonApi } from '../models'; @@ -36,15 +36,7 @@ export class ProjectOverviewMapper { currentUserIsContributorOrGroupMember: response.attributes.current_user_is_contributor_or_group_member, wikiEnabled: response.attributes.wiki_enabled, customCitation: response.attributes.custom_citation, - contributors: - response.embeds.bibliographic_contributors?.data?.map((contributor) => ({ - id: contributor.embeds.users.data.id, - familyName: contributor.embeds.users.data.attributes.family_name, - fullName: contributor.embeds.users.data.attributes.full_name, - givenName: contributor.embeds.users.data.attributes.given_name, - middleName: contributor.embeds.users.data.attributes.middle_name, - type: contributor.embeds.users.data.type, - })) ?? [], + contributors: ContributorsMapper.getContributors(response?.embeds?.bibliographic_contributors?.data), affiliatedInstitutions: response.embeds.affiliated_institutions ? InstitutionsMapper.fromInstitutionsResponse(response.embeds.affiliated_institutions) : [], diff --git a/src/app/features/project/overview/models/project-overview.models.ts b/src/app/features/project/overview/models/project-overview.models.ts index 64b632ba1..4390b4020 100644 --- a/src/app/features/project/overview/models/project-overview.models.ts +++ b/src/app/features/project/overview/models/project-overview.models.ts @@ -1,5 +1,7 @@ import { UserPermissions } from '@osf/shared/enums'; import { + ContributorDataJsonApi, + ContributorModel, Identifier, IdTypeModel, Institution, @@ -10,15 +12,6 @@ import { MetaAnonymousJsonApi, } from '@osf/shared/models'; -export interface ProjectOverviewContributor { - familyName: string; - fullName: string; - givenName: string; - middleName: string; - id: string; - type: string; -} - export interface ProjectOverview { id: string; type: string; @@ -52,7 +45,7 @@ export interface ProjectOverview { currentUserIsContributor: boolean; currentUserIsContributorOrGroupMember: boolean; wikiEnabled: boolean; - contributors: ProjectOverviewContributor[]; + contributors: ContributorModel[]; customCitation: string | null; region?: IdTypeModel; affiliatedInstitutions?: Institution[]; @@ -113,22 +106,7 @@ export interface ProjectOverviewGetResponseJsonApi { }[]; }; bibliographic_contributors: { - data: { - embeds: { - users: { - data: { - id: string; - type: string; - attributes: { - family_name: string; - full_name: string; - given_name: string; - middle_name: string; - }; - }; - }; - }; - }[]; + data: ContributorDataJsonApi[]; }; license: { data: { diff --git a/src/app/features/registries/components/registries-metadata-step/registries-contributors/registries-contributors.component.html b/src/app/features/registries/components/registries-metadata-step/registries-contributors/registries-contributors.component.html index 0e1864b7c..7c626c448 100644 --- a/src/app/features/registries/components/registries-metadata-step/registries-contributors/registries-contributors.component.html +++ b/src/app/features/registries/components/registries-metadata-step/registries-contributors/registries-contributors.component.html @@ -1,7 +1,7 @@

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

- {{ 'common.labels.description' | translate }}

-

{{ 'navigation.contributors' | translate }}

-
- @for (contributor of contributors(); let last = $last; track contributor.id) { - - {{ contributor.fullName }} - @if (!last) { - , - } - - } -
+

{{ 'common.labels.contributors' | translate }}

+ +
diff --git a/src/app/features/registries/components/review/review.component.ts b/src/app/features/registries/components/review/review.component.ts index 5862e1a80..f2cfb1f41 100644 --- a/src/app/features/registries/components/review/review.component.ts +++ b/src/app/features/registries/components/review/review.component.ts @@ -13,10 +13,10 @@ import { map, of } from 'rxjs'; import { ChangeDetectionStrategy, Component, computed, effect, inject } from '@angular/core'; import { toSignal } from '@angular/core/rxjs-interop'; -import { ActivatedRoute, Router, RouterLink } from '@angular/router'; +import { ActivatedRoute, Router } from '@angular/router'; import { ENVIRONMENT } from '@core/provider/environment.provider'; -import { RegistrationBlocksDataComponent } from '@osf/shared/components'; +import { ContributorsListComponent, RegistrationBlocksDataComponent } from '@osf/shared/components'; import { INPUT_VALIDATION_MESSAGES } from '@osf/shared/constants'; import { FieldType, ResourceType } from '@osf/shared/enums'; import { InterpolatePipe } from '@osf/shared/pipes'; @@ -45,7 +45,6 @@ import { SelectComponentsDialogComponent } from '../select-components-dialog/sel TranslatePipe, Card, Message, - RouterLink, Tag, Button, Accordion, @@ -54,6 +53,7 @@ import { SelectComponentsDialogComponent } from '../select-components-dialog/sel AccordionPanel, InterpolatePipe, RegistrationBlocksDataComponent, + ContributorsListComponent, ], templateUrl: './review.component.html', styleUrl: './review.component.scss', diff --git a/src/app/features/registry/components/registration-links-card/registration-links-card.component.html b/src/app/features/registry/components/registration-links-card/registration-links-card.component.html index bd9d2fed0..6c0d081f4 100644 --- a/src/app/features/registry/components/registration-links-card/registration-links-card.component.html +++ b/src/app/features/registry/components/registration-links-card/registration-links-card.component.html @@ -39,15 +39,8 @@
- {{ 'project.overview.metadata.contributors' | translate }}: - - @for (contributor of registrationData().contributors; track contributor.id) { - {{ contributor.fullName }} - @if (!$last) { - , - } - } - + {{ 'common.labels.contributors' | translate }}: +
diff --git a/src/app/features/registry/components/registration-links-card/registration-links-card.component.ts b/src/app/features/registry/components/registration-links-card/registration-links-card.component.ts index 5c597ef20..a5b50c72e 100644 --- a/src/app/features/registry/components/registration-links-card/registration-links-card.component.ts +++ b/src/app/features/registry/components/registration-links-card/registration-links-card.component.ts @@ -5,9 +5,13 @@ import { Card } from 'primeng/card'; import { DatePipe } from '@angular/common'; import { ChangeDetectionStrategy, Component, computed, input, output } from '@angular/core'; -import { RouterLink } from '@angular/router'; -import { DataResourcesComponent, IconComponent, TruncatedTextComponent } from '@osf/shared/components'; +import { + ContributorsListComponent, + DataResourcesComponent, + IconComponent, + TruncatedTextComponent, +} from '@osf/shared/components'; import { RevisionReviewStates } from '@osf/shared/enums'; import { LinkedNode, LinkedRegistration, RegistryComponentModel } from '../../models'; @@ -22,7 +26,7 @@ import { LinkedNode, LinkedRegistration, RegistryComponentModel } from '../../mo DataResourcesComponent, TruncatedTextComponent, IconComponent, - RouterLink, + ContributorsListComponent, ], templateUrl: './registration-links-card.component.html', styleUrl: './registration-links-card.component.scss', diff --git a/src/app/features/registry/components/short-registration-info/short-registration-info.component.html b/src/app/features/registry/components/short-registration-info/short-registration-info.component.html index 066099deb..4487d7184 100644 --- a/src/app/features/registry/components/short-registration-info/short-registration-info.component.html +++ b/src/app/features/registry/components/short-registration-info/short-registration-info.component.html @@ -1,33 +1,32 @@
-

{{ 'navigation.contributors' | translate }}

-

- @for (contributor of registration().contributors; track contributor.id) { - - {{ contributor.fullName }} - {{ !$last ? ', ' : '' }} - - } -

+

{{ 'common.labels.contributors' | translate }}

+ +
+

{{ 'common.labels.description' | translate }}

{{ registration().description }}

+

{{ 'registry.overview.metadata.type' | translate }}

{{ registration().registrationType }}

+

{{ 'registry.overview.metadata.registeredDate' | translate }}

{{ registration().dateRegistered | date }}

+

{{ 'registry.archiving.createdDate' | translate }}

{{ registration().dateCreated | date }}

+

{{ 'registry.overview.metadata.associatedProject' | translate }}

{{ associatedProjectUrl }} diff --git a/src/app/features/registry/components/short-registration-info/short-registration-info.component.ts b/src/app/features/registry/components/short-registration-info/short-registration-info.component.ts index 3f388056d..b859aec99 100644 --- a/src/app/features/registry/components/short-registration-info/short-registration-info.component.ts +++ b/src/app/features/registry/components/short-registration-info/short-registration-info.component.ts @@ -5,12 +5,13 @@ import { ChangeDetectionStrategy, Component, inject, input } from '@angular/core import { RouterLink } from '@angular/router'; import { ENVIRONMENT } from '@core/provider/environment.provider'; +import { ContributorsListComponent } from '@osf/shared/components'; import { RegistryOverview } from '../../models'; @Component({ selector: 'osf-short-registration-info', - imports: [TranslatePipe, DatePipe, RouterLink], + imports: [TranslatePipe, DatePipe, RouterLink, ContributorsListComponent], templateUrl: './short-registration-info.component.html', styleUrl: './short-registration-info.component.scss', changeDetection: ChangeDetectionStrategy.OnPush, diff --git a/src/app/features/registry/mappers/linked-nodes.mapper.ts b/src/app/features/registry/mappers/linked-nodes.mapper.ts index e6d73c72d..cfc31289e 100644 --- a/src/app/features/registry/mappers/linked-nodes.mapper.ts +++ b/src/app/features/registry/mappers/linked-nodes.mapper.ts @@ -15,7 +15,7 @@ export class LinkedNodesMapper { isPublic: apiNode.attributes.public, htmlUrl: apiNode.links.html, apiUrl: apiNode.links.self, - contributors: ContributorsMapper.fromResponse(apiNode.embeds.bibliographic_contributors.data) || [], + contributors: ContributorsMapper.getContributors(apiNode.embeds.bibliographic_contributors.data) || [], }; } } diff --git a/src/app/features/registry/mappers/linked-registrations.mapper.ts b/src/app/features/registry/mappers/linked-registrations.mapper.ts index fc27a69d1..a7d1f527e 100644 --- a/src/app/features/registry/mappers/linked-registrations.mapper.ts +++ b/src/app/features/registry/mappers/linked-registrations.mapper.ts @@ -26,7 +26,7 @@ export class LinkedRegistrationsMapper { pendingRegistrationApproval: apiRegistration.attributes.pending_registration_approval, registrationSupplement: apiRegistration.attributes.registration_supplement, currentUserPermissions: apiRegistration.attributes.current_user_permissions, - contributors: ContributorsMapper.fromResponse(apiRegistration.embeds.bibliographic_contributors.data) || [], + contributors: ContributorsMapper.getContributors(apiRegistration.embeds.bibliographic_contributors.data) || [], }; } } diff --git a/src/app/features/registry/mappers/registry-components.mapper.ts b/src/app/features/registry/mappers/registry-components.mapper.ts index 6d38e2bb7..af272a2fc 100644 --- a/src/app/features/registry/mappers/registry-components.mapper.ts +++ b/src/app/features/registry/mappers/registry-components.mapper.ts @@ -15,7 +15,7 @@ export class RegistryComponentsMapper { registrationSupplement: apiComponent.attributes.registration_supplement, tags: apiComponent.attributes.tags, isPublic: apiComponent.attributes.public, - contributors: ContributorsMapper.fromResponse(apiComponent.embeds.bibliographic_contributors.data) || [], + contributors: ContributorsMapper.getContributors(apiComponent.embeds.bibliographic_contributors.data) || [], }; } diff --git a/src/app/features/registry/mappers/registry-overview.mapper.ts b/src/app/features/registry/mappers/registry-overview.mapper.ts index f6133dc0a..768660c8c 100644 --- a/src/app/features/registry/mappers/registry-overview.mapper.ts +++ b/src/app/features/registry/mappers/registry-overview.mapper.ts @@ -1,4 +1,4 @@ -import { IdentifiersMapper, LicensesMapper } from '@osf/shared/mappers'; +import { ContributorsMapper, IdentifiersMapper, LicensesMapper } from '@osf/shared/mappers'; import { MapRegistryStatus, RegistrationMapper, RegistrationNodeMapper } from '@osf/shared/mappers/registration'; import { RegistryOverview, RegistryOverviewJsonApiData } from '../models'; @@ -27,14 +27,7 @@ export function MapRegistryOverview(data: RegistryOverviewJsonApiData): Registry registrationType: data.attributes?.registration_supplement, doi: data.attributes?.article_doi, tags: data.attributes?.tags, - contributors: data.embeds?.bibliographic_contributors?.data.map((contributor) => ({ - id: contributor?.embeds?.users?.data?.id, - familyName: contributor?.embeds?.users?.data?.attributes?.family_name, - fullName: contributor?.embeds?.users?.data?.attributes?.full_name, - givenName: contributor?.embeds?.users?.data?.attributes?.given_name, - middleName: contributor?.embeds?.users?.data?.attributes?.middle_names, - type: contributor?.embeds?.users?.data?.type, - })), + contributors: ContributorsMapper.getContributors(data?.embeds?.bibliographic_contributors?.data), identifiers: IdentifiersMapper.fromJsonApi(data.embeds?.identifiers), analyticsKey: data.attributes?.analytics_key, currentUserCanComment: data.attributes.current_user_can_comment, diff --git a/src/app/features/registry/models/get-registry-overview-json-api.model.ts b/src/app/features/registry/models/get-registry-overview-json-api.model.ts index 83d678a18..79bc04867 100644 --- a/src/app/features/registry/models/get-registry-overview-json-api.model.ts +++ b/src/app/features/registry/models/get-registry-overview-json-api.model.ts @@ -1,6 +1,7 @@ import { RegistrationReviewStates, RevisionReviewStates } from '@osf/shared/enums'; import { ApiData, + ContributorDataJsonApi, IdentifiersJsonApiData, JsonApiResponseWithMeta, LicenseDataJsonApi, @@ -73,22 +74,7 @@ export type RegistrationQuestions = Record + @if (anonymous()) { +

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

+ } @else { + @for (contributor of contributors(); track contributor.id) { +
+ @if (readonly() || contributor.isUnregisteredContributor || !contributor.userId) { + {{ contributor.fullName }}{{ $last ? '' : ',' }} + } @else { + + {{ contributor.fullName }}{{ $last ? '' : ',' }} + + } +
+ } + } +
diff --git a/src/app/shared/components/contributors-list/contributors-list.component.scss b/src/app/shared/components/contributors-list/contributors-list.component.scss new file mode 100644 index 000000000..e69de29bb diff --git a/src/app/shared/components/contributors-list/contributors-list.component.spec.ts b/src/app/shared/components/contributors-list/contributors-list.component.spec.ts new file mode 100644 index 000000000..393521b2e --- /dev/null +++ b/src/app/shared/components/contributors-list/contributors-list.component.spec.ts @@ -0,0 +1,26 @@ +import { ComponentFixture, TestBed } from '@angular/core/testing'; + +import { TranslateServiceMock } from '@shared/mocks'; + +import { ContributorsListComponent } from './contributors-list.component'; + +describe('ContributorsListComponent', () => { + let component: ContributorsListComponent; + let fixture: ComponentFixture; + + beforeEach(async () => { + await TestBed.configureTestingModule({ + imports: [ContributorsListComponent], + providers: [TranslateServiceMock], + }).compileComponents(); + + fixture = TestBed.createComponent(ContributorsListComponent); + component = fixture.componentInstance; + + fixture.detectChanges(); + }); + + it('should create', () => { + expect(component).toBeTruthy(); + }); +}); diff --git a/src/app/shared/components/contributors-list/contributors-list.component.ts b/src/app/shared/components/contributors-list/contributors-list.component.ts new file mode 100644 index 000000000..89cc6ab67 --- /dev/null +++ b/src/app/shared/components/contributors-list/contributors-list.component.ts @@ -0,0 +1,19 @@ +import { TranslatePipe } from '@ngx-translate/core'; + +import { ChangeDetectionStrategy, Component, input } from '@angular/core'; +import { RouterLink } from '@angular/router'; + +import { ContributorModel } from '@shared/models'; + +@Component({ + selector: 'osf-contributors-list', + imports: [RouterLink, TranslatePipe], + templateUrl: './contributors-list.component.html', + styleUrl: './contributors-list.component.scss', + changeDetection: ChangeDetectionStrategy.OnPush, +}) +export class ContributorsListComponent { + contributors = input.required[]>(); + readonly = input(false); + anonymous = input(false); +} diff --git a/src/app/shared/components/contributors/contributors-list/contributors-list.component.html b/src/app/shared/components/contributors/contributors-table/contributors-table.component.html similarity index 100% rename from src/app/shared/components/contributors/contributors-list/contributors-list.component.html rename to src/app/shared/components/contributors/contributors-table/contributors-table.component.html diff --git a/src/app/shared/components/contributors/contributors-list/contributors-list.component.scss b/src/app/shared/components/contributors/contributors-table/contributors-table.component.scss similarity index 100% rename from src/app/shared/components/contributors/contributors-list/contributors-list.component.scss rename to src/app/shared/components/contributors/contributors-table/contributors-table.component.scss diff --git a/src/app/shared/components/contributors/contributors-list/contributors-list.component.spec.ts b/src/app/shared/components/contributors/contributors-table/contributors-table.component.spec.ts similarity index 89% rename from src/app/shared/components/contributors/contributors-list/contributors-list.component.spec.ts rename to src/app/shared/components/contributors/contributors-table/contributors-table.component.spec.ts index 9c0705668..c48539324 100644 --- a/src/app/shared/components/contributors/contributors-list/contributors-list.component.spec.ts +++ b/src/app/shared/components/contributors/contributors-table/contributors-table.component.spec.ts @@ -4,23 +4,23 @@ import { DialogService } from 'primeng/dynamicdialog'; import { ComponentFixture, TestBed } from '@angular/core/testing'; -import { ContributorPermission } from '@shared/enums'; -import { MOCK_CONTRIBUTOR, MOCK_CONTRIBUTOR_WITHOUT_HISTORY, TranslateServiceMock } from '@shared/mocks'; -import { ContributorModel } from '@shared/models'; +import { ContributorPermission } from '@osf/shared/enums'; +import { MOCK_CONTRIBUTOR, MOCK_CONTRIBUTOR_WITHOUT_HISTORY, TranslateServiceMock } from '@osf/shared/mocks'; +import { ContributorModel } from '@osf/shared/models'; -import { ContributorsListComponent } from './contributors-list.component'; +import { ContributorsTableComponent } from './contributors-table.component'; -describe('ContributorsListComponent', () => { - let component: ContributorsListComponent; - let fixture: ComponentFixture; +describe('ContributorsTableComponent', () => { + let component: ContributorsTableComponent; + let fixture: ComponentFixture; beforeEach(async () => { await TestBed.configureTestingModule({ - imports: [ContributorsListComponent], + imports: [ContributorsTableComponent], providers: [MockProviders(DialogService), TranslateServiceMock], }).compileComponents(); - fixture = TestBed.createComponent(ContributorsListComponent); + fixture = TestBed.createComponent(ContributorsTableComponent); component = fixture.componentInstance; fixture.detectChanges(); @@ -128,6 +128,7 @@ describe('ContributorsListComponent', () => { type: 'user', isBibliographic: true, isCurator: true, + index: 0, isUnregisteredContributor: false, fullName: 'Minimal User', givenName: 'Minimal User', diff --git a/src/app/shared/components/contributors/contributors-list/contributors-list.component.ts b/src/app/shared/components/contributors/contributors-table/contributors-table.component.ts similarity index 84% rename from src/app/shared/components/contributors/contributors-list/contributors-list.component.ts rename to src/app/shared/components/contributors/contributors-table/contributors-table.component.ts index 72e7f96c3..2e8eda2a3 100644 --- a/src/app/shared/components/contributors/contributors-list/contributors-list.component.ts +++ b/src/app/shared/components/contributors/contributors-table/contributors-table.component.ts @@ -11,23 +11,22 @@ import { ChangeDetectionStrategy, Component, computed, inject, input, output, si import { FormsModule } from '@angular/forms'; import { ModeratorPermission } from '@osf/features/moderation/enums'; +import { EducationHistoryDialogComponent } from '@osf/shared/components/education-history-dialog/education-history-dialog.component'; +import { EmploymentHistoryDialogComponent } from '@osf/shared/components/employment-history-dialog/employment-history-dialog.component'; +import { SelectComponent } from '@osf/shared/components/select/select.component'; import { DEFAULT_TABLE_PARAMS, PERMISSION_OPTIONS } from '@osf/shared/constants'; +import { ContributorPermission } from '@osf/shared/enums'; import { ContributorModel, SelectOption, TableParameters } from '@osf/shared/models'; -import { ContributorPermission } from '@shared/enums'; - -import { EducationHistoryDialogComponent } from '../../education-history-dialog/education-history-dialog.component'; -import { EmploymentHistoryDialogComponent } from '../../employment-history-dialog/employment-history-dialog.component'; -import { SelectComponent } from '../../select/select.component'; @Component({ - selector: 'osf-contributors-list', + selector: 'osf-contributors-table', imports: [TranslatePipe, FormsModule, TableModule, Tooltip, Checkbox, Skeleton, Button, SelectComponent], - templateUrl: './contributors-list.component.html', - styleUrl: './contributors-list.component.scss', + templateUrl: './contributors-table.component.html', + styleUrl: './contributors-table.component.scss', changeDetection: ChangeDetectionStrategy.OnPush, providers: [DialogService], }) -export class ContributorsListComponent { +export class ContributorsTableComponent { contributors = input([]); isLoading = input(false); showCurator = input(false); diff --git a/src/app/shared/components/contributors/index.ts b/src/app/shared/components/contributors/index.ts index 8e74a5fc4..1c1ae3307 100644 --- a/src/app/shared/components/contributors/index.ts +++ b/src/app/shared/components/contributors/index.ts @@ -1,3 +1,3 @@ export * from './add-contributor-dialog/add-contributor-dialog.component'; export * from './add-unregistered-contributor-dialog/add-unregistered-contributor-dialog.component'; -export * from './contributors-list/contributors-list.component'; +export * from './contributors-table/contributors-table.component'; diff --git a/src/app/shared/components/index.ts b/src/app/shared/components/index.ts index 91e12717b..e4357154a 100644 --- a/src/app/shared/components/index.ts +++ b/src/app/shared/components/index.ts @@ -3,6 +3,7 @@ export { AffiliatedInstitutionSelectComponent } from './affiliated-institution-s export { AffiliatedInstitutionsViewComponent } from './affiliated-institutions-view/affiliated-institutions-view.component'; export { BarChartComponent } from './bar-chart/bar-chart.component'; export { ConfirmEmailComponent } from './confirm-email/confirm-email.component'; +export { ContributorsListComponent } from './contributors-list/contributors-list.component'; export { CopyButtonComponent } from './copy-button/copy-button.component'; export { CustomPaginatorComponent } from './custom-paginator/custom-paginator.component'; export { DataResourcesComponent } from './data-resources/data-resources.component'; diff --git a/src/app/shared/components/registration-card/registration-card.component.html b/src/app/shared/components/registration-card/registration-card.component.html index d74aac4c3..ed509ab86 100644 --- a/src/app/shared/components/registration-card/registration-card.component.html +++ b/src/app/shared/components/registration-card/registration-card.component.html @@ -36,15 +36,9 @@

- {{ 'project.overview.metadata.contributors' | translate }}: - - @for (contributor of registrationData().contributors; track contributor) { - {{ contributor.fullName }} - @if (!$last) { - , - } - } - + {{ 'common.labels.contributors' | translate }}: + +
diff --git a/src/app/shared/components/registration-card/registration-card.component.ts b/src/app/shared/components/registration-card/registration-card.component.ts index 0456d733f..68be76b33 100644 --- a/src/app/shared/components/registration-card/registration-card.component.ts +++ b/src/app/shared/components/registration-card/registration-card.component.ts @@ -15,6 +15,7 @@ import { CreateSchemaResponse, FetchAllSchemaResponses, RegistriesSelectors } fr import { RegistrationReviewStates, RevisionReviewStates, UserPermissions } from '@osf/shared/enums'; import { RegistrationCard } from '@osf/shared/models'; +import { ContributorsListComponent } from '../contributors-list/contributors-list.component'; import { DataResourcesComponent } from '../data-resources/data-resources.component'; import { IconComponent } from '../icon/icon.component'; import { StatusBadgeComponent } from '../status-badge/status-badge.component'; @@ -32,6 +33,7 @@ import { TruncatedTextComponent } from '../truncated-text/truncated-text.compone DataResourcesComponent, IconComponent, TruncatedTextComponent, + ContributorsListComponent, ], templateUrl: './registration-card.component.html', styleUrl: './registration-card.component.scss', diff --git a/src/app/shared/components/resource-metadata/resource-metadata.component.html b/src/app/shared/components/resource-metadata/resource-metadata.component.html index c9f8f8b7c..db627deaf 100644 --- a/src/app/shared/components/resource-metadata/resource-metadata.component.html +++ b/src/app/shared/components/resource-metadata/resource-metadata.component.html @@ -15,19 +15,13 @@

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

-

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

+

{{ 'common.labels.contributors' | translate }}

- @if (!resource.isAnonymous) { - @for (contributor of resource.contributors; track contributor.id) { -
- {{ contributor.fullName }} - {{ $last ? '' : ',' }} -
- } - } @else { -

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

- } +
diff --git a/src/app/shared/components/resource-metadata/resource-metadata.component.ts b/src/app/shared/components/resource-metadata/resource-metadata.component.ts index bb6e0dd48..f1ef25b3a 100644 --- a/src/app/shared/components/resource-metadata/resource-metadata.component.ts +++ b/src/app/shared/components/resource-metadata/resource-metadata.component.ts @@ -13,6 +13,7 @@ import { CurrentResourceType } from '@osf/shared/enums'; import { ResourceOverview } from '@shared/models'; import { AffiliatedInstitutionsViewComponent } from '../affiliated-institutions-view/affiliated-institutions-view.component'; +import { ContributorsListComponent } from '../contributors-list/contributors-list.component'; import { ResourceCitationsComponent } from '../resource-citations/resource-citations.component'; import { TruncatedTextComponent } from '../truncated-text/truncated-text.component'; @@ -28,6 +29,7 @@ import { TruncatedTextComponent } from '../truncated-text/truncated-text.compone ResourceCitationsComponent, OverviewCollectionsComponent, AffiliatedInstitutionsViewComponent, + ContributorsListComponent, ], templateUrl: './resource-metadata.component.html', styleUrl: './resource-metadata.component.scss', diff --git a/src/app/shared/constants/social-links.const.ts b/src/app/shared/constants/social-links.const.ts index 36a8a9206..e7f18b186 100644 --- a/src/app/shared/constants/social-links.const.ts +++ b/src/app/shared/constants/social-links.const.ts @@ -39,7 +39,7 @@ export const SOCIAL_LINKS: SocialLinksModel[] = [ address: 'https://impactstory.org/u/', placeholder: 'profileID', key: 'impactStory', - icon: 'impactStory.svg', + icon: 'impactStory.png', }, { id: 6, diff --git a/src/app/shared/mappers/collections/collections.mapper.ts b/src/app/shared/mappers/collections/collections.mapper.ts index 29e7d6949..ea2b92d41 100644 --- a/src/app/shared/mappers/collections/collections.mapper.ts +++ b/src/app/shared/mappers/collections/collections.mapper.ts @@ -14,7 +14,7 @@ import { CollectionSubmissionPayloadJsonApi, CollectionSubmissionWithGuid, CollectionSubmissionWithGuidJsonApi, - ContributorShortInfoModel, + ContributorModel, PaginatedData, ResponseJsonApi, } from '@osf/shared/models'; @@ -189,7 +189,7 @@ export class CollectionsMapper { dataType: submission.attributes.data_type, disease: submission.attributes.disease, gradeLevels: submission.attributes.grade_levels, - contributors: [] as ContributorShortInfoModel[], + contributors: [] as ContributorModel[], })); } diff --git a/src/app/shared/mappers/components/components.mapper.ts b/src/app/shared/mappers/components/components.mapper.ts index 762e19d95..57a6d0ec8 100644 --- a/src/app/shared/mappers/components/components.mapper.ts +++ b/src/app/shared/mappers/components/components.mapper.ts @@ -1,5 +1,7 @@ import { ComponentGetResponseJsonApi, ComponentOverview } from '@shared/models'; +import { ContributorsMapper } from '../contributors'; + export class ComponentsMapper { static fromGetComponentResponse(response: ComponentGetResponseJsonApi): ComponentOverview { return { @@ -8,14 +10,7 @@ export class ComponentsMapper { title: response.attributes.title, description: response.attributes.description, public: response.attributes.public, - contributors: response.embeds.bibliographic_contributors.data.map((contributor) => ({ - id: contributor.embeds.users?.data?.id, - familyName: contributor.embeds.users?.data?.attributes?.family_name, - fullName: contributor.embeds.users?.data?.attributes?.full_name, - givenName: contributor.embeds.users?.data?.attributes?.given_name, - middleName: contributor.embeds.users?.data?.attributes?.middle_name, - type: contributor.embeds.users?.data?.type, - })), + contributors: ContributorsMapper.getContributors(response?.embeds?.bibliographic_contributors?.data), currentUserPermissions: response.attributes?.current_user_permissions || [], }; } diff --git a/src/app/shared/mappers/contributors/contributors.mapper.ts b/src/app/shared/mappers/contributors/contributors.mapper.ts index 22cd79f88..0be93bef9 100644 --- a/src/app/shared/mappers/contributors/contributors.mapper.ts +++ b/src/app/shared/mappers/contributors/contributors.mapper.ts @@ -11,47 +11,51 @@ import { } from '@osf/shared/models'; export class ContributorsMapper { - static fromResponse(response: ContributorDataJsonApi[] | undefined): ContributorModel[] { + static getContributors(response: ContributorDataJsonApi[] | undefined): ContributorModel[] { if (!response) { return []; } - return response - .filter((contributor) => !contributor?.embeds?.users?.errors) - .map((contributor) => this.fromContributorResponse(contributor)); + return response.map((contributor) => this.getContributor(contributor)); } - static fromContributorResponse(response: ContributorDataJsonApi): ContributorModel { + static getContributor(response: ContributorDataJsonApi): ContributorModel { + const userEmbed = response.embeds.users; + const errorMeta = userEmbed?.errors && userEmbed.errors.length > 0 ? userEmbed.errors[0]?.meta : null; + const userData = userEmbed?.data; + return { id: response.id, - userId: response.embeds?.users?.data?.id || '', type: response.type, isBibliographic: response.attributes.bibliographic, isUnregisteredContributor: !!response.attributes.unregistered_contributor, isCurator: response.attributes.is_curator, permission: response.attributes.permission, index: response.attributes.index, - fullName: response.embeds?.users?.data?.attributes?.full_name || '', - givenName: response.embeds?.users?.data?.attributes?.given_name || '', - familyName: response.embeds?.users?.data?.attributes?.family_name || '', - education: response.embeds?.users?.data?.attributes?.education || '', - employment: response.embeds?.users?.data?.attributes?.employment || '', + userId: errorMeta ? '' : userData?.id || '', + fullName: errorMeta ? errorMeta?.full_name : userData?.attributes?.full_name || '', + givenName: errorMeta ? errorMeta?.given_name : userData?.attributes?.given_name || '', + familyName: errorMeta ? errorMeta?.family_name : userData?.attributes?.family_name || '', + education: errorMeta ? [] : userData?.attributes?.education || [], + employment: errorMeta ? [] : userData?.attributes?.employment || [], }; } static getContributorShortInfo(response: ContributorDataJsonApi[] | undefined): ContributorShortInfoModel[] { - const contributors = this.fromResponse(response); + const contributors = this.getContributors(response); return contributors.map((contributor) => ({ id: contributor.id, userId: contributor.userId, fullName: contributor.fullName, + isUnregisteredContributor: contributor.isUnregisteredContributor, + isBibliographic: contributor.isBibliographic, + index: contributor.index, + permission: contributor.permission, })); } - static fromUsersWithPaginationGetResponse( - response: ResponseJsonApi - ): PaginatedData { + static getPaginatedUsers(response: ResponseJsonApi): PaginatedData { return { data: response.data.map( (user) => diff --git a/src/app/shared/mappers/duplicates.mapper.ts b/src/app/shared/mappers/duplicates.mapper.ts index 9ce728059..b003f6909 100644 --- a/src/app/shared/mappers/duplicates.mapper.ts +++ b/src/app/shared/mappers/duplicates.mapper.ts @@ -16,7 +16,7 @@ export class DuplicatesMapper { dateModified: duplicate.attributes.date_modified, public: duplicate.attributes.public, currentUserPermissions: duplicate.attributes.current_user_permissions, - contributors: ContributorsMapper.getContributorShortInfo(duplicate.embeds.bibliographic_contributors.data), + contributors: ContributorsMapper.getContributors(duplicate.embeds.bibliographic_contributors.data), })), totalCount: response.meta.total, }; diff --git a/src/app/shared/mappers/registration/registration.mapper.ts b/src/app/shared/mappers/registration/registration.mapper.ts index 71ac07cf5..efc7eb644 100644 --- a/src/app/shared/mappers/registration/registration.mapper.ts +++ b/src/app/shared/mappers/registration/registration.mapper.ts @@ -68,7 +68,7 @@ export class RegistrationMapper { registrationTemplate: registration.embeds?.registration_schema?.data?.attributes?.name || '', registry: registration.embeds?.provider?.data?.attributes?.name || '', public: registration.attributes.public, - contributors: ContributorsMapper.getContributorShortInfo(registration.embeds?.bibliographic_contributors?.data), + contributors: ContributorsMapper.getContributors(registration.embeds?.bibliographic_contributors?.data), currentUserPermissions: registration.attributes.current_user_permissions, }; } @@ -91,7 +91,7 @@ export class RegistrationMapper { hasMaterials: registration.attributes.has_materials, hasPapers: registration.attributes.has_papers, hasSupplements: registration.attributes.has_supplements, - contributors: ContributorsMapper.getContributorShortInfo(registration.embeds?.bibliographic_contributors?.data), + contributors: ContributorsMapper.getContributors(registration?.embeds?.bibliographic_contributors?.data), rootParentId: registration.relationships.root?.data?.id, currentUserPermissions: registration.attributes.current_user_permissions, }; diff --git a/src/app/shared/models/collections/collections.models.ts b/src/app/shared/models/collections/collections.models.ts index f26e1b5d8..eba654ae7 100644 --- a/src/app/shared/models/collections/collections.models.ts +++ b/src/app/shared/models/collections/collections.models.ts @@ -1,7 +1,7 @@ import { CollectionSubmissionReviewAction } from '@osf/features/moderation/models'; import { Brand } from '../brand.model'; -import { ContributorShortInfoModel } from '../contributors'; +import { ContributorModel } from '../contributors'; import { BaseProviderModel } from '../provider'; export interface CollectionProvider extends BaseProviderModel { @@ -83,7 +83,7 @@ export interface CollectionSubmissionWithGuid { dataType: string; disease: string; gradeLevels: string; - contributors?: ContributorShortInfoModel[]; + contributors?: ContributorModel[]; creator?: { id: string; fullName: string; diff --git a/src/app/shared/models/components/components.models.ts b/src/app/shared/models/components/components.models.ts index be72c402a..ed25e28c2 100644 --- a/src/app/shared/models/components/components.models.ts +++ b/src/app/shared/models/components/components.models.ts @@ -1,19 +1,14 @@ import { UserPermissions } from '@osf/shared/enums'; +import { ContributorDataJsonApi, ContributorModel } from '../contributors'; + export interface ComponentOverview { id: string; type: string; title: string; description: string; public: boolean; - contributors: { - familyName: string; - fullName: string; - givenName: string; - middleName: string; - id: string; - type: string; - }[]; + contributors: ContributorModel[]; currentUserPermissions: UserPermissions[]; } @@ -28,22 +23,7 @@ export interface ComponentGetResponseJsonApi { }; embeds: { bibliographic_contributors: { - data: { - embeds: { - users: { - data: { - id: string; - type: string; - attributes: { - family_name: string; - full_name: string; - given_name: string; - middle_name: string; - }; - }; - }; - }; - }[]; + data: ContributorDataJsonApi[]; }; }; } diff --git a/src/app/shared/models/contributors/contributor.model.ts b/src/app/shared/models/contributors/contributor.model.ts index 7630906df..2272110b8 100644 --- a/src/app/shared/models/contributors/contributor.model.ts +++ b/src/app/shared/models/contributors/contributor.model.ts @@ -17,4 +17,7 @@ export interface ContributorModel { education: Education[]; } -export type ContributorShortInfoModel = Pick; +export type ContributorShortInfoModel = Pick< + ContributorModel, + 'id' | 'userId' | 'fullName' | 'isUnregisteredContributor' | 'isBibliographic' | 'index' | 'permission' +>; diff --git a/src/app/shared/models/duplicates/duplicate.model.ts b/src/app/shared/models/duplicates/duplicate.model.ts index d940c9558..7edeb6d13 100644 --- a/src/app/shared/models/duplicates/duplicate.model.ts +++ b/src/app/shared/models/duplicates/duplicate.model.ts @@ -1,4 +1,4 @@ -import { ContributorShortInfoModel } from '../contributors'; +import { ContributorModel } from '../contributors'; export interface Duplicate { id: string; @@ -9,7 +9,7 @@ export interface Duplicate { dateModified: string; public: boolean; currentUserPermissions: string[]; - contributors: ContributorShortInfoModel[]; + contributors: ContributorModel[]; } export interface DuplicatesWithTotal { diff --git a/src/app/shared/models/my-resources/my-resources.models.ts b/src/app/shared/models/my-resources/my-resources.models.ts index 201a4d117..e5f268377 100644 --- a/src/app/shared/models/my-resources/my-resources.models.ts +++ b/src/app/shared/models/my-resources/my-resources.models.ts @@ -1,4 +1,4 @@ -import { ContributorDataJsonApi, ContributorShortInfoModel, ResponseJsonApi } from '@shared/models'; +import { ContributorDataJsonApi, ContributorModel, ResponseJsonApi } from '@shared/models'; export type MyResourcesItemResponseJsonApi = ResponseJsonApi; @@ -20,13 +20,6 @@ export interface MyResourcesItemGetResponseJsonApi { }; } -export interface MyResourcesContributor { - familyName: string; - fullName: string; - givenName: string; - middleName: string; -} - export interface MyResourcesItem { id: string; type: string; @@ -34,5 +27,5 @@ export interface MyResourcesItem { dateCreated: string; dateModified: string; isPublic: boolean; - contributors: ContributorShortInfoModel[]; + contributors: ContributorModel[]; } diff --git a/src/app/shared/models/registration/registration-card.model.ts b/src/app/shared/models/registration/registration-card.model.ts index 625b4995d..af67f9011 100644 --- a/src/app/shared/models/registration/registration-card.model.ts +++ b/src/app/shared/models/registration/registration-card.model.ts @@ -9,7 +9,7 @@ export interface RegistrationCard { status: RegistryStatus; dateCreated: string; dateModified: string; - contributors: Partial[]; + contributors: ContributorModel[]; registrationTemplate: string; registry: string; resources?: Record; diff --git a/src/app/shared/models/resource-overview.model.ts b/src/app/shared/models/resource-overview.model.ts index 30fc7132c..963580adf 100644 --- a/src/app/shared/models/resource-overview.model.ts +++ b/src/app/shared/models/resource-overview.model.ts @@ -1,6 +1,5 @@ -import { ProjectOverviewContributor } from '@osf/features/project/overview/models'; - import { IdTypeModel } from './common'; +import { ContributorModel } from './contributors'; import { Identifier } from './identifiers'; import { Institution } from './institutions'; import { LicensesOption } from './license.model'; @@ -50,7 +49,7 @@ export interface ResourceOverview { currentUserIsContributorOrGroupMember: boolean; wikiEnabled: boolean; subjects: SubjectModel[]; - contributors: ProjectOverviewContributor[]; + contributors: ContributorModel[]; customCitation: string | null; region?: IdTypeModel; affiliatedInstitutions?: Institution[]; diff --git a/src/app/shared/services/collections.service.ts b/src/app/shared/services/collections.service.ts index fd21cc40c..6f903ce05 100644 --- a/src/app/shared/services/collections.service.ts +++ b/src/app/shared/services/collections.service.ts @@ -24,7 +24,7 @@ import { CollectionSubmissionTargetType, CollectionSubmissionWithGuid, CollectionSubmissionWithGuidJsonApi, - ContributorShortInfoModel, + ContributorModel, ContributorsResponseJsonApi, JsonApiResponse, PaginatedData, @@ -201,14 +201,14 @@ export class CollectionsService { >(`${this.apiUrl}/collection_submission_actions/`, params); } - private getCollectionContributors(contributorsUrl: string): Observable { + private getCollectionContributors(contributorsUrl: string): Observable { const params: Record = { 'fields[users]': 'full_name', }; return this.jsonApiService .get(contributorsUrl, params) - .pipe(map((response) => ContributorsMapper.getContributorShortInfo(response.data))); + .pipe(map((response) => ContributorsMapper.getContributors(response.data))); } private fetchUserCollectionSubmissionsByStatus( diff --git a/src/app/shared/services/contributors.service.ts b/src/app/shared/services/contributors.service.ts index 86d87823b..e350ed35a 100644 --- a/src/app/shared/services/contributors.service.ts +++ b/src/app/shared/services/contributors.service.ts @@ -52,7 +52,7 @@ export class ContributorsService { return this.jsonApiService .get(`${baseUrl}/`) - .pipe(map((response) => ContributorsMapper.fromResponse(response.data))); + .pipe(map((response) => ContributorsMapper.getContributors(response.data))); } searchUsers(value: string, page = 1): Observable> { @@ -60,7 +60,7 @@ export class ContributorsService { return this.jsonApiService .get>(baseUrl) - .pipe(map((response) => ContributorsMapper.fromUsersWithPaginationGetResponse(response))); + .pipe(map((response) => ContributorsMapper.getPaginatedUsers(response))); } addContributor( @@ -75,7 +75,7 @@ export class ContributorsService { return this.jsonApiService .post(baseUrl, contributorData) - .pipe(map((contributor) => ContributorsMapper.fromContributorResponse(contributor.data))); + .pipe(map((contributor) => ContributorsMapper.getContributor(contributor.data))); } updateContributor( @@ -89,7 +89,7 @@ export class ContributorsService { return this.jsonApiService .patch(baseUrl, contributorData) - .pipe(map((contributor) => ContributorsMapper.fromContributorResponse(contributor))); + .pipe(map((contributor) => ContributorsMapper.getContributor(contributor))); } deleteContributor(resourceType: ResourceType, resourceId: string, userId: string): Observable { diff --git a/src/app/shared/services/files.service.ts b/src/app/shared/services/files.service.ts index 8970afbe4..b7da9c0d5 100644 --- a/src/app/shared/services/files.service.ts +++ b/src/app/shared/services/files.service.ts @@ -232,10 +232,10 @@ export class FilesService { ); } - getResourceContributors(resourceId: string, resourceType: string): Observable[]> { + getResourceContributors(resourceId: string, resourceType: string): Observable { return this.jsonApiService .get(`${this.apiUrl}/${resourceType}/${resourceId}/bibliographic_contributors/`) - .pipe(map((response) => ContributorsMapper.fromResponse(response.data))); + .pipe(map((response) => ContributorsMapper.getContributors(response.data))); } patchFileMetadata(data: PatchFileMetadata, fileGuid: string): Observable {