-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
2f87abc
commit 55953b0
Showing
10 changed files
with
270 additions
and
150 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
53 changes: 53 additions & 0 deletions
53
biogenome-client/src/components/inputs/TaxonSearchSelect.vue
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
<template> | ||
<VaSelect @click="emits('inputClicked')" :loading="isLoading" hideSelected dropdownIcon="search" searchable | ||
highlight-matched-text :textBy="(v: TreeNode) => `${v.name} (${v.rank})`" trackBy="taxid" | ||
@update:search="debouncedUpdateSearch" v-model="taxon" :searchPlaceholderText="t('taxon.search.placeholder')" | ||
:placeholder="t('taxon.search.placeholder')" :noOptionsText="t('taxon.search.noOptions')" :options="options"> | ||
</VaSelect> | ||
</template> | ||
<script setup lang="ts"> | ||
import { computed, ref } from 'vue'; | ||
import { useI18n } from 'vue-i18n' | ||
import { TreeNode } from '../../data/types'; | ||
import TaxonService from '../../services/clients/TaxonService'; | ||
import { AxiosError } from 'axios'; | ||
const props = defineProps<{ | ||
currentTaxon: TreeNode | null, | ||
isLoading?: boolean | ||
}>() | ||
const emits = defineEmits(['updateTaxon', 'inputClicked']) | ||
const { t } = useI18n() | ||
const taxon = computed({ | ||
get() { | ||
return props.currentTaxon | ||
}, set(taxon: TreeNode) { | ||
emits('updateTaxon', taxon) | ||
} | ||
}) | ||
const options = ref<TreeNode[]>([]) | ||
const debouncedUpdateSearch = debounce(async (filter: string) => { | ||
if (!filter && filter.length <= 1) return | ||
try { | ||
const { data } = await TaxonService.getTaxons({ filter: filter }) | ||
options.value = [...data.data] | ||
} catch (error) { | ||
console.log(error) | ||
const axiosError = error as AxiosError | ||
} | ||
}, 300); | ||
function debounce(fn: any, delay: number) { | ||
let timeoutId: any; | ||
return function (...args: any) { | ||
if (timeoutId) clearTimeout(timeoutId); | ||
timeoutId = setTimeout(() => { | ||
fn(...args); | ||
}, delay); | ||
}; | ||
} | ||
</script> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,4 @@ | ||
<template> | ||
|
||
<div class="container"> | ||
<div class="controls"> | ||
<div class="row justify-space-between align-center"> | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.