feat: use computed for namespace title

This commit is contained in:
Dominik Pschenitschni 2021-10-16 16:38:30 +02:00
parent a6db1e7391
commit 12a3c238b8
No known key found for this signature in database
GPG key ID: B257AC0149F43A77

View file

@ -54,14 +54,14 @@
<span <span
@click="toggleLists(n.id)" @click="toggleLists(n.id)"
class="menu-label" class="menu-label"
v-tooltip="getNamespaceTitle(n) + ' (' + n.lists.filter(l => !l.isArchived).length + ')'"> v-tooltip="namespaceTitles[nk]">
<span class="name"> <span class="name">
<span <span
:style="{ backgroundColor: n.hexColor }" :style="{ backgroundColor: n.hexColor }"
class="color-bubble" class="color-bubble"
v-if="n.hexColor !== ''"> v-if="n.hexColor !== ''">
</span> </span>
{{ getNamespaceTitle(n) }} ({{ n.lists.filter(l => !l.isArchived).length }}) {{ namespaceTitles[nk] }}
</span> </span>
</span> </span>
<a <a
@ -191,7 +191,13 @@ export default {
loading: state => state[LOADING] && state[LOADING_MODULE] === 'namespaces', loading: state => state[LOADING] && state[LOADING_MODULE] === 'namespaces',
}), }),
activeLists() { activeLists() {
return this.namespaces.map(({lists}) => lists.filter(item => !item.isArchived)) return this.namespaces.map(({lists}) => lists?.filter(item => !item.isArchived))
},
namespaceTitles() {
return this.namespaces.map((namespace, index) => {
const title = this.getNamespaceTitle(namespace)
return `${title} (${this.activeLists[index]?.length ?? 0})`
})
}, },
}, },
beforeCreate() { beforeCreate() {
@ -229,7 +235,7 @@ export default {
} }
}, },
toggleLists(namespaceId) { toggleLists(namespaceId) {
this.listsVisible[namespaceId] = !this.listsVisible[namespaceId] ?? false this.listsVisible[namespaceId] = !this.listsVisible[namespaceId]
}, },
updateActiveLists(namespace, activeLists) { updateActiveLists(namespace, activeLists) {
// this is a bit hacky: since we do have to filter out the archived items from the list // this is a bit hacky: since we do have to filter out the archived items from the list