Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Add linkout for genes in SV page (#152) #153

Merged
merged 1 commit into from
Oct 17, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading