Skip to content

Commit

Permalink
Use id instead of study_id
Browse files Browse the repository at this point in the history
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
  • Loading branch information
naglepuff committed Aug 24, 2023
1 parent 5bfb417 commit 224e9de
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 21 deletions.
34 changes: 17 additions & 17 deletions web/src/store/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
*/
Expand Down Expand Up @@ -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
Expand Down
8 changes: 4 additions & 4 deletions web/src/views/IndividualResults/StudyPage.vue
Original file line number Diff line number Diff line change
Expand Up @@ -105,15 +105,15 @@ export default defineComponent({
const router = useRouter();
function setChecked(omicsType = '') {
function seeOmicsForStudy(omicsType = '') {
setUniqueCondition(
['study_id', 'omics_type'],
['study', 'omics_processing'],
[{
value: props.id,
table: 'study',
op: '==',
field: 'study_id',
field: 'id',
}, {
value: omicsType,
table: 'omics_processing',
Expand Down Expand Up @@ -154,7 +154,7 @@ export default defineComponent({
item,
displayFields,
/* Methods */
setChecked,
seeOmicsForStudy,
relatedTypeDescription,
openLink,
formatAPA,
Expand Down Expand Up @@ -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 }}
</v-chip>
Expand Down

0 comments on commit 224e9de

Please sign in to comment.