This repository has been archived on 2024-02-08. You can view files and clone it, but cannot push or open issues or pull requests.
frontend/src/components/lists/ShowList.vue
konrad 7d2bd192ab
All checks were successful
continuous-integration/drone/push Build is passing
Add support for archiving lists and namespaces (#73)
Use fancy checkbox for archiving namespace

Show is archived badge for namespaces

Fix is archived badge in navigation bar

Add check to filter out archived lists or namespaces

Show if a list is archived in menu

Hide edit task if the list is archived

Hide marking tasks as done if the list is archived

Show is archived message on list

Add archiving a list

Add archiving a namespace

Co-authored-by: kolaente <k@knt.li>
Reviewed-on: #73
2020-03-22 20:40:13 +00:00

80 lines
2.6 KiB
Vue

<template>
<div class="loader-container" :class="{ 'is-loading': listService.loading}">
<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.is_archived">
This list is archived.
It is not possible to create new or edit tasks or it.
</div>
<div class="switch-view">
<router-link :to="{ name: 'showList', params: { id: list.id } }" :class="{'is-active': $route.params.type !== 'gantt'}">List</router-link>
<router-link :to="{ name: 'showListWithType', params: { id: list.id, type: 'gantt' } }" :class="{'is-active': $route.params.type === 'gantt'}">Gantt</router-link>
</div>
</div>
<gantt :list="list" v-if="$route.params.type === 'gantt'"/>
<show-list-task :the-list="list" v-else/>
</div>
</template>
<script>
import auth from '../../auth'
import router from '../../router'
import ShowListTask from '../tasks/ShowListTasks'
import Gantt from '../tasks/Gantt'
import ListModel from '../../models/list'
import ListService from '../../services/list'
import authType from '../../models/authTypes'
export default {
data() {
return {
listID: this.$route.params.id,
listService: ListService,
list: ListModel,
}
},
components: {
Gantt,
ShowListTask,
},
beforeMount() {
// Check if the user is already logged in, if so, redirect him to the homepage
if (!auth.user.authenticated && auth.user.infos.type !== authType.LINK_SHARE) {
router.push({name: 'home'})
}
// 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 !== '') {
router.push({name: 'showList', params: { id: this.$route.params.id }})
}
},
created() {
this.listService = new ListService()
this.list = new ListModel()
this.loadList()
},
watch: {
// call again the method if the route changes
'$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)
})
},
}
}
</script>