Skip to content

Commit

Permalink
fix: Add linkout for genes in SV page
Browse files Browse the repository at this point in the history
  • Loading branch information
gromdimon committed Oct 17, 2023
1 parent 5123958 commit 11255ed
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 2 deletions.
25 changes: 24 additions & 1 deletion frontend/src/components/SvDetails/SvGenes.vue
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@
import { type ComputedRef, type Ref, computed, ref } from 'vue'
import VariantDetailsGene from '@/components/VariantDetails/VariantGene.vue'
import { roundIt } from '@/lib/utils'
import { roundIt, search } from '@/lib/utils'
import router from '@/router'
/** `GeneInfo` is a type alias for easier future interface definition. */
type GeneInfo = any
Expand Down Expand Up @@ -129,6 +130,23 @@ const items: ComputedRef<GeneInfo[]> = computed(() => {
const onRowClicked = (event: Event, { item }: { item: GeneInfo }): void => {
currentGeneInfos.value = item
}
/**
* Perform a search based on the input gene symbol and current genome release.
*
* If a route is found for the search term then redirect to that route.
* Otherwise log an error.
*
* @param geneSymbol Gene symbol to search for
*/
const performSearch = async (geneSymbol: string) => {
const routeLocation: any = await search(geneSymbol, 'grch37')
if (routeLocation) {
router.push(routeLocation)
} else {
console.error(`no route found for ${geneSymbol}`)
}
}
</script>

<template>
Expand All @@ -144,6 +162,11 @@ const onRowClicked = (event: Event, { item }: { item: GeneInfo }): void => {
item-key="gene_name"
@click:row="onRowClicked"
>
<template v-slot:[`item.dbnsfp.gene_name`]="{ item }">
{{ item.dbnsfp.gene_name }}
<v-btn prepend-icon="mdi-open-in-new" @click="performSearch(item.dbnsfp.gene_name)" />
</template>

<template v-slot:[`item.omim`]="{ value }">
<template v-if="value?.omim_diseases?.length">
<template v-for="(disease, idx) in value?.omim_diseases" :key="idx">
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/views/VariantDetailView.vue
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ const performSearch = async (geneSymbol: string) => {
if (routeLocation) {
router.push(routeLocation)
} else {
console.error(`no route found for ${searchTermRef.value}`)
console.error(`no route found for ${geneSymbol}`)
}
}
</script>
Expand Down

0 comments on commit 11255ed

Please sign in to comment.