From 49bf0a4518bfb94908d75ebecf0cf728ab8fee70 Mon Sep 17 00:00:00 2001 From: Manuel Holtgrewe Date: Thu, 28 Dec 2023 08:17:46 +0100 Subject: [PATCH] feat: using links for home view examples (#349) --- frontend/src/lib/utils.ts | 25 +++++++++++++------ frontend/src/views/HomeView.vue | 16 ++++++------ frontend/src/views/__tests__/HomeView.spec.ts | 4 +-- 3 files changed, 27 insertions(+), 18 deletions(-) diff --git a/frontend/src/lib/utils.ts b/frontend/src/lib/utils.ts index edab25f0..feb633bb 100644 --- a/frontend/src/lib/utils.ts +++ b/frontend/src/lib/utils.ts @@ -107,6 +107,23 @@ export const scrollToSection = async (route: RouteLocationNormalizedLoaded) => { } } +/** + * Helper that returns the `RouteLocationRaw` for the given search term. + * + * @param searchTerm The search term to use. + * @param genomeBuild The genome build to use. + * @returns The `RouteLocationRaw` to use with a vue-router `Router`. + */ +export const searchTo = (searchTerm: string, genomeBuild: GenomeBuild): RouteLocationRaw => { + return { + name: 'query', + query: { + q: searchTerm, + genomeBuild: genomeBuild + } + } +} + /** Helper that launches a search through the router. * * @param router The {Router} to use. @@ -118,13 +135,7 @@ export const performSearch = async ( searchTerm: string, genomeBuild: GenomeBuild ) => { - router.push({ - name: 'query', - query: { - q: searchTerm, - genomeBuild: genomeBuild - } - }) + router.push(searchTo(searchTerm, genomeBuild)) } /** diff --git a/frontend/src/views/HomeView.vue b/frontend/src/views/HomeView.vue index 82f098d6..a009860f 100644 --- a/frontend/src/views/HomeView.vue +++ b/frontend/src/views/HomeView.vue @@ -6,14 +6,14 @@ Implements the search bar for variants and genes.