From 224e9de309a204c38a8dc7fdfe43f2fcc38860c0 Mon Sep 17 00:00:00 2001 From: naglepuff Date: Fri, 21 Apr 2023 15:32:04 -0400 Subject: [PATCH] Use id instead of study_id This properly filters the NMDC home page to only include the study of interest. This affects clicking on the omics type chips on a study page --- web/src/store/index.ts | 34 +++++++++---------- web/src/views/IndividualResults/StudyPage.vue | 8 ++--- 2 files changed, 21 insertions(+), 21 deletions(-) diff --git a/web/src/store/index.ts b/web/src/store/index.ts index c2b561ad..a7f1d180 100644 --- a/web/src/store/index.ts +++ b/web/src/store/index.ts @@ -54,6 +54,23 @@ function setConditions(conditions: Condition[], push = false) { } } +/** + * For each condition, remove all others with a similar table & field. + */ +function setUniqueCondition( + field: string[], + table: string[], + conditions: Condition[], +) { + const others = state.conditions.filter((c) => ( + !field.includes(c.field)) || (!table.includes(c.table) + )); + setConditions([ + ...conditions, + ...others, + ]); +} + /** * Restore state from localStorage and clear */ @@ -119,23 +136,6 @@ async function getTreeData() { } } -/** - * For each condition, remove all others with a similar table & field. - */ -function setUniqueCondition( - field: string[], - table: string[], - conditions: Condition[], -) { - const others = state.conditions.filter((c) => ( - !field.includes(c.field)) || (!table.includes(c.table) - )); - setConditions([ - ...conditions, - ...others, - ]); -} - /** * For each condition, if it already exists, remove it, * otherwise, add it diff --git a/web/src/views/IndividualResults/StudyPage.vue b/web/src/views/IndividualResults/StudyPage.vue index 2b00d9fc..4d27fe3a 100644 --- a/web/src/views/IndividualResults/StudyPage.vue +++ b/web/src/views/IndividualResults/StudyPage.vue @@ -105,7 +105,7 @@ export default defineComponent({ const router = useRouter(); - function setChecked(omicsType = '') { + function seeOmicsForStudy(omicsType = '') { setUniqueCondition( ['study_id', 'omics_type'], ['study', 'omics_processing'], @@ -113,7 +113,7 @@ export default defineComponent({ value: props.id, table: 'study', op: '==', - field: 'study_id', + field: 'id', }, { value: omicsType, table: 'omics_processing', @@ -154,7 +154,7 @@ export default defineComponent({ item, displayFields, /* Methods */ - setChecked, + seeOmicsForStudy, relatedTypeDescription, openLink, formatAPA, @@ -188,7 +188,7 @@ export default defineComponent({ :key="val.type" small class="mr-2 my-1" - @click="setChecked(val.type)" + @click="seeOmicsForStudy(val.type)" > {{ fieldDisplayName(val.type) }}: {{ val.count }}