Redirect to current list view on click on list in menu again

Fixes #196
This commit is contained in:
kolaente 2020-07-29 13:02:46 +02:00
parent c9299a2bf3
commit d9361bcd53
No known key found for this signature in database
GPG key ID: F40E70337AB24C9B

View file

@ -74,6 +74,12 @@
}, },
}, },
methods: { methods: {
replaceListView() {
const savedListView = getListView(this.$route.params.listId)
router.replace({name: savedListView, params: {id: this.$route.params.listId}})
console.debug('Replaced list view with ', savedListView)
return
},
loadList() { loadList() {
this.setTitle(this.currentList.title) this.setTitle(this.currentList.title)
@ -88,6 +94,12 @@
this.$store.commit('kanban/setListId', 0) this.$store.commit('kanban/setListId', 0)
} }
// When clicking again on a list in the menu, there would be no list view selected which means no list
// at all. Users will then have to click on the list view menu again which is quite confusing.
if (this.$route.name === 'list.index') {
return this.replaceListView()
}
// Don't load the list if we either already loaded it or aren't dealing with a list at all currently // Don't load the list if we either already loaded it or aren't dealing with a list at all currently
if ( if (
this.$route.params.listId === this.listLoaded || this.$route.params.listId === this.listLoaded ||
@ -105,11 +117,7 @@
this.$route.name !== 'list.table' && this.$route.name !== 'list.table' &&
this.$route.name !== 'list.kanban' this.$route.name !== 'list.kanban'
) { ) {
const savedListView = getListView(this.$route.params.listId) return this.replaceListView()
router.replace({name: savedListView, params: {id: this.$route.params.listId}})
console.debug('Replaced list view with ', savedListView)
return
} }
console.debug(`Loading list, $route.name = ${this.$route.name}, $route.params =`, this.$route.params, `, listLoaded = ${this.listLoaded}, currentList = `, this.currentList) console.debug(`Loading list, $route.name = ${this.$route.name}, $route.params =`, this.$route.params, `, listLoaded = ${this.listLoaded}, currentList = `, this.currentList)