Show parent list and namespace for tasks in detail views

This commit is contained in:
kolaente 2020-05-09 23:28:54 +02:00
parent 495350fa83
commit c2135338d3
No known key found for this signature in database
GPG key ID: F40E70337AB24C9B
2 changed files with 66 additions and 50 deletions

View file

@ -6,16 +6,15 @@
#{{ task.id }} #{{ task.id }}
</h1> </h1>
<div class="is-done" v-if="task.done">Done</div> <div class="is-done" v-if="task.done">Done</div>
<h1 class="title input" contenteditable="true" @focusout="saveTaskOnChange()" ref="taskTitle" @keyup.ctrl.enter="saveTaskOnChange()">{{ task.text }}</h1> <h1 class="title input" contenteditable="true" @focusout="saveTaskOnChange()" ref="taskTitle"
@keyup.ctrl.enter="saveTaskOnChange()">{{ task.text }}</h1>
</div> </div>
<!-- FIXME: Throw this away once we have vuex --> <h6 class="subtitle" v-if="parent && parent.namespace && parent.list">
<!-- Commented out because it is a) not working and b) not working --> {{ parent.namespace.name }} >
<!-- <h6 class="subtitle">--> <router-link :to="{ name: 'list.index', params: { listId: parent.list.id } }">
<!-- {{ namespace.name }} >--> {{ parent.list.title }}
<!-- <router-link :to="{ name: 'list.index', params: { id: list.id } }">--> </router-link>
<!-- {{ list.title }}--> </h6>
<!-- </router-link>-->
<!-- </h6>-->
<!-- Content and buttons --> <!-- Content and buttons -->
<div class="columns"> <div class="columns">
@ -51,14 +50,14 @@
</div> </div>
<div class="date-input"> <div class="date-input">
<flat-pickr <flat-pickr
:class="{ 'disabled': taskService.loading}" :class="{ 'disabled': taskService.loading}"
class="input" class="input"
:disabled="taskService.loading" :disabled="taskService.loading"
v-model="dueDate" v-model="dueDate"
:config="flatPickerConfig" :config="flatPickerConfig"
@on-close="saveTask" @on-close="saveTask"
placeholder="Click here to set a due date" placeholder="Click here to set a due date"
ref="dueDate" ref="dueDate"
> >
</flat-pickr> </flat-pickr>
<a v-if="dueDate" @click="() => {dueDate = task.dueDate = null;saveTask()}"> <a v-if="dueDate" @click="() => {dueDate = task.dueDate = null;saveTask()}">
@ -84,14 +83,14 @@
</div> </div>
<div class="date-input"> <div class="date-input">
<flat-pickr <flat-pickr
:class="{ 'disabled': taskService.loading}" :class="{ 'disabled': taskService.loading}"
class="input" class="input"
:disabled="taskService.loading" :disabled="taskService.loading"
v-model="task.startDate" v-model="task.startDate"
:config="flatPickerConfig" :config="flatPickerConfig"
@on-close="saveTask" @on-close="saveTask"
placeholder="Click here to set a start date" placeholder="Click here to set a start date"
ref="startDate" ref="startDate"
> >
</flat-pickr> </flat-pickr>
<a v-if="task.startDate" @click="() => {task.startDate = null;saveTask()}"> <a v-if="task.startDate" @click="() => {task.startDate = null;saveTask()}">
@ -109,14 +108,14 @@
</div> </div>
<div class="date-input"> <div class="date-input">
<flat-pickr <flat-pickr
:class="{ 'disabled': taskService.loading}" :class="{ 'disabled': taskService.loading}"
class="input" class="input"
:disabled="taskService.loading" :disabled="taskService.loading"
v-model="task.endDate" v-model="task.endDate"
:config="flatPickerConfig" :config="flatPickerConfig"
@on-close="saveTask" @on-close="saveTask"
placeholder="Click here to set an end date" placeholder="Click here to set an end date"
ref="endDate" ref="endDate"
> >
</flat-pickr> </flat-pickr>
<a v-if="task.endDate" @click="() => {task.endDate = null;saveTask()}"> <a v-if="task.endDate" @click="() => {task.endDate = null;saveTask()}">
@ -221,7 +220,10 @@
<comments :task-id="taskId"/> <comments :task-id="taskId"/>
</div> </div>
<div class="column is-one-third action-buttons"> <div class="column is-one-third action-buttons">
<a class="button is-outlined noshadow has-no-border" :class="{'is-success': !task.done}" @click="toggleTaskDone()"> <a
class="button is-outlined noshadow has-no-border"
:class="{'is-success': !task.done}"
@click="toggleTaskDone()">
<span class="icon is-small"><icon icon="check-double"/></span> <span class="icon is-small"><icon icon="check-double"/></span>
<template v-if="task.done"> <template v-if="task.done">
Mark as undone Mark as undone
@ -306,7 +308,6 @@
import TaskService from '../../services/task' import TaskService from '../../services/task'
import TaskModel from '../../models/task' import TaskModel from '../../models/task'
import relationKinds from '../../models/relationKinds' import relationKinds from '../../models/relationKinds'
import NamespaceModel from '../../models/namespace'
import priorites from '../../models/priorities' import priorites from '../../models/priorities'
@ -349,7 +350,6 @@
// in store right after updating it from the api resulting in the wrong due date format being saved in the task. // in store right after updating it from the api resulting in the wrong due date format being saved in the task.
dueDate: null, dueDate: null,
namespace: NamespaceModel,
showDeleteModal: false, showDeleteModal: false,
taskTitle: '', taskTitle: '',
descriptionChanged: false, descriptionChanged: false,
@ -388,13 +388,28 @@
mounted() { mounted() {
this.loadTask() this.loadTask()
}, },
computed: {
parent() {
if(!this.task.listId) {
return {
namespace: null,
list: null,
}
}
if(!this.$store.getters["namespaces/getListAndNamespaceById"]) {
return null
}
return this.$store.getters["namespaces/getListAndNamespaceById"](this.task.listId)
},
},
methods: { methods: {
loadTask() { loadTask() {
this.taskId = Number(this.$route.params.id) this.taskId = Number(this.$route.params.id)
this.taskService.get({id: this.taskId}) this.taskService.get({id: this.taskId})
.then(r => { .then(r => {
this.$set(this, 'task', r) this.$set(this, 'task', r)
this.setListAndNamespaceTitleFromParent()
this.taskTitle = this.task.text this.taskTitle = this.task.text
this.setActiveFields() this.setActiveFields()
}) })
@ -468,18 +483,6 @@
this.error(e, this) this.error(e, this)
}) })
}, },
setListAndNamespaceTitleFromParent() {
// FIXME: Throw this away once we have vuex
// this.$parent.namespaces.forEach(n => {
// n.lists.forEach(l => {
// if (l.id === this.task.listId) {
// this.list = l
// this.namespace = n
// return
// }
// })
// })
},
setFieldActive(fieldName) { setFieldActive(fieldName) {
this.activeFields[fieldName] = true this.activeFields[fieldName] = true
this.$nextTick(() => this.$refs[fieldName].$el.focus()) this.$nextTick(() => this.$refs[fieldName].$el.focus())
@ -509,7 +512,7 @@
// Since we can either trigger this with ctrl+enter or @change, it would be possible to save a task first // Since we can either trigger this with ctrl+enter or @change, it would be possible to save a task first
// with ctrl+enter and then with @change although nothing changed since the last save when @change gets fired. // with ctrl+enter and then with @change although nothing changed since the last save when @change gets fired.
// To only save one time we added this method. // To only save one time we added this method.
if(this.descriptionChanged) { if (this.descriptionChanged) {
this.descriptionChanged = false this.descriptionChanged = false
this.saveTask() this.saveTask()
} }

View file

@ -57,6 +57,19 @@ export default {
} }
return null return null
}, },
getListAndNamespaceById: state => listId => {
for (const n in state.namespaces) {
for (const l in state.namespaces[n].lists) {
if (state.namespaces[n].lists[l].id === listId) {
return {
list: state.namespaces[n].lists[l],
namespace: state.namespaces[n],
}
}
}
}
return null
},
}, },
actions: { actions: {
loadNamespaces(ctx) { loadNamespaces(ctx) {