Fix showing and hiding lists in the menu

This commit is contained in:
kolaente 2021-02-20 16:28:45 +01:00
parent 074b7e53f5
commit 62bfbcce79
No known key found for this signature in database
GPG key ID: F40E70337AB24C9B
3 changed files with 26 additions and 40 deletions

View file

@ -51,8 +51,8 @@
<aside class="menu namespaces-lists loader-container" :class="{'is-loading': loading}"> <aside class="menu namespaces-lists loader-container" :class="{'is-loading': loading}">
<template v-for="n in namespaces"> <template v-for="n in namespaces">
<div :key="n.id" class="namespace-title"> <div :key="n.id" class="namespace-title">
<label <span
:for="n.id + 'checker'" @click="toggleLists(n.id)"
class="menu-label" class="menu-label"
v-tooltip="n.title + ' (' + n.lists.filter(l => !l.isArchived).length + ')'"> v-tooltip="n.title + ' (' + n.lists.filter(l => !l.isArchived).length + ')'">
<span class="name"> <span class="name">
@ -63,16 +63,10 @@
</span> </span>
{{ n.title }} ({{ n.lists.filter(l => !l.isArchived).length }}) {{ n.title }} ({{ n.lists.filter(l => !l.isArchived).length }})
</span> </span>
</label> </span>
<namespace-settings-dropdown :namespace="n" v-if="n.id > 0"/> <namespace-settings-dropdown :namespace="n" v-if="n.id > 0"/>
</div> </div>
<input <div :key="n.id + 'child'" class="more-container" v-if="listsVisible[n.id]">
:id="n.id + 'checker'"
:key="n.id + 'checker'"
checked="checked"
class="checkinput"
type="checkbox"/>
<div :key="n.id + 'child'" class="more-container">
<ul class="menu-list can-be-hidden"> <ul class="menu-list can-be-hidden">
<template v-for="l in n.lists"> <template v-for="l in n.lists">
<!-- This is a bit ugly but vue wouldn't want to let me filter this - probably because the lists <!-- This is a bit ugly but vue wouldn't want to let me filter this - probably because the lists
@ -104,10 +98,14 @@
</li> </li>
</template> </template>
</ul> </ul>
<label :for="n.id + 'checker'" class="hidden-hint">
Show hidden lists ({{ n.lists.filter(l => !l.isArchived).length }})...
</label>
</div> </div>
<span
@click="toggleLists(n.id)"
:key="`${n.id}_hidden_hint`"
class="hidden-hint"
v-else-if="n.lists.filter(l => !l.isArchived).length > 0">
Show hidden lists ({{ n.lists.filter(l => !l.isArchived).length }})...
</span>
</template> </template>
</aside> </aside>
<a class="menu-bottom-link" href="https://vikunja.io" target="_blank">Powered by Vikunja</a> <a class="menu-bottom-link" href="https://vikunja.io" target="_blank">Powered by Vikunja</a>
@ -122,6 +120,11 @@ import NamespaceSettingsDropdown from '@/components/namespace/namespace-settings
export default { export default {
name: 'navigation', name: 'navigation',
data() {
return {
listsVisible: {},
}
},
components: { components: {
ListSettingsDropdown, ListSettingsDropdown,
NamespaceSettingsDropdown, NamespaceSettingsDropdown,
@ -137,6 +140,11 @@ export default {
}), }),
beforeCreate() { beforeCreate() {
this.$store.dispatch('namespaces/loadNamespaces') this.$store.dispatch('namespaces/loadNamespaces')
.then(namespaces => {
namespaces.forEach(n => {
this.$set(this.listsVisible, n.id, true)
})
})
}, },
created() { created() {
window.addEventListener('resize', this.resize) window.addEventListener('resize', this.resize)
@ -162,6 +170,9 @@ export default {
this.$store.commit(MENU_ACTIVE, true) this.$store.commit(MENU_ACTIVE, true)
} }
}, },
toggleLists(namespaceId) {
this.$set(this.listsVisible, namespaceId, !this.listsVisible[namespaceId] ?? false)
},
}, },
} }
</script> </script>

View file

@ -114,7 +114,7 @@ export default {
ctx.commit('lists/addLists', lists, {root: true}) ctx.commit('lists/addLists', lists, {root: true})
return Promise.resolve() return Promise.resolve(r)
}) })
.catch(e => { .catch(e => {
return Promise.reject(e) return Promise.reject(e)

View file

@ -194,40 +194,15 @@
color: $vikunja-nav-color; color: $vikunja-nav-color;
} }
.checkinput {
display: none;
}
.checkinput:checked + .more-container {
.menu-list.can-be-hidden {
opacity: 1;
height: auto;
}
}
.checkinput:not(:checked) + .more-container .hidden-hint {
opacity: 1;
height: auto;
}
.hidden-hint { .hidden-hint {
display: block; display: block;
opacity: 0;
height: 0;
text-align: center; text-align: center;
color: $grey-500; color: $grey-500;
cursor: pointer; cursor: pointer;
font-size: 0.8rem; font-size: 0.75rem;
} }
.menu-list { .menu-list {
&.can-be-hidden {
transition: all $transition;
height: 0;
//overflow: hidden;
opacity: 0;
}
li { li {
height: 44px; height: 44px;
display: flex; display: flex;