2018-09-08 23:33:23 +02:00
|
|
|
<template>
|
2020-05-31 21:17:10 +02:00
|
|
|
<div
|
|
|
|
class="loader-container"
|
|
|
|
:class="{ 'is-loading': listService.loading}"
|
|
|
|
>
|
|
|
|
<div class="switch-view">
|
|
|
|
<router-link
|
|
|
|
:to="{ name: 'list.list', params: { listId: listId } }"
|
|
|
|
:class="{'is-active': $route.name === 'list.list'}">
|
|
|
|
List
|
|
|
|
</router-link>
|
|
|
|
<router-link
|
|
|
|
:to="{ name: 'list.gantt', params: { listId: listId } }"
|
|
|
|
:class="{'is-active': $route.name === 'list.gantt'}">
|
|
|
|
Gantt
|
|
|
|
</router-link>
|
|
|
|
<router-link
|
|
|
|
:to="{ name: 'list.table', params: { listId: listId } }"
|
|
|
|
:class="{'is-active': $route.name === 'list.table'}">
|
|
|
|
Table
|
|
|
|
</router-link>
|
|
|
|
<router-link
|
|
|
|
:to="{ name: 'list.kanban', params: { listId: listId } }"
|
|
|
|
:class="{'is-active': $route.name === 'list.kanban'}">
|
|
|
|
Kanban
|
2018-09-12 08:42:07 +02:00
|
|
|
</router-link>
|
2020-05-31 21:17:10 +02:00
|
|
|
</div>
|
|
|
|
<div class="notification is-warning" v-if="list.isArchived">
|
|
|
|
This list is archived.
|
|
|
|
It is not possible to create new or edit tasks or it.
|
2018-09-08 23:33:23 +02:00
|
|
|
</div>
|
2019-04-29 23:41:39 +02:00
|
|
|
|
2020-04-26 01:11:34 +02:00
|
|
|
<router-view/>
|
2018-09-08 23:33:23 +02:00
|
|
|
</div>
|
|
|
|
</template>
|
|
|
|
|
|
|
|
<script>
|
2019-03-02 11:25:10 +01:00
|
|
|
import router from '../../router'
|
|
|
|
|
|
|
|
import ListModel from '../../models/list'
|
2019-04-29 23:41:39 +02:00
|
|
|
import ListService from '../../services/list'
|
2020-05-09 19:15:13 +02:00
|
|
|
import {CURRENT_LIST} from '../../store/mutation-types'
|
2020-05-22 17:28:26 +02:00
|
|
|
import {getListView} from '../../helpers/saveListView'
|
2019-03-02 11:25:10 +01:00
|
|
|
|
|
|
|
export default {
|
|
|
|
data() {
|
|
|
|
return {
|
|
|
|
listService: ListService,
|
2019-04-29 23:41:39 +02:00
|
|
|
list: ListModel,
|
2020-04-26 01:11:34 +02:00
|
|
|
listLoaded: 0,
|
2019-03-02 11:25:10 +01:00
|
|
|
}
|
|
|
|
},
|
|
|
|
created() {
|
|
|
|
this.listService = new ListService()
|
2019-04-29 23:41:39 +02:00
|
|
|
this.list = new ListModel()
|
2020-04-26 01:11:34 +02:00
|
|
|
},
|
|
|
|
mounted() {
|
2019-03-02 11:25:10 +01:00
|
|
|
this.loadList()
|
|
|
|
},
|
|
|
|
watch: {
|
|
|
|
// call again the method if the route changes
|
2020-04-26 01:11:34 +02:00
|
|
|
'$route.path': 'loadList',
|
2019-03-02 11:25:10 +01:00
|
|
|
},
|
2020-05-09 19:15:13 +02:00
|
|
|
computed: {
|
|
|
|
// Computed property to let "listId" always have a value
|
|
|
|
listId() {
|
|
|
|
return typeof this.$route.params.listId === 'undefined' ? 0 : this.$route.params.listId
|
|
|
|
},
|
2020-05-31 21:17:10 +02:00
|
|
|
background() {
|
|
|
|
return this.$store.state.background
|
|
|
|
},
|
2020-07-01 19:16:01 +02:00
|
|
|
currentList() {
|
|
|
|
return typeof this.$store.state.currentList === 'undefined' ? {id: 0} : this.$store.state.currentList
|
|
|
|
},
|
2020-05-09 19:15:13 +02:00
|
|
|
},
|
2019-03-02 11:25:10 +01:00
|
|
|
methods: {
|
|
|
|
loadList() {
|
2020-04-26 01:11:34 +02:00
|
|
|
|
2020-06-23 22:51:10 +02:00
|
|
|
// This invalidates the loaded list at the kanban board which lets it reload its content when
|
|
|
|
// switched to it. This ensures updates done to tasks in the gantt or list views are consistently
|
|
|
|
// shown in all views while preventing reloads when closing a task popup.
|
|
|
|
// We don't do this for the table view because that does not change tasks.
|
|
|
|
if (
|
|
|
|
this.$route.name === 'list.list' ||
|
|
|
|
this.$route.name === 'list.gantt'
|
|
|
|
) {
|
|
|
|
this.$store.commit('kanban/setListId', 0)
|
|
|
|
}
|
|
|
|
|
2020-04-26 01:11:34 +02:00
|
|
|
// Don't load the list if we either already loaded it or aren't dealing with a list at all currently
|
2020-07-01 19:16:01 +02:00
|
|
|
if (
|
|
|
|
this.$route.params.listId === this.listLoaded ||
|
|
|
|
typeof this.$route.params.listId === 'undefined' ||
|
|
|
|
this.$route.params.listId === this.currentList.id) {
|
2020-04-26 01:11:34 +02:00
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
// Redirect the user to list view by default
|
|
|
|
if (
|
|
|
|
this.$route.name !== 'list.list' &&
|
|
|
|
this.$route.name !== 'list.gantt' &&
|
|
|
|
this.$route.name !== 'list.table' &&
|
|
|
|
this.$route.name !== 'list.kanban'
|
|
|
|
) {
|
2020-05-22 17:28:26 +02:00
|
|
|
const savedListView = getListView(this.$route.params.listId)
|
2020-05-21 11:12:59 +02:00
|
|
|
|
2020-05-22 17:28:26 +02:00
|
|
|
router.replace({name: savedListView, params: {id: this.$route.params.listId}})
|
2020-04-26 01:11:34 +02:00
|
|
|
return
|
|
|
|
}
|
|
|
|
|
2019-03-02 11:25:10 +01:00
|
|
|
// We create an extra list object instead of creating it in this.list because that would trigger a ui update which would result in bad ux.
|
2020-04-26 01:11:34 +02:00
|
|
|
let list = new ListModel({id: this.$route.params.listId})
|
2019-03-02 11:25:10 +01:00
|
|
|
this.listService.get(list)
|
|
|
|
.then(r => {
|
|
|
|
this.$set(this, 'list', r)
|
2020-05-31 21:17:10 +02:00
|
|
|
this.$store.commit(CURRENT_LIST, r)
|
2019-03-02 11:25:10 +01:00
|
|
|
})
|
|
|
|
.catch(e => {
|
2020-01-30 22:47:08 +01:00
|
|
|
this.error(e, this)
|
2019-03-02 11:25:10 +01:00
|
|
|
})
|
2020-04-26 01:11:34 +02:00
|
|
|
.finally(() => {
|
|
|
|
this.listLoaded = this.$route.params.listId
|
|
|
|
})
|
2019-03-02 11:25:10 +01:00
|
|
|
},
|
|
|
|
}
|
|
|
|
}
|
2018-11-06 15:54:25 +01:00
|
|
|
</script>
|