Skip to content

Commit e8cca2f

Browse files
Merge pull request #208 from CenterForOpenScience/feat/214
Feat/214 registration components
2 parents 927b464 + 84fd04a commit e8cca2f

25 files changed

+403
-24
lines changed

src/app/features/registry/components/registration-links-card/registration-links-card.component.html

Lines changed: 26 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,20 @@ <h2 class="align-self-center">
1313
</div>
1414
<div class="flex flex-wrap flex-column lg:flex-nowrap lg:flex-row justify-content-between gap-5">
1515
<div class="flex gap-3 flex-column w-full">
16+
@if (isComponentData() && componentsDataTyped()?.registrationSupplement) {
17+
<div class="flex gap-2 align-items-baseline">
18+
<strong>{{ 'project.registrations.card.registrationTemplate' | translate }}</strong>
19+
<span>{{ componentsDataTyped()!.registrationSupplement }}</span>
20+
</div>
21+
}
22+
23+
@if (isComponentData() && componentsDataTyped()?.registry) {
24+
<div class="flex gap-2">
25+
<strong>{{ 'project.registrations.card.registry' | translate }}</strong>
26+
<span>{{ componentsDataTyped()!.registry }}</span>
27+
</div>
28+
}
29+
1630
<div class="flex gap-2 align-items-baseline">
1731
<strong>{{ 'project.registrations.card.registered' | translate }}</strong>
1832
<span>{{ registrationData().dateCreated | date: 'medium' }}</span>
@@ -88,20 +102,18 @@ <h2 class="align-self-center">
88102
</div>
89103
</div>
90104

91-
@if (hasResources()) {
92-
<div class="flex flex-column min-w-max">
93-
<h3 class="mb-1">{{ 'shared.resources.title' | translate }}</h3>
94-
<osf-data-resources
95-
[vertical]="true"
96-
[resourceId]="registrationData().id"
97-
[hasData]="registrationDataTyped()?.hasData"
98-
[hasAnalyticCode]="registrationDataTyped()?.hasAnalyticCode"
99-
[hasMaterials]="registrationDataTyped()?.hasMaterials"
100-
[hasPapers]="registrationDataTyped()?.hasPapers"
101-
[hasSupplements]="registrationDataTyped()?.hasSupplements"
102-
></osf-data-resources>
103-
</div>
104-
}
105+
<div class="flex flex-column min-w-max">
106+
<h3 class="mb-1">{{ 'shared.resources.title' | translate }}</h3>
107+
<osf-data-resources
108+
[vertical]="true"
109+
[resourceId]="registrationData().id"
110+
[hasData]="registrationDataTyped()?.hasData || isComponentData()"
111+
[hasAnalyticCode]="registrationDataTyped()?.hasAnalyticCode || isComponentData()"
112+
[hasMaterials]="registrationDataTyped()?.hasMaterials || isComponentData()"
113+
[hasPapers]="registrationDataTyped()?.hasPapers || isComponentData()"
114+
[hasSupplements]="registrationDataTyped()?.hasSupplements || isComponentData()"
115+
></osf-data-resources>
116+
</div>
105117
</div>
106118
</div>
107119
}

src/app/features/registry/components/registration-links-card/registration-links-card.component.ts

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import { Card } from 'primeng/card';
66
import { DatePipe } from '@angular/common';
77
import { ChangeDetectionStrategy, Component, computed, input, output } from '@angular/core';
88

9-
import { LinkedNode, LinkedRegistration } from '@osf/features/registry/models';
9+
import { LinkedNode, LinkedRegistration, RegistryComponentModel } from '@osf/features/registry/models';
1010
import { DataResourcesComponent, TruncatedTextComponent } from '@shared/components';
1111
import { RevisionReviewStates } from '@shared/enums';
1212

@@ -18,7 +18,8 @@ import { RevisionReviewStates } from '@shared/enums';
1818
changeDetection: ChangeDetectionStrategy.OnPush,
1919
})
2020
export class RegistrationLinksCardComponent {
21-
readonly registrationData = input.required<LinkedRegistration | LinkedNode>();
21+
readonly registrationData = input.required<LinkedRegistration | LinkedNode | RegistryComponentModel>();
22+
2223
readonly updateEmitRegistrationData = output<string>();
2324
readonly reviewEmitRegistrationData = output<string>();
2425

@@ -29,16 +30,18 @@ export class RegistrationLinksCardComponent {
2930
return 'reviewsState' in data;
3031
});
3132

33+
protected readonly isComponentData = computed(() => {
34+
const data = this.registrationData();
35+
return 'registrationSupplement' in data;
36+
});
37+
3238
protected readonly registrationDataTyped = computed(() => {
3339
const data = this.registrationData();
3440
return this.isRegistrationData() ? (data as LinkedRegistration) : null;
3541
});
3642

