Skip to content

Commit 1e4385a

Browse files
committed
extract parent Project info
1 parent 12516bd commit 1e4385a

File tree

7 files changed

+19
-4
lines changed

7 files changed

+19
-4
lines changed

src/app/features/contributors/contributors.component.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -270,6 +270,7 @@ export class ContributorsComponent implements OnInit {
270270
addedContributorIds,
271271
components,
272272
resourceName: resourceDetails.title,
273+
parentResourceName: resourceDetails.parent?.title,
273274
allowAddingContributorsFromParentProject:
274275
this.resourceType() === ResourceType.Project &&
275276
resourceDetails.rootParentId &&

src/app/shared/components/contributors/add-contributor-dialog/add-contributor-dialog.component.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@
7474
(onClick)="addSourceProjectContributors()"
7575
[label]="
7676
'project.contributors.addDialog.addingContributorsFromParentProject'
77-
| translate: { projectName: resourceName() }
77+
| translate: { projectName: parentResourceName() }
7878
"
7979
>
8080
</p-button>

src/app/shared/components/contributors/add-contributor-dialog/add-contributor-dialog.component.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,7 @@ export class AddContributorDialogComponent implements OnInit, OnDestroy {
6969
readonly selectedUsers = signal<ContributorAddModel[]>([]);
7070
readonly components = signal<ComponentCheckboxItemModel[]>([]);
7171
readonly resourceName = signal<string>('');
72+
readonly parentResourceName = signal<string>('');
7273
readonly allowAddingContributorsFromParentProject = signal<boolean>(false);
7374

7475
readonly contributorNames = computed(() =>
@@ -134,7 +135,8 @@ export class AddContributorDialogComponent implements OnInit, OnDestroy {
134135
private initializeDialogData(): void {
135136
this.selectedUsers.set([]);
136137

137-
const { components, resourceName, allowAddingContributorsFromParentProject } = this.config.data || {};
138+
const { components, resourceName, parentResourceName, allowAddingContributorsFromParentProject } =
139+
this.config.data || {};
138140

139141
if (components) {
140142
this.components.set(components);
@@ -147,6 +149,10 @@ export class AddContributorDialogComponent implements OnInit, OnDestroy {
147149
if (allowAddingContributorsFromParentProject) {
148150
this.allowAddingContributorsFromParentProject.set(allowAddingContributorsFromParentProject);
149151
}
152+
153+
if (parentResourceName) {
154+
this.parentResourceName.set(parentResourceName);
155+
}
150156
}
151157

152158
private closeDialogWithData(AddContributorTypeValue = AddContributorType.Registered): void {

src/app/shared/mappers/nodes/base-node.mapper.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@ export class BaseNodeMapper {
6060
wikiEnabled: data.attributes.wiki_enabled,
6161
customCitation: data.attributes.custom_citation || undefined,
6262
rootParentId: data.relationships.root?.data?.id,
63+
parent: data.embeds?.parent?.data ? this.getNodeData(data.embeds?.parent.data) : undefined,
6364
};
6465
}
6566

src/app/shared/models/nodes/base-node-embeds-json-api.model.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import {
2+
BaseNodeDataJsonApi,
23
ContributorDataJsonApi,
34
IdentifierAttributes,
45
IdentifiersJsonApiData,
@@ -23,6 +24,9 @@ export interface BaseNodeEmbedsJsonApi {
2324
region?: {
2425
data: RegionDataJsonApi;
2526
};
27+
parent?: {
28+
data: BaseNodeDataJsonApi;
29+
};
2630
}
2731

2832
export interface JsonApiResource<T extends string, A> {

src/app/shared/models/nodes/base-node.model.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ export interface BaseNodeModel {
2323
wikiEnabled: boolean;
2424
rootParentId?: string;
2525
type: string;
26+
parent?: BaseNodeModel;
2627
}
2728

2829
export interface NodeModel extends BaseNodeModel {

src/app/shared/services/resource.service.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,9 +66,11 @@ export class ResourceGuidService {
6666

6767
getResourceDetails(resourceId: string, resourceType: ResourceType): Observable<BaseNodeModel> {
6868
const resourcePath = this.urlMap.get(resourceType);
69-
69+
const params: Record<string, unknown> = {
70+
embed: 'parent',
71+
};
7072
return this.jsonApiService
71-
.get<ResponseDataJsonApi<BaseNodeDataJsonApi>>(`${this.apiUrl}/${resourcePath}/${resourceId}/`)
73+
.get<ResponseDataJsonApi<BaseNodeDataJsonApi>>(`${this.apiUrl}/${resourcePath}/${resourceId}/`, params)
7274
.pipe(map((response) => BaseNodeMapper.getNodeData(response.data)));
7375
}
7476

0 commit comments

Comments
 (0)