88 <div class =" flex flex-wrap justify-content-center gap-3" >
99 <IconField iconPosition =" left" >
1010 <InputIcon class =" pi pi-search" ></InputIcon >
11- <InputText v-model =" searchText" ref =" searchTextInput" type =" search" class =" p-inputtext-sm" placeholder =" HGVS string" style =" width : 500px ;" />
11+ <InputText v-model =" searchText" @keyup.enter = " hgvsSearch " ref =" searchTextInput" type =" search" class =" p-inputtext-sm" placeholder =" HGVS string" style =" width : 500px ;" />
1212 </IconField >
1313 <Button class =" p-button-plain" @click =" hgvsSearch" >Search</Button >
1414 </div >
4141 <div class =" variant-search-result" >
4242 <div v-if =" allele.variants.length > 0" class =" variant-search-result-button" >
4343 <router-link :to =" `/variants/${allele.clingenAlleleId}`" >
44- <Button label =" View in MaveMD " icon =" pi pi-eye" />
44+ <Button label =" View in MaveDB Clinical View " icon =" pi pi-eye" />
4545 </router-link >
4646 </div >
4747 <div class =" variant-search-result-content" >
@@ -113,6 +113,8 @@ import InputText from 'primevue/inputtext'
113113import Button from ' primevue/button'
114114import Message from ' primevue/message'
115115import {defineComponent } from ' vue'
116+ import { useRoute , useRouter } from ' vue-router'
117+ import { useToast } from ' primevue/usetoast'
116118// import {debounce} from 'vue-debounce'
117119
118120import config from ' @/config'
@@ -124,6 +126,12 @@ const SCORE_SETS_TO_SHOW = 5
124126export default defineComponent ({
125127 name: ' SearchVariantsScreen' ,
126128 components: {Card , Column , DataTable , DefaultLayout , Dropdown , EntityLink , IconField , InputIcon , InputText , Button , Message },
129+ setup() {
130+ const route = useRoute ()
131+ const router = useRouter ()
132+ const toast = useToast ()
133+ return { route , router , toast }
134+ },
127135
128136 data : function () {
129137 return {
@@ -175,6 +183,46 @@ export default defineComponent({
175183 }
176184 }
177185 },
186+ ' $route.query.search' : {
187+ immediate: true ,
188+ handler(newVal ) {
189+ if (typeof newVal === ' string' ) {
190+ this .searchText = newVal
191+ } else if (! newVal ) {
192+ this .searchText = ' '
193+ }
194+ }
195+ },
196+ ' $route.query.gene' : {
197+ immediate: true ,
198+ handler(newVal ) {
199+ this .inputGene = typeof newVal === ' string' ? newVal : ' '
200+ }
201+ },
202+ ' $route.query.variantType' : {
203+ immediate: true ,
204+ handler(newVal ) {
205+ this .inputVariantType = typeof newVal === ' string' ? newVal : ' '
206+ }
207+ },
208+ ' $route.query.variantPosition' : {
209+ immediate: true ,
210+ handler(newVal ) {
211+ this .inputVariantPosition = typeof newVal === ' string' ? newVal : ' '
212+ }
213+ },
214+ ' $route.query.refAllele' : {
215+ immediate: true ,
216+ handler(newVal ) {
217+ this .inputReferenceAllele = typeof newVal === ' string' ? newVal : ' '
218+ }
219+ },
220+ ' $route.query.altAllele' : {
221+ immediate: true ,
222+ handler(newVal ) {
223+ this .inputAlternateAllele = typeof newVal === ' string' ? newVal : ' '
224+ }
225+ },
178226 },
179227
180228 computed: {
@@ -196,6 +244,11 @@ export default defineComponent({
196244
197245 methods: {
198246 hgvsSearch : async function () {
247+ // Remove fuzzy search params from the URL
248+ const { gene, variantType, variantPosition, refAllele, altAllele, ... rest } = this .route .query ;
249+ this .router .replace ({
250+ query: { ... rest , search: this .searchText || undefined }
251+ })
199252 this .alleles = []
200253 this .loading = true ;
201254 if (this .searchText !== null && this .searchText !== ' ' ) {
@@ -249,10 +302,16 @@ export default defineComponent({
249302 break
250303 }
251304 this .alleles .push (newAllele )
252- } catch (error ) {
305+ } catch (error : any ) {
253306 // NOTE: not resetting alleles here, because any error will have occurred before pushing to alleles.
254307 // don't want to reset alleles because this function may be called in a loop to process several hgvs strings.
255308 console .log (" Error while loading search results" , error )
309+ this .toast .add ({
310+ severity: ' error' ,
311+ summary: error .response .data ?.errorType && error .response .data ?.description ? ` ${error .response .data ?.errorType }: ${error .response .data ?.description } ` : ' Error fetching results' ,
312+ detail: error .response .data ?.message || ' Invalid HGVS string provided.' ,
313+ life: 10000 ,
314+ })
256315 }
257316 },
258317 searchVariants : async function () {
@@ -265,21 +324,38 @@ export default defineComponent({
265324 clingenAlleleIds: [allele .clingenAlleleId ]
266325 }
267326 )
268- if (response .data !== null && response .data .length > 0 ) {
269- allele .variants = response .data [0 ]
327+
328+ allele .variants = response .data [0 ]
329+ allele .variantsStatus = ' Loaded'
330+ } catch (error : any ) {
331+ allele .variants = []
332+ console .log (" Error while loading MaveDB search results for variant" , error )
333+ if (error .response ?.status === 404 ) {
270334 allele .variantsStatus = ' Loaded'
335+ this .toast .add ({ severity: ' info' , summary: ' No results found' , detail: ' No variants match the provided search criteria.' , life: 10000 })
336+ } else if (error .response ?.status >= 500 ) {
337+ allele .variantsStatus = ' Error'
338+ this .toast .add ({ severity: ' error' , summary: ' Server Error' , detail: ' The server encountered an unexpected error. Please try again later.' , life: 10000 })
271339 } else {
272- allele .variants = []
273- allele . variantsStatus = ' Loaded '
340+ allele .variantsStatus = ' Error '
341+ this . toast . add ({ severity: ' error ' , summary: ' Error fetching results ' , detail: ' An error occurred while fetching MaveDB variants. ' , life: 10000 })
274342 }
275- } catch (error ) {
276- allele .variants = []
277- allele .variantsStatus = ' Error'
278- console .log (" Error while loading MaveDB search results for variant" , error )
279343 }
280344 }
281345 },
282346 fuzzySearch : async function () {
347+ // Remove HGVS search param from the URL
348+ const { search, ... rest } = this .route .query ;
349+ this .router .replace ({
350+ query: {
351+ ... rest ,
352+ gene: this .inputGene || undefined ,
353+ variantType: this .inputVariantType || undefined ,
354+ variantPosition: this .inputVariantPosition || undefined ,
355+ refAllele: this .inputReferenceAllele || undefined ,
356+ altAllele: this .inputAlternateAllele || undefined
357+ }
358+ })
283359 this .alleles = []
284360 this .loading = true ;
285361 await this .fetchFuzzySearchResults ()
@@ -351,13 +427,40 @@ export default defineComponent({
351427 for (const hgvsString of hgvsStrings ) {
352428 await this .fetchHgvsSearchResults (hgvsString .hgvsString , hgvsString .maneStatus )
353429 }
354- } catch (error ) {
430+ } catch (error : any ) {
355431 this .alleles = []
356432 console .log (" Error while loading search results" , error )
433+ this .toast .add ({
434+ severity: ' error' ,
435+ summary: error .response .data ?.errorType && error .response .data ?.description ? ` ${error .response .data ?.errorType }: ${error .response .data ?.description } ` : ' Error fetching results' ,
436+ detail: error .response .data ?.message || ' Invalid HGVS string provided.' ,
437+ life: 10000 ,
438+ })
357439 }
358440 }
359441 }
442+ },
443+
444+ mounted() {
445+ // If HGVS search param is present, run HGVS search
446+ if (this .route .query .search && String (this .route .query .search ).trim () !== ' ' ) {
447+ this .hgvsSearchVisible = true ;
448+ this .fuzzySearchVisible = false ;
449+ this .hgvsSearch ();
450+ } else if (
451+ this .route .query .gene ||
452+ this .route .query .variantType ||
453+ this .route .query .variantPosition ||
454+ this .route .query .refAllele ||
455+ this .route .query .altAllele
456+ ) {
457+ // If any fuzzy search param is present, run fuzzy search
458+ this .hgvsSearchVisible = false ;
459+ this .fuzzySearchVisible = true ;
460+ this .fuzzySearch ();
461+ }
360462 }
463+
361464})
362465
363466 </script >
0 commit comments