Skip to content

Commit

Permalink
Merge pull request #955 from microbiomedata/unify-study-filter-links
Browse files Browse the repository at this point in the history
  • Loading branch information
naglepuff authored Aug 29, 2023
2 parents f16bc8d + 224e9de commit 631c823
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 631c823

Please sign in to comment.