-
Notifications
You must be signed in to change notification settings - Fork 19
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(data/biobank-directory): fixes Study model
- Loading branch information
Showing
6 changed files
with
240 additions
and
4 deletions.
There are no files selected for viewing
38 changes: 38 additions & 0 deletions
38
apps/directory/src/components/report-components/ReportStudyDetails.vue
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
<template> | ||
<div> | ||
<div class="d-flex"> | ||
<report-description | ||
:description="study.description" | ||
:maxLength="500" | ||
></report-description> | ||
</div> | ||
|
||
<!-- study information --> | ||
<view-generator :viewmodel="studyModel.viewmodel" /> | ||
</div> | ||
</template> | ||
|
||
<script> | ||
import { getStudyDetails } from "../../functions/viewmodelMapper"; | ||
import ReportDescription from "../report-components/ReportDescription.vue"; | ||
import ViewGenerator from "../generators/ViewGenerator.vue"; | ||
export default { | ||
name: "ReportStudyDetails", | ||
props: { | ||
study: { | ||
type: Object, | ||
required: true, | ||
}, | ||
}, | ||
components: { | ||
ReportDescription, | ||
ViewGenerator, | ||
}, | ||
computed: { | ||
studyModel() { | ||
return this.study ? getStudyDetails(this.study) : {}; | ||
}, | ||
}, | ||
}; | ||
</script> |
44 changes: 44 additions & 0 deletions
44
apps/directory/src/components/report-components/StudyReportInfoCard.vue
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
<template> | ||
<div class="col-md-4"> | ||
<div class="card"> | ||
<div class="card-body"> | ||
<div class="card-text"> | ||
<template v-if="info.also_known"> | ||
<h5>Also Known In</h5> | ||
<ReportDetailsList :reportDetails="info.also_known" /> | ||
</template> | ||
</div> | ||
</div> | ||
</div> | ||
</div> | ||
</template> | ||
|
||
<script setup> | ||
import { toRefs } from "vue"; | ||
import ReportDetailsList from "../../components/report-components/ReportDetailsList.vue"; | ||
const props = defineProps(["info"]); | ||
let { info } = toRefs(props); | ||
</script> | ||
|
||
<style scoped> | ||
.right-content-list { | ||
list-style-type: none; | ||
margin-left: -2.5rem; | ||
} | ||
.right-content-list:not(:last-child) { | ||
margin-bottom: 1.5rem; | ||
} | ||
.right-content-list li { | ||
margin-bottom: 0.5rem; | ||
} | ||
.info-list { | ||
margin-bottom: 1rem; | ||
} | ||
.cert-badge:not(:last-child) { | ||
margin-right: 1rem; | ||
} | ||
</style> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
const initialStudyColumns = [ | ||
{ label: "Id:", column: "id", type: "string", showCopyIcon: true }, | ||
{ label: "Title:", column: "title", type: "string" }, | ||
{ label: "Description:", column: "description", type: "string" }, | ||
{ label: "Type:", column: "type", type: "string" }, | ||
{ label: "Sex:", column: { sex: ["label"] }, type: "array" }, | ||
{ label: "Number of subjects:", column: "number_of_subjects", type: "int" }, | ||
{ | ||
label: "Age:", | ||
type: "range", | ||
min: "age_high", | ||
max: "age_low", | ||
unit: "age_unit", | ||
unit_column: { age_unit: ["label"] }, | ||
}, | ||
{ | ||
label: "Also Known In:", | ||
column: { also_known: ["name_system", "url"] }, | ||
type: "xref", | ||
}, | ||
]; | ||
|
||
export default initialStudyColumns; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
import { defineStore } from "pinia"; | ||
import { QueryEMX2 } from "molgenis-components"; | ||
import { useSettingsStore } from "./settingsStore"; | ||
|
||
export const useStudyStore = defineStore("studyStore", () => { | ||
const settingsStore = useSettingsStore(); | ||
|
||
const studyColumns = settingsStore.config.studyColumns; | ||
const graphqlEndpoint = settingsStore.config.graphqlEndpoint; | ||
|
||
function getStudyColumns() { | ||
const properties = studyColumns | ||
.filter((column) => column.column) | ||
.flatMap((studyColumn) => studyColumn.column); | ||
|
||
const rangeProperties = studyColumns.filter( | ||
(column) => column.type === "range" | ||
); | ||
|
||
for (const property of rangeProperties) { | ||
properties.push(property.min, property.max, property.unit_column); | ||
} | ||
|
||
return properties; | ||
} | ||
|
||
async function getStudyReport(id) { | ||
const studyReportQuery = new QueryEMX2(graphqlEndpoint) | ||
.table("Studies") | ||
.select(getStudyColumns()) | ||
.orderBy("Studies", "id", "asc") | ||
.where("id") | ||
.like(id); | ||
const reportResults = await studyReportQuery.execute(); | ||
|
||
return reportResults; | ||
} | ||
|
||
return { | ||
getStudyColumns, | ||
getStudyReport, | ||
}; | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,87 @@ | ||
<template> | ||
<div class="container mg-network-report-card"> | ||
<div | ||
v-if="!loaded" | ||
class="d-flex justify-content-center align-items-center spinner-container" | ||
> | ||
<Spinner /> | ||
</div> | ||
<div v-else class="container-fluid"> | ||
<div class="row"> | ||
<div class="col my-3 shadow-sm d-flex p-2 align-items-center bg-white"> | ||
<Breadcrumb | ||
class="directory-nav" | ||
:crumbs="{ | ||
[uiText['home']]: '../#/', | ||
[study.title]: '/', | ||
}" | ||
/> | ||
</div> | ||
</div> | ||
|
||
<div class="row" v-if="study"> | ||
<div class="col"> | ||
<report-title type="Study" :name="study.title" /> | ||
<div class="container"> | ||
<div class="row"> | ||
<div class="container p-0"> | ||
<div class="row"> | ||
<div class="col-md-8"> | ||
<report-study-details v-if="study" :study="study" /> | ||
</div> | ||
<study-report-info-card :info="info" /> | ||
</div> | ||
</div> | ||
</div> | ||
</div> | ||
</div> | ||
</div> | ||
</div> | ||
</div> | ||
</template> | ||
|
||
<script setup> | ||
import { Breadcrumb, Spinner } from "molgenis-components"; | ||
import { computed, ref, watch } from "vue"; | ||
import { useRoute } from "vue-router"; | ||
import ReportStudyDetails from "../components/report-components/ReportStudyDetails.vue"; | ||
import StudyReportInfoCard from "../components/report-components/StudyReportInfoCard.vue"; | ||
import ReportTitle from "../components/report-components/ReportTitle.vue"; | ||
import { studyReportInformation } from "../functions/viewmodelMapper"; | ||
import { useStudyStore } from "../stores/studyStore"; | ||
import { useSettingsStore } from "../stores/settingsStore"; | ||
const settingsStore = useSettingsStore(); | ||
const studyStore = useStudyStore(); | ||
const route = useRoute(); | ||
const study = ref({}); | ||
let loaded = ref(false); | ||
loadStudyReport(route.params.id); | ||
watch(route, async (route) => { | ||
loadStudyReport(route.params.id); | ||
}); | ||
const uiText = computed(() => settingsStore.uiText); | ||
const studyDataAvailable = computed(() => { | ||
return Object.keys(study).length; | ||
}); | ||
const info = computed(() => { | ||
return studyDataAvailable.value ? studyReportInformation(study.value) : {}; | ||
}); | ||
function loadStudyReport(id) { | ||
loaded.value = false; | ||
const studyPromise = studyStore.getStudyReport(id).then((result) => { | ||
study.value = result.Studies.length ? result.Studies[0] : {}; | ||
}); | ||
Promise.all([studyPromise]).then(() => { | ||
loaded.value = true; | ||
}); | ||
} | ||
</script> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters