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
1 changed files with 10 additions and 4 deletions

View File

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