Remember list view when navigating between lists

This commit is contained in:
kolaente 2020-05-21 11:12:59 +02:00
parent 978e7b4acb
commit 12727900de
No known key found for this signature in database
GPG key ID: F40E70337AB24C9B
5 changed files with 24 additions and 1 deletions

View file

@ -68,7 +68,10 @@
this.$route.name !== 'list.table' && this.$route.name !== 'list.table' &&
this.$route.name !== 'list.kanban' this.$route.name !== 'list.kanban'
) { ) {
router.replace({name: 'list.list', params: {id: this.$route.params.listId}})
const savedListView = localStorage.getItem('listView')
router.replace({name: savedListView ? savedListView : 'list.list', params: {id: this.$route.params.listId}})
return return
} }

View file

@ -71,6 +71,11 @@
flatPickr, flatPickr,
GanttChart GanttChart
}, },
created() {
// Save the current list view to local storage
// We use local storage and not vuex here to make it persistent across reloads.
localStorage.setItem('listView', this.$route.name)
},
data() { data() {
return { return {
showTaskswithoutDates: false, showTaskswithoutDates: false,

View file

@ -237,6 +237,13 @@
this.taskService = new TaskService() this.taskService = new TaskService()
this.loadBuckets() this.loadBuckets()
setTimeout(() => document.addEventListener('click', this.closeBucketDropdowns), 0) setTimeout(() => document.addEventListener('click', this.closeBucketDropdowns), 0)
// Save the current list view to local storage
// We use local storage and not vuex here to make it persistent across reloads.
localStorage.setItem('listView', this.$route.name)
},
watch: {
'$route.params.listId': 'loadBuckets',
}, },
computed: mapState({ computed: mapState({
buckets: state => state.kanban.buckets, buckets: state => state.kanban.buckets,

View file

@ -136,6 +136,10 @@
}, },
created() { created() {
this.taskService = new TaskService() this.taskService = new TaskService()
// Save the current list view to local storage
// We use local storage and not vuex here to make it persistent across reloads.
localStorage.setItem('listView', this.$route.name)
}, },
methods: { methods: {
// This function initializes the tasks page and loads the first page of tasks // This function initializes the tasks page and loads the first page of tasks

View file

@ -202,6 +202,10 @@
} }
this.initTasks(1) this.initTasks(1)
// Save the current list view to local storage
// We use local storage and not vuex here to make it persistent across reloads.
localStorage.setItem('listView', this.$route.name)
}, },
methods: { methods: {
initTasks(page, search = '') { initTasks(page, search = '') {