Skip to content

Commit

Permalink
fix(catalogue): add missing resource types and otherwise use raw type…
Browse files Browse the repository at this point in the history
… name (#4348)
  • Loading branch information
mswertz authored Oct 17, 2024
1 parent a820887 commit 5ae0013
Show file tree
Hide file tree
Showing 6 changed files with 38 additions and 13 deletions.
2 changes: 1 addition & 1 deletion apps/nuxt3-ssr/components/header/Catalogue.vue
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ if (
if (props.resourceTypes.length > 0) {
props.resourceTypes.forEach((resourceType) => {
const resourceTypeMetadata = getResourceMetadataForType(
resourceType.type.name
resourceType.type?.name
);
menu.push({
label: resourceTypeMetadata.plural,
Expand Down
7 changes: 4 additions & 3 deletions apps/nuxt3-ssr/composables/usePathResourceType.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,11 @@ export const usePathResourceType = () => {
Object.values(typeMetadata).filter(
(value: IResourceTypeMetadata) => value.path === resourceType
)?.[0] || {
type: "Resource",
plural: "Resources",
type: resourceType,
plural: resourceType,
image: "image-link",
path: "resources",
path: resourceType,
description: resourceType,
}
);
};
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ let pageFilterTemplate: IFilter[] = [
},
];
if (resourceType.path === "resources") {
if (route.params.resourceType === "resources") {
pageFilterTemplate.push({
id: "type",
config: {
Expand Down Expand Up @@ -168,7 +168,7 @@ const gqlFilter = computed(() => {
result = buildQueryFilter(filters.value);
if (resourceType.path != "resources") {
if (route.params.resourceType != "resources") {
result.type = { name: { equals: resourceType.type } };
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -175,11 +175,13 @@ const aboutLink = `/${route.params.schema}/ssr-catalogue/${catalogueRouteParam}/
const resources = computed(() => {
if (cohortOnly.value) {
return data.value.data.Resources_groupBy.filter(
(resource: { type: { name: string } }) =>
resource.type.name === "Cohort study"
(resource: IResources) => resource.type.name === "Cohort study"
);
} else {
return data.value.data.Resources_groupBy;
//omit counts of resources without a type
return data.value.data.Resources_groupBy.filter(
(resource: IResources) => resource.type
);
}
});
</script>
Expand Down
28 changes: 25 additions & 3 deletions apps/nuxt3-ssr/utils/CollectionUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,27 @@ export const typeMetadata: IResourceTypeMetadata[] = [
description: "Networks & Consortia",
},
{ type: "Study", plural: "Studies", path: "studies" },
{
type: "Clinical trial",
plural: "Clinical Trials",
path: "trials",
image: "image-data-warehouse",
description: "Prospective collection with intervention(s)",
},
{
type: "Common data model",
plural: "Common data models",
path: "cdms",
image: "image-data-warehouse",
description: "For data harmonization",
},
{
type: "Other type",
plural: "Other types",
path: "other-types",
image: "image-data-warehouse",
description: "Other type of resource",
},
];

export function getResourceMetadataForType(
Expand All @@ -44,10 +65,11 @@ export function getResourceMetadataForType(
Object.values(typeMetadata).filter(
(value: IResourceTypeMetadata) => value.type === type
)?.[0] || {
type: "Resource",
plural: "Resources",
type: type,
plural: type,
image: "image-link",
path: "resources",
path: type,
description: type,
}
);
}
2 changes: 1 addition & 1 deletion apps/nuxt3-ssr/utils/errorLogger.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ export const logError = (error: IMgError, contextMsg?: string) => {

console.log(`[ERROR] StatusCode: ${error.statusCode}`);
console.log(`[ERROR] Message: ${error.message}`);
if (error.data.errors) {
if (error.data?.errors) {
console.log("[ERROR] MESSAGES FROM API: ");
error.data.errors.forEach((e: { message: string }, lineNr) =>
console.log(` ${lineNr}: ${e.message}`)
Expand Down

0 comments on commit 5ae0013

Please sign in to comment.