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-11-13 21:28:29 +01:00
|
|
|
v-shortcut="'g l'"
|
|
|
|
:title="$t('keyboardShortcuts.list.switchToListView')"
|
2021-10-03 15:54:24 +02:00
|
|
|
:class="{'is-active': currentListType === '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-11-13 21:28:29 +01:00
|
|
|
v-shortcut="'g g'"
|
|
|
|
:title="$t('keyboardShortcuts.list.switchToGanttView')"
|
2021-10-03 15:54:24 +02:00
|
|
|
:class="{'is-active': currentListType === '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-11-13 21:28:29 +01:00
|
|
|
v-shortcut="'g t'"
|
|
|
|
:title="$t('keyboardShortcuts.list.switchToTableView')"
|
2021-10-03 15:54:24 +02:00
|
|
|
:class="{'is-active': currentListType === '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-11-13 21:28:29 +01:00
|
|
|
v-shortcut="'g k'"
|
|
|
|
:title="$t('keyboardShortcuts.list.switchToKanbanView')"
|
2021-10-03 15:54:24 +02:00
|
|
|
:class="{'is-active': currentListType === '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">
|
2021-11-28 15:18:27 +01:00
|
|
|
<message variant="warning" v-if="currentList.isArchived" class="mb-4">
|
2021-06-24 01:24:57 +02:00
|
|
|
{{ $t('list.archived') }}
|
2021-11-28 15:18:27 +01:00
|
|
|
</message>
|
2021-01-30 17:17:04 +01:00
|
|
|
</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>
|
2021-11-28 15:18:27 +01:00
|
|
|
import Message from '@/components/misc/message'
|
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 {
|
2021-11-28 15:18:27 +01:00
|
|
|
components: {Message},
|
2020-09-05 22:35:52 +02:00
|
|
|
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: {
|
2021-10-03 15:54:24 +02:00
|
|
|
currentListType() {
|
|
|
|
// default: 'list',
|
|
|
|
return ''
|
|
|
|
},
|
|
|
|
|
2020-09-05 22:35:52 +02:00
|
|
|
// 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
|
|
|
|
2021-10-03 15:54:24 +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>
|
2021-10-18 14:21:02 +02:00
|
|
|
|
|
|
|
<style lang="scss" scoped>
|
2021-10-18 14:21:53 +02:00
|
|
|
.switch-view-container {
|
|
|
|
@media screen and (max-width: $tablet) {
|
|
|
|
display: flex;
|
|
|
|
justify-content: center;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
.switch-view {
|
2021-11-22 22:12:54 +01:00
|
|
|
background: var(--white);
|
2021-10-18 14:21:53 +02:00
|
|
|
display: inline-flex;
|
|
|
|
border-radius: $radius;
|
|
|
|
font-size: .75rem;
|
2021-11-22 22:12:54 +01:00
|
|
|
box-shadow: var(--shadow-sm);
|
2021-10-18 14:21:53 +02:00
|
|
|
height: $switch-view-height;
|
|
|
|
margin-bottom: 1rem;
|
|
|
|
padding: .5rem;
|
|
|
|
|
|
|
|
a {
|
|
|
|
padding: .25rem .5rem;
|
|
|
|
display: block;
|
|
|
|
border-radius: $radius;
|
|
|
|
|
|
|
|
transition: all 100ms;
|
|
|
|
|
|
|
|
&:not(:last-child) {
|
|
|
|
margin-right: .5rem;
|
|
|
|
}
|
|
|
|
|
|
|
|
&.is-active,
|
2021-11-22 22:12:54 +01:00
|
|
|
&:hover {
|
|
|
|
color: var(--switch-view-color);
|
2021-10-18 14:21:53 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
&.is-active {
|
2021-11-22 22:12:54 +01:00
|
|
|
background: var(--primary);
|
2021-10-18 14:21:53 +02:00
|
|
|
font-weight: bold;
|
2021-11-22 22:12:54 +01:00
|
|
|
box-shadow: var(--shadow-xs);
|
2021-10-18 14:21:53 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
&:hover {
|
2021-11-22 22:12:54 +01:00
|
|
|
background: var(--primary);
|
2021-10-18 14:21:53 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-10-18 14:21:02 +02:00
|
|
|
.is-archived .notification.is-warning {
|
|
|
|
margin-bottom: 1rem;
|
|
|
|
}
|
|
|
|
</style>
|