37-
protected readonly hasResources = computed(() => {
38-
const regData = this.registrationDataTyped();
39-
if (!regData) return false;
40-
return (
41-
regData.hasData || regData.hasAnalyticCode || regData.hasMaterials || regData.hasPapers || regData.hasSupplements
42-
);
43+
protected readonly componentsDataTyped = computed(() => {
44+
const data = this.registrationData();
45+
return this.isComponentData() ? (data as RegistryComponentModel) : null;
4346
});
4447
}

src/app/features/registry/mappers/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ export * from './bibliographic-contributors.mapper';
33
export * from './cedar-form.mapper';
44
export * from './linked-nodes.mapper';
55
export * from './linked-registrations.mapper';
6+
export * from './registry-components.mapper';
67
export * from './registry-metadata.mapper';
78
export * from './registry-overview.mapper';
89
export * from './registry-resource.mapper';
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
import { RegistryComponentModel } from '../models/registry-components.models';
2+
import { RegistryComponentJsonApi } from '../models/registry-components-json-api.model';
3+
4+
export class RegistryComponentsMapper {
5+
static fromApiResponse(apiComponent: RegistryComponentJsonApi): RegistryComponentModel {
6+
return {
7+
id: apiComponent.id,
8+
title: apiComponent.attributes.title,
9+
description: apiComponent.attributes.description,
10+
category: apiComponent.attributes.category,
11+
dateCreated: apiComponent.attributes.date_created,
12+
dateModified: apiComponent.attributes.date_modified,
13+
dateRegistered: apiComponent.attributes.date_registered,
14+
registrationSupplement: apiComponent.attributes.registration_supplement,
15+
tags: apiComponent.attributes.tags,
16+
isPublic: apiComponent.attributes.public,
17+
};
18+
}
19+
20+
static fromApiResponseArray(apiComponents: RegistryComponentJsonApi[]): RegistryComponentModel[] {
21+
return apiComponents.map(this.fromApiResponse);
22+
}
23+
}

src/app/features/registry/mappers/registry-overview.mapper.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@ export function MapRegistryOverview(data: RegistryOverviewJsonApiData): Registry
6060
revisionResponses: schemaResponse.attributes?.revision_responses,
6161
updatedResponseKeys: schemaResponse.attributes?.updated_response_keys,
6262
})),
63+
registry: data.embeds.provider.data.attributes.name,
6364
status: MapRegistryStatus(data.attributes),
6465
revisionStatus: data.attributes.revision_state,
6566
reviewsState: data.attributes.reviews_state,

src/app/features/registry/models/get-registry-overview-json-api.model.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,13 @@ export interface RegistryOverviewJsonApiEmbed {
114114
};
115115
}[];
116116
};
117+
provider: {
118+
data: {
119+
attributes: {
120+
name: string;
121+
};
122+
};
123+
};
117124
}
118125

119126
export interface RegistryOverviewJsonApiRelationships {

src/app/features/registry/models/index.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@ export * from './linked-nodes.models';
77
export * from './linked-nodes-json-api.model';
88
export * from './linked-registrations-json-api.model';
99
export * from './linked-response.models';
10+
export * from './registry-components.models';
11+
export * from './registry-components-json-api.model';
1012
export * from './registry-contributor-json-api.model';
1113
export * from './registry-institution.model';
1214
export * from './registry-institutions-json-api.model';
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
import { RegistryComponentModel } from './registry-components.models';
2+
3+
export interface RegistryComponentJsonApi {
4+
id: string;
5+
type: string;
6+
attributes: {
7+
title: string;
8+
description: string;
9+
category: string;
10+
date_created: string;
11+
date_modified: string;
12+
date_registered: string;
13+
registration_supplement: string;
14+
tags: string[];
15+
public: boolean;
16+
};
17+
}
18+
19+
export interface RegistryComponentsJsonApiResponse {
20+
data: RegistryComponentJsonApi[];
21+
meta: {
22+
total: number;
23+
per_page: number;
24+
};
25+
}
26+
27+
export interface RegistryComponentsResponseJsonApi {
28+
data: RegistryComponentModel[];
29+
meta: { total: number; per_page: number };
30+
}
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
import { NodeBibliographicContributor } from './bibliographic-contributors.models';
2+
3+
export interface RegistryComponentModel {
4+
id: string;
5+
title: string;
6+
description: string;
7+
category: string;
8+
dateCreated: string;
9+
dateModified: string;
10+
dateRegistered: string;
11+
registrationSupplement: string;
12+
tags: string[];
13+
isPublic: boolean;
14+
contributorsCount?: number;
15+
contributors?: NodeBibliographicContributor[];
16+
registry?: string;
17+
}

src/app/features/registry/models/registry-overview.models.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ export interface RegistryOverview {
1616
registrationType: string;
1717
doi: string;
1818
tags: string[];
19+
registry?: string;
1920
contributors: ProjectOverviewContributor[];
2021
citation: string;
2122
category: string;

0 commit comments

Comments
 (0)