2018-09-08 23:33:23 +02:00
|
|
|
<template>
|
2019-03-02 11:25:10 +01:00
|
|
|
<div class="loader-container" :class="{ 'is-loading': listService.loading}">
|
2018-09-08 23:33:23 +02:00
|
|
|
<div class="content">
|
2018-09-12 08:42:07 +02:00
|
|
|
<router-link :to="{ name: 'editList', params: { id: list.id } }" class="icon settings is-medium">
|
|
|
|
<icon icon="cog" size="2x"/>
|
|
|
|
</router-link>
|
2020-01-31 11:05:53 +01:00
|
|
|
<h1 :style="{ 'opacity': list.title === '' ? '0': '1' }">{{ list.title === '' ? 'Loading...': list.title}}</h1>
|
2020-04-12 23:54:46 +02:00
|
|
|
<div class="notification is-warning" v-if="list.isArchived">
|
2020-03-22 21:40:13 +01:00
|
|
|
This list is archived.
|
|
|
|
It is not possible to create new or edit tasks or it.
|
|
|
|
</div>
|
2019-04-29 23:41:39 +02:00
|
|
|
<div class="switch-view">
|
2020-04-01 22:13:57 +02:00
|
|
|
<router-link :to="{ name: 'showList', params: { id: list.id } }" :class="{'is-active': $route.params.type !== 'gantt' && $route.params.type !== 'table'}">List</router-link>
|
2019-04-29 23:41:39 +02:00
|
|
|
<router-link :to="{ name: 'showListWithType', params: { id: list.id, type: 'gantt' } }" :class="{'is-active': $route.params.type === 'gantt'}">Gantt</router-link>
|
2020-04-01 22:13:57 +02:00
|
|
|
<router-link :to="{ name: 'showListWithType', params: { id: list.id, type: 'table' } }" :class="{'is-active': $route.params.type === 'table'}">Table</router-link>
|
2018-09-09 22:09:20 +02:00
|
|
|
</div>
|
2018-09-08 23:33:23 +02:00
|
|
|
</div>
|
2019-04-29 23:41:39 +02:00
|
|
|
|
|
|
|
<gantt :list="list" v-if="$route.params.type === 'gantt'"/>
|
2020-04-01 22:13:57 +02:00
|
|
|
<table-view :list="list" v-else-if="$route.params.type === 'table'"/>
|
2019-04-29 23:41:39 +02:00
|
|
|
<show-list-task :the-list="list" v-else/>
|
2018-09-08 23:33:23 +02:00
|
|
|
</div>
|
|
|
|
</template>
|
|
|
|
|
|
|
|
<script>
|
2019-03-02 11:25:10 +01:00
|
|
|
import auth from '../../auth'
|
|
|
|
import router from '../../router'
|
|
|
|
|
2019-04-29 23:41:39 +02:00
|
|
|
import ShowListTask from '../tasks/ShowListTasks'
|
|
|
|
import Gantt from '../tasks/Gantt'
|
|
|
|
|
2019-03-02 11:25:10 +01:00
|
|
|
import ListModel from '../../models/list'
|
2019-04-29 23:41:39 +02:00
|
|
|
import ListService from '../../services/list'
|
2019-09-09 20:36:30 +02:00
|
|
|
import authType from '../../models/authTypes'
|
2020-04-01 22:13:57 +02:00
|
|
|
import TableView from '../tasks/TableView'
|
2019-03-02 11:25:10 +01:00
|
|
|
|
|
|
|
export default {
|
|
|
|
data() {
|
|
|
|
return {
|
|
|
|
listID: this.$route.params.id,
|
|
|
|
listService: ListService,
|
2019-04-29 23:41:39 +02:00
|
|
|
list: ListModel,
|
2019-03-02 11:25:10 +01:00
|
|
|
}
|
|
|
|
},
|
2018-09-11 08:28:11 +02:00
|
|
|
components: {
|
2020-04-01 22:13:57 +02:00
|
|
|
TableView,
|
2019-04-29 23:41:39 +02:00
|
|
|
Gantt,
|
|
|
|
ShowListTask,
|
2018-09-11 08:28:11 +02:00
|
|
|
},
|
2019-03-02 11:25:10 +01:00
|
|
|
beforeMount() {
|
|
|
|
// Check if the user is already logged in, if so, redirect him to the homepage
|
2019-09-09 20:36:30 +02:00
|
|
|
if (!auth.user.authenticated && auth.user.infos.type !== authType.LINK_SHARE) {
|
2019-03-02 11:25:10 +01:00
|
|
|
router.push({name: 'home'})
|
|
|
|
}
|
2019-04-29 23:41:39 +02:00
|
|
|
|
|
|
|
// If the type is invalid, redirect the user
|
2020-04-01 22:13:57 +02:00
|
|
|
if (
|
|
|
|
auth.user.authenticated &&
|
|
|
|
auth.user.infos.type !== authType.LINK_SHARE &&
|
|
|
|
this.$route.params.type !== 'gantt' &&
|
|
|
|
this.$route.params.type !== 'table' &&
|
2020-04-14 23:37:08 +02:00
|
|
|
this.$route.params.type !== 'list' &&
|
2020-04-01 22:13:57 +02:00
|
|
|
this.$route.params.type !== ''
|
|
|
|
) {
|
2019-04-29 23:41:39 +02:00
|
|
|
router.push({name: 'showList', params: { id: this.$route.params.id }})
|
|
|
|
}
|
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()
|
2019-03-02 11:25:10 +01:00
|
|
|
this.loadList()
|
|
|
|
},
|
|
|
|
watch: {
|
|
|
|
// call again the method if the route changes
|
2019-12-03 19:09:12 +01:00
|
|
|
'$route.path': 'loadList'
|
2019-03-02 11:25:10 +01:00
|
|
|
},
|
|
|
|
methods: {
|
|
|
|
loadList() {
|
|
|
|
// 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.
|
|
|
|
let list = new ListModel({id: this.$route.params.id})
|
|
|
|
this.listService.get(list)
|
|
|
|
.then(r => {
|
|
|
|
this.$set(this, 'list', r)
|
|
|
|
})
|
|
|
|
.catch(e => {
|
2020-01-30 22:47:08 +01:00
|
|
|
this.error(e, this)
|
2019-03-02 11:25:10 +01:00
|
|
|
})
|
|
|
|
},
|
|
|
|
}
|
|
|
|
}
|
2018-11-06 15:54:25 +01:00
|
|
|
</script>
|