vikunja-frontend/src/components/lists/ShowList.vue

90 lines
2.9 KiB
Vue
Raw Normal View History

2018-09-08 23:33:23 +02:00
<template>
<div class="loader-container" :class="{ 'is-loading': listService.loading}">
2018-09-08 23:33:23 +02:00
<div class="content">
<router-link :to="{ name: 'editList', params: { id: list.id } }" class="icon settings is-medium">
<icon icon="cog" size="2x"/>
</router-link>
<h1 :style="{ 'opacity': list.title === '' ? '0': '1' }">{{ list.title === '' ? 'Loading...': list.title}}</h1>
<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.
</div>
2019-04-29 23:41:39 +02:00
<div class="switch-view">
<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>
<router-link :to="{ name: 'showListWithType', params: { id: list.id, type: 'table' } }" :class="{'is-active': $route.params.type === 'table'}">Table</router-link>
</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'"/>
<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>
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'
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'
import TableView from '../tasks/TableView'
export default {
data() {
return {
listID: this.$route.params.id,
listService: ListService,
2019-04-29 23:41:39 +02:00
list: ListModel,
}
},
components: {
TableView,
2019-04-29 23:41:39 +02:00
Gantt,
ShowListTask,
},
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) {
router.push({name: 'home'})
}
2019-04-29 23:41:39 +02:00
// If the type is invalid, redirect the user
if (
auth.user.authenticated &&
auth.user.infos.type !== authType.LINK_SHARE &&
this.$route.params.type !== 'gantt' &&
this.$route.params.type !== 'table' &&
this.$route.params.type !== ''
) {
2019-04-29 23:41:39 +02:00
router.push({name: 'showList', params: { id: this.$route.params.id }})
}
},
created() {
this.listService = new ListService()
2019-04-29 23:41:39 +02:00
this.list = new ListModel()
this.loadList()
},
watch: {
// call again the method if the route changes
2019-12-03 19:09:12 +01:00
'$route.path': 'loadList'
},
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 => {
this.error(e, this)
})
},
}
}
2018-11-06 15:54:25 +01:00
</script>