2018-09-08 23:33:23 +02:00
|
|
|
<template>
|
2020-05-31 21:17:10 +02:00
|
|
|
<div
|
2021-01-30 17:17:04 +01:00
|
|
|
:class="{ 'is-loading': listService.loading, 'is-archived': currentList.isArchived}"
|
2020-09-05 22:35:52 +02:00
|
|
|
class="loader-container"
|
2020-05-31 21:17:10 +02:00
|
|
|
>
|
2021-01-18 22:14:10 +01:00
|
|
|
<div class="switch-view-container">
|
|
|
|
<div class="switch-view">
|
|
|
|
<router-link
|
2021-01-30 17:17:04 +01:00
|
|
|
:class="{'is-active': $route.name.includes('list.list')}"
|
2021-01-18 22:14:10 +01:00
|
|
|
:to="{ name: 'list.list', params: { listId: listId } }">
|
2021-06-24 01:24:57 +02:00
|
|
|
{{ $t('list.list.title') }}
|
2021-01-18 22:14:10 +01:00
|
|
|
</router-link>
|
|
|
|
<router-link
|
2021-01-30 17:17:04 +01:00
|
|
|
:class="{'is-active': $route.name.includes('list.gantt')}"
|
2021-01-18 22:14:10 +01:00
|
|
|
:to="{ name: 'list.gantt', params: { listId: listId } }">
|
2021-06-24 01:24:57 +02:00
|
|
|
{{ $t('list.gantt.title') }}
|
2021-01-18 22:14:10 +01:00
|
|
|
</router-link>
|
|
|
|
<router-link
|
2021-01-30 17:17:04 +01:00
|
|
|
:class="{'is-active': $route.name.includes('list.table')}"
|
2021-01-18 22:14:10 +01:00
|
|
|
:to="{ name: 'list.table', params: { listId: listId } }">
|
2021-06-24 01:24:57 +02:00
|
|
|
{{ $t('list.table.title') }}
|
2021-01-18 22:14:10 +01:00
|
|
|
</router-link>
|
|
|
|
<router-link
|
2021-01-30 17:17:04 +01:00
|
|
|
:class="{'is-active': $route.name.includes('list.kanban')}"
|
2021-01-18 22:14:10 +01:00
|
|
|
:to="{ name: 'list.kanban', params: { listId: listId } }">
|
2021-06-24 01:24:57 +02:00
|
|
|
{{ $t('list.kanban.title') }}
|
2021-01-18 22:14:10 +01:00
|
|
|
</router-link>
|
|
|
|
</div>
|
2020-05-31 21:17:10 +02:00
|
|
|
</div>
|
2021-01-30 17:17:04 +01:00
|
|
|
<transition name="fade">
|
|
|
|
<div class="notification is-warning" v-if="currentList.isArchived">
|
2021-06-24 01:24:57 +02:00
|
|
|
{{ $t('list.archived') }}
|
2021-01-30 17:17:04 +01:00
|
|
|
</div>
|
|
|
|
</transition>
|
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>
|
2020-09-05 22:35:52 +02:00
|
|
|
import ListModel from '../../models/list'
|
|
|
|
import ListService from '../../services/list'
|
2021-08-06 23:34:37 +02:00
|
|
|
import {CURRENT_LIST} from '../../store/mutation-types'
|
|
|
|
import {getListView} from '../../helpers/saveListView'
|
2021-07-19 20:20:49 +02:00
|
|
|
import {saveListToHistory} from '../../modules/listHistory'
|
2019-03-02 11:25:10 +01:00
|
|
|
|
2020-09-05 22:35:52 +02:00
|
|
|
export default {
|
|
|
|
data() {
|
|
|
|
return {
|
2021-09-08 11:59:38 +02:00
|
|
|
listService: new ListService(),
|
2020-09-05 22:35:52 +02:00
|
|
|
listLoaded: 0,
|
|
|
|
}
|
|
|
|
},
|
|
|
|
watch: {
|
|
|
|
// call again the method if the route changes
|
2021-09-08 11:59:38 +02:00
|
|
|
'$route.path': {
|
|
|
|
handler: 'loadList',
|
|
|
|
immediate: true,
|
|
|
|
},
|
2020-09-05 22:35:52 +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-04-26 01:11:34 +02:00
|
|
|
},
|
2020-09-05 22:35:52 +02:00
|
|
|
background() {
|
|
|
|
return this.$store.state.background
|
2019-03-02 11:25:10 +01:00
|
|
|
},
|
2020-09-05 22:35:52 +02:00
|
|
|
currentList() {
|
|
|
|
return typeof this.$store.state.currentList === 'undefined' ? {
|
|
|
|
id: 0,
|
|
|
|
title: '',
|
2021-01-30 17:17:04 +01:00
|
|
|
isArchived: false,
|
2020-09-05 22:35:52 +02:00
|
|
|
} : this.$store.state.currentList
|
2019-03-02 11:25:10 +01:00
|
|
|
},
|
2020-09-05 22:35:52 +02:00
|
|
|
},
|
|
|
|
methods: {
|
|
|
|
replaceListView() {
|
|
|
|
const savedListView = getListView(this.$route.params.listId)
|
2021-08-06 23:34:37 +02:00
|
|
|
this.$router.replace({name: savedListView, params: {id: this.$route.params.listId}})
|
|
|
|
console.debug('Replaced list view with', savedListView)
|
2020-05-09 19:15:13 +02:00
|
|
|
},
|
2021-10-11 19:37:20 +02:00
|
|
|
|
|
|
|
async loadList() {
|
2021-07-10 12:45:36 +02:00
|
|
|
if (this.$route.name.includes('.settings.')) {
|
2021-01-30 17:17:04 +01:00
|
|
|
return
|
|
|
|
}
|
|
|
|
|
2021-07-19 20:20:49 +02:00
|
|
|
const listData = {id: parseInt(this.$route.params.listId)}
|
2021-07-06 22:22:57 +02:00
|
|
|
|
|
|
|
saveListToHistory(listData)
|
|
|
|
|
2021-07-09 10:22:20 +02:00
|
|
|
this.setTitle(this.currentList.id ? this.getListTitle(this.currentList) : '')
|
2020-04-26 01:11:34 +02:00
|
|
|
|
2020-09-05 22:35:52 +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-06-23 22:51:10 +02:00
|
|
|
|
2020-09-05 22:35:52 +02:00
|
|
|
// 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()
|
|
|
|
}
|
2020-07-29 13:02:46 +02:00
|
|
|
|
2021-07-10 12:45:36 +02:00
|
|
|
// Don't load the list if we either already loaded it or aren't dealing with a list at all currently and
|
|
|
|
// the currently loaded list has the right set.
|
2020-09-05 22:35:52 +02:00
|
|
|
if (
|
2021-07-10 12:45:36 +02:00
|
|
|
(
|
|
|
|
this.$route.params.listId === this.listLoaded ||
|
|
|
|
typeof this.$route.params.listId === 'undefined' ||
|
|
|
|
this.$route.params.listId === this.currentList.id ||
|
|
|
|
parseInt(this.$route.params.listId) === this.currentList.id
|
|
|
|
)
|
|
|
|
&& typeof this.currentList !== 'undefined' && this.currentList.maxRight !== null
|
2020-09-05 22:35:52 +02:00
|
|
|
) {
|
|
|
|
return
|
|
|
|
}
|
2020-04-26 01:11:34 +02:00
|
|
|
|
2020-09-05 22:35:52 +02:00
|
|
|
// 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'
|
|
|
|
) {
|
|
|
|
return this.replaceListView()
|
|
|
|
}
|
2020-04-26 01:11:34 +02:00
|
|
|
|
2020-09-05 22:35:52 +02:00
|
|
|
console.debug(`Loading list, $route.name = ${this.$route.name}, $route.params =`, this.$route.params, `, listLoaded = ${this.listLoaded}, currentList = `, this.currentList)
|
2020-07-24 10:42:30 +02:00
|
|
|
|
2020-09-05 22:35:52 +02: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.
|
2021-07-06 22:22:57 +02:00
|
|
|
const list = new ListModel(listData)
|
2021-10-11 19:37:20 +02:00
|
|
|
try {
|
|
|
|
const loadedList = await this.listService.get(list)
|
2021-10-16 20:44:39 +02:00
|
|
|
await this.$store.dispatch(CURRENT_LIST, loadedList)
|
2021-10-11 19:37:20 +02:00
|
|
|
this.setTitle(this.getListTitle(loadedList))
|
|
|
|
} finally {
|
|
|
|
this.listLoaded = this.$route.params.listId
|
|
|
|
}
|
2020-09-05 22:35:52 +02:00
|
|
|
},
|
|
|
|
},
|
|
|
|
}
|
2021-07-09 10:22:20 +02:00
|
|
|
</script>
|