Skip to content

Commit 4fdc9b2

Browse files
authored
Merge branch 'main' into 310-add-rendering-for-spdx-licenses
2 parents 15a873b + 1359fde commit 4fdc9b2

File tree

1 file changed

+54
-28
lines changed
  • packages/stencil-library/src/rendererModules

1 file changed

+54
-28
lines changed

packages/stencil-library/src/rendererModules/RORType.tsx

Lines changed: 54 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,45 @@ export class RORType extends GenericIdentifierType {
1414
private label: string;
1515
private acronym: string;
1616

17+
private relationshipTypes = {
18+
parent: {
19+
title: 'Parent Organization',
20+
tooltip: 'Organization that this organization is part of',
21+
},
22+
child: {
23+
title: 'Child Organization',
24+
tooltip: 'Organization that is part of this organization',
25+
},
26+
related: {
27+
title: 'Related Organization',
28+
tooltip: 'Organization that is related to this organization',
29+
},
30+
predecessor: {
31+
title: 'Predecessor Organization',
32+
tooltip: 'Organization that preceded this organization',
33+
},
34+
successor: {
35+
title: 'Successor Organization',
36+
tooltip: 'Organization that succeeded this organization',
37+
},
38+
};
39+
40+
private contentMappings = {
41+
active: '🟢 Active',
42+
inactive: '⚪️ Inactive',
43+
withdrawn: '⚠️ Withdrawn',
44+
education: '🏫 Education',
45+
funder: '💰 Funder',
46+
healthcare: '🏥 Healthcare',
47+
company: '🏢 Company',
48+
archive: '📚 Archive',
49+
nonprofit: '🎗️ Nonprofit',
50+
government: '🏛️ Government',
51+
facility: '🔬 Facility',
52+
other: 'Other',
53+
unknown: '❓ Unknown',
54+
};
55+
1756
getSettingsKey(): string {
1857
return 'RORType';
1958
}
@@ -36,6 +75,15 @@ export class RORType extends GenericIdentifierType {
3675
return this.value.split('/').pop();
3776
}
3877

78+
private getOptimizedContent(content: string): string {
79+
// Check if the content is in the contentMappings
80+
if (this.contentMappings[content.toLowerCase()]) {
81+
return this.contentMappings[content.toLowerCase()];
82+
}
83+
// If not, return the content as is
84+
return content;
85+
}
86+
3987
/**
4088
* Fetches organization data from the ROR API v2
4189
* @returns {Promise<void>}
@@ -82,14 +130,15 @@ export class RORType extends GenericIdentifierType {
82130
this.actions.push(new FoldableAction(10, 'View on ROR', this.rorData.id, 'primary'));
83131

84132
// Add status of the organization
85-
this.items.push(new FoldableItem(30, 'Status', this.rorData.status || 'Unknown', 'Current status of the organization in the ROR registry'));
133+
134+
this.items.push(new FoldableItem(30, 'Status', this.getOptimizedContent(this.rorData.status || 'unknown'), 'Current status of the organization in the ROR registry'));
86135

87136
// Add types of the organization
88137
if (!this.rorData.types || this.rorData.types.length === 0) {
89-
this.items.push(new FoldableItem(25, 'Type', 'Unknown', 'Type of organization'));
138+
this.items.push(new FoldableItem(25, 'Type', this.getOptimizedContent('unknown'), 'Type of organization'));
90139
} else {
91140
for (const type of this.rorData.types) {
92-
this.items.push(new FoldableItem(25, 'Type', type, 'Type of organization'));
141+
this.items.push(new FoldableItem(25, 'Type', this.getOptimizedContent(type), 'Type of organization'));
93142
}
94143
}
95144

@@ -115,33 +164,10 @@ export class RORType extends GenericIdentifierType {
115164

116165
// Add related organizations with tooltips for relationship types
117166
if (this.rorData.relationships && this.rorData.relationships.length > 0) {
118-
const relationshipTypes = {
119-
parent: {
120-
title: 'Parent Organization',
121-
tooltip: 'Organization that this organization is part of',
122-
},
123-
child: {
124-
title: 'Child Organization',
125-
tooltip: 'Organization that is part of this organization',
126-
},
127-
related: {
128-
title: 'Related Organization',
129-
tooltip: 'Organization that is related to this organization',
130-
},
131-
predecessor: {
132-
title: 'Predecessor Organization',
133-
tooltip: 'Organization that preceded this organization',
134-
},
135-
successor: {
136-
title: 'Successor Organization',
137-
tooltip: 'Organization that succeeded this organization',
138-
},
139-
};
140-
141167
for (const rel of this.rorData.relationships) {
142-
const relationType = relationshipTypes[rel.type] || { title: rel.type, tooltip: `${rel.type} organization` };
168+
const relationType = this.relationshipTypes[rel.type] || { title: rel.type, tooltip: `${rel.type} organization` };
143169

144-
this.items.push(new FoldableItem(90, relationType.title, `https://ror.org/${rel.id}`, relationType.tooltip));
170+
this.items.push(new FoldableItem(90, relationType.title, rel.id, relationType.tooltip));
145171
}
146172
}
147173

0 commit comments

Comments
 (0)