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-05-09 19:15:13 +02:00
|
|
|
<router-link :to="{ name: 'list.list', params: { listId: listId } }" :class="{'is-active': $route.name === 'list.list'}">List</router-link>
|
|
|
|
<router-link :to="{ name: 'list.gantt', params: { listId: listId } }" :class="{'is-active': $route.name === 'list.gantt'}">Gantt</router-link>
|
|
|
|
<router-link :to="{ name: 'list.table', params: { listId: listId } }" :class="{'is-active': $route.name === 'list.table'}">Table</router-link>
|
|
|
|
<router-link :to="{ name: 'list.kanban', params: { listId: listId } }" :class="{'is-active': $route.name === 'list.kanban'}">Kanban</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
|
|
|
|
2020-04-26 01:11:34 +02:00
|
|
|
<router-view/>
|
2018-09-08 23:33:23 +02:00
|
|
|
</div>
|
|
|
|
</template>
|
|
|
|
|
|
|
|
<script>
|
2019-03-02 11:25:10 +01:00
|
|
|
import router from '../../router'
|
|
|
|
|
|
|
|
import ListModel from '../../models/list'
|
2019-04-29 23:41:39 +02:00
|
|
|
import ListService from '../../services/list'
|
2020-05-09 19:15:13 +02:00
|
|
|
import {CURRENT_LIST} from '../../store/mutation-types'
|
2019-03-02 11:25:10 +01:00
|
|
|
|
|
|
|
export default {
|
|
|
|
data() {
|
|
|
|
return {
|
|
|
|
listService: ListService,
|
2019-04-29 23:41:39 +02:00
|
|
|
list: ListModel,
|
2020-04-26 01:11:34 +02:00
|
|
|
listLoaded: 0,
|
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()
|
2020-04-26 01:11:34 +02:00
|
|
|
},
|
|
|
|
mounted() {
|
2019-03-02 11:25:10 +01:00
|
|
|
this.loadList()
|
|
|
|
},
|
|
|
|
watch: {
|
|
|
|
// call again the method if the route changes
|
2020-04-26 01:11:34 +02:00
|
|
|
'$route.path': 'loadList',
|
2019-03-02 11:25:10 +01:00
|
|
|
},
|
2020-05-09 19:15:13 +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
|
|
|
|
},
|
|
|
|
},
|
2019-03-02 11:25:10 +01:00
|
|
|
methods: {
|
|
|
|
loadList() {
|
2020-04-26 01:11:34 +02:00
|
|
|
|
|
|
|
// Don't load the list if we either already loaded it or aren't dealing with a list at all currently
|
|
|
|
if(this.$route.params.listId === this.listLoaded || typeof this.$route.params.listId === 'undefined') {
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
// 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'
|
|
|
|
) {
|
|
|
|
router.push({name: 'list.list', params: {id: this.$route.params.listId}})
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
2020-05-08 21:07:33 +02:00
|
|
|
this.$store.commit(CURRENT_LIST, Number(this.$route.params.listId))
|
|
|
|
|
2019-03-02 11:25:10 +01: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.
|
2020-04-26 01:11:34 +02:00
|
|
|
let list = new ListModel({id: this.$route.params.listId})
|
2019-03-02 11:25:10 +01:00
|
|
|
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
|
|
|
})
|
2020-04-26 01:11:34 +02:00
|
|
|
.finally(() => {
|
|
|
|
this.listLoaded = this.$route.params.listId
|
|
|
|
})
|
2019-03-02 11:25:10 +01:00
|
|
|
},
|
|
|
|
}
|
|
|
|
}
|
2018-11-06 15:54:25 +01:00
|
|
|
</script>
|