Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(catalogue): add missing resource types and otherwise use raw type name #4348

Merged
merged 10 commits into from
Oct 17, 2024
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 @@ -29,7 +29,7 @@ if (route.params.resourceType) {
if (props.resourceTypes.length > 0) {
props.resourceTypes.forEach((resourceType) => {
const resourceTypeMetadata = getResourceMetadataForType(
resourceType.type.name
resourceType.type?.name
mswertz marked this conversation as resolved.
Show resolved Hide resolved
);
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,
mswertz marked this conversation as resolved.
Show resolved Hide resolved
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