fix: misc component issues

This commit is contained in:
axolotle 2024-03-19 01:26:18 +01:00
parent c730de8b32
commit 4b33e67514
5 changed files with 18 additions and 21 deletions

View file

@ -142,7 +142,7 @@ export default {
if (key === copypastaCode[copypastastep++]) { if (key === copypastaCode[copypastastep++]) {
if (copypastastep === copypastaCode.length) { if (copypastastep === copypastaCode.length) {
document document
.getElementsByClassName('unselectable') .querySelectorAll('.unselectable')
.forEach((element) => element.classList.remove('unselectable')) .forEach((element) => element.classList.remove('unselectable'))
copypastastep = 0 copypastastep = 0
} }

View file

@ -175,7 +175,7 @@ export default {
// Allow to start searching after dropdown opening // Allow to start searching after dropdown opening
if ( if (
!['Tab', 'Space'].includes(e.code) && !['Tab', 'Space'].includes(e.code) &&
e.target === this.$refs.dropdown.$el.lastElementChild e.target === this.$refs.dropdown.$el.firstElementChild
) { ) {
this.$refs['search-input'].focus() this.$refs['search-input'].focus()
} }

View file

@ -1,6 +1,7 @@
import api from '@/api' import api from '@/api'
import { isEmptyValue } from '@/helpers/commons' import { isEmptyValue } from '@/helpers/commons'
import { stratify } from '@/helpers/data/tree' import { stratify } from '@/helpers/data/tree'
import { reactive } from 'vue'
export function getParentDomain(domain, domains, highest = false) { export function getParentDomain(domain, domains, highest = false) {
const method = highest ? 'lastIndexOf' : 'indexOf' const method = highest ? 'lastIndexOf' : 'indexOf'
@ -277,14 +278,16 @@ export default {
// action when state.domain change) // action when state.domain change)
const domains = getters.orderedDomains const domains = getters.orderedDomains
if (!domains) return if (!domains) return
const dataset = domains.map((name) => ({ const dataset = reactive(
domains.map((name) => ({
// data to build a hierarchy // data to build a hierarchy
name, name,
parent: getParentDomain(name, domains), parent: getParentDomain(name, domains),
// utility data that will be used by `RecursiveListGroup` component // utility data that will be used by `RecursiveListGroup` component
to: { name: 'domain-info', params: { name } }, to: { name: 'domain-info', params: { name } },
opened: true, opened: true,
})) })),
)
return stratify(dataset) return stratify(dataset)
}, },

View file

@ -80,7 +80,10 @@
class="category-card" class="category-card"
> >
<BCardTitle> <BCardTitle>
<BLink @click="updateQuery('category', cat.value)" class="card-link"> <BLink
@click.prevent="updateQuery('category', cat.value)"
class="card-link"
>
<YIcon :iname="cat.icon" /> {{ cat.text }} <YIcon :iname="cat.icon" /> {{ cat.text }}
</BLink> </BLink>
</BCardTitle> </BCardTitle>

View file

@ -6,7 +6,6 @@
items-name="domains" items-name="domains"
:queries="queries" :queries="queries"
:filtered-items="hasFilteredItems" :filtered-items="hasFilteredItems"
@queries-response="onQueriesResponse"
> >
<template #top-bar-buttons> <template #top-bar-buttons>
<BButton variant="success" :to="{ name: 'domain-add' }"> <BButton variant="success" :to="{ name: 'domain-add' }">
@ -63,12 +62,11 @@ export default {
return { return {
queries: [['GET', { uri: 'domains', storeKey: 'domains' }]], queries: [['GET', { uri: 'domains', storeKey: 'domains' }]],
search: '', search: '',
domainsTree: undefined,
} }
}, },
computed: { computed: {
...mapGetters(['domains', 'mainDomain']), ...mapGetters(['domains', 'mainDomain', 'domainsTree']),
tree() { tree() {
if (!this.domainsTree) return if (!this.domainsTree) return
@ -86,12 +84,5 @@ export default {
return this.tree.children || null return this.tree.children || null
}, },
}, },
methods: {
onQueriesResponse() {
// Add the tree to `data` to make it reactive
this.domainsTree = this.$store.getters.domainsTree
},
},
} }
</script> </script>