4a413e7f3c
Change all snake/camelCase mix and match to camelCase everywhere Fix conversion to not interfer with service interceptors Add dynamic conversion between camelCase and snake_case to services Co-authored-by: kolaente <k@knt.li> Reviewed-on: https://kolaente.dev/vikunja/frontend/pulls/105
118 lines
No EOL
2.5 KiB
Vue
118 lines
No EOL
2.5 KiB
Vue
<template>
|
|
<div>
|
|
<h3 v-if="showAll">Current tasks</h3>
|
|
<h3 v-else>Tasks from {{startDate.toLocaleDateString()}} until {{endDate.toLocaleDateString()}}</h3>
|
|
<template v-if="!taskService.loading && (!hasUndoneTasks || !tasks)">
|
|
<h3 class="nothing">Nothing to to - Have a nice day!</h3>
|
|
<img src="/images/cool.svg" alt=""/>
|
|
</template>
|
|
<div class="spinner" :class="{ 'is-loading': taskService.loading}"></div>
|
|
<div class="tasks" v-if="tasks && tasks.length > 0">
|
|
<div class="task" v-for="t in tasks" :key="t.id">
|
|
<single-task-in-list :the-task="t" @taskUpdated="updateTasks"/>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</template>
|
|
<script>
|
|
import TaskService from '../../services/task'
|
|
import SingleTaskInList from "./reusable/singleTaskInList";
|
|
|
|
export default {
|
|
name: 'ShowTasks',
|
|
components: {
|
|
SingleTaskInList,
|
|
},
|
|
data() {
|
|
return {
|
|
tasks: [],
|
|
hasUndoneTasks: false,
|
|
taskService: TaskService,
|
|
}
|
|
},
|
|
props: {
|
|
startDate: Date,
|
|
endDate: Date,
|
|
showAll: Boolean,
|
|
},
|
|
created() {
|
|
this.taskService = new TaskService()
|
|
this.loadPendingTasks()
|
|
},
|
|
computed: {
|
|
undoneTasks: function () {
|
|
return this.tasks.filter(t => !t.done)
|
|
}
|
|
},
|
|
methods: {
|
|
loadPendingTasks() {
|
|
let params = {sort_by: ['dueDate_unix', 'id'], order_by: ['desc', 'desc']}
|
|
if (!this.showAll) {
|
|
params.startdate = Math.round(+ this.startDate / 1000)
|
|
params.enddate = Math.round(+ this.endDate / 1000)
|
|
}
|
|
|
|
this.taskService.getAll({}, params)
|
|
.then(r => {
|
|
if (r.length > 0) {
|
|
for (const index in r) {
|
|
if (r[index].done !== true) {
|
|
this.hasUndoneTasks = true
|
|
}
|
|
}
|
|
}
|
|
this.$set(this, 'tasks', r)
|
|
this.sortTasks()
|
|
})
|
|
.catch(e => {
|
|
this.error(e, this)
|
|
})
|
|
},
|
|
sortTasks() {
|
|
if (this.tasks === null || this.tasks === []) {
|
|
return
|
|
}
|
|
return this.tasks.sort(function(a,b) {
|
|
if (a.done < b.done)
|
|
return -1
|
|
if (a.done > b.done)
|
|
return 1
|
|
|
|
if (a.id > b.id)
|
|
return -1
|
|
if (a.id < b.id)
|
|
return 1
|
|
return 0
|
|
})
|
|
},
|
|
updateTasks(updatedTask) {
|
|
for (const t in this.tasks) {
|
|
if (this.tasks[t].id === updatedTask.id) {
|
|
this.$set(this.tasks, t, updatedTask)
|
|
break
|
|
}
|
|
}
|
|
this.sortTasks()
|
|
},
|
|
},
|
|
}
|
|
</script>
|
|
|
|
<style scoped>
|
|
h3{
|
|
text-align: left;
|
|
}
|
|
|
|
h3.nothing{
|
|
text-align: center;
|
|
margin-top: 3em;
|
|
}
|
|
|
|
img{
|
|
margin-top: 2em;
|
|
}
|
|
|
|
.spinner.is-loading:after {
|
|
margin-left: calc(40% - 1em);
|
|
}
|
|
</style> |