2018-12-25 23:41:55 +01:00
|
|
|
<template>
|
|
|
|
<div>
|
|
|
|
<h3 v-if="showAll">Current tasks</h3>
|
|
|
|
<h3 v-else>Tasks from {{startDate.toLocaleDateString()}} until {{endDate.toLocaleDateString()}}</h3>
|
2019-03-10 13:59:17 +01:00
|
|
|
<template v-if="!taskService.loading && (!hasUndoneTasks || !tasks)">
|
2018-12-25 23:41:55 +01:00
|
|
|
<h3 class="nothing">Nothing to to - Have a nice day!</h3>
|
|
|
|
<img src="/images/cool.svg" alt=""/>
|
|
|
|
</template>
|
2019-03-10 13:59:17 +01:00
|
|
|
<div class="spinner" :class="{ 'is-loading': taskService.loading}"></div>
|
2018-12-25 23:41:55 +01:00
|
|
|
<div class="tasks" v-if="tasks && tasks.length > 0">
|
|
|
|
<div @click="gotoList(l.listID)" class="task" v-for="l in tasks" :key="l.id" v-if="!l.done">
|
|
|
|
<label :for="l.id">
|
|
|
|
<div class="fancycheckbox">
|
|
|
|
<input type="checkbox" :id="l.id" :checked="l.done" style="display: none;" disabled>
|
|
|
|
<label :for="l.id" class="check">
|
|
|
|
<svg width="18px" height="18px" viewBox="0 0 18 18">
|
|
|
|
<path d="M1,9 L1,3.5 C1,2 2,1 3.5,1 L14.5,1 C16,1 17,2 17,3.5 L17,14.5 C17,16 16,17 14.5,17 L3.5,17 C2,17 1,16 1,14.5 L1,9 Z"></path>
|
|
|
|
<polyline points="1 9 7 14 15 4"></polyline>
|
|
|
|
</svg>
|
|
|
|
</label>
|
|
|
|
</div>
|
|
|
|
<span class="tasktext">
|
2019-03-03 16:03:08 +01:00
|
|
|
{{l.text}}
|
|
|
|
<i v-if="l.dueDate > 0" :class="{'overdue': (new Date(l.dueDate * 1000) <= new Date())}"> - Due on {{formatUnixDate(l.dueDate)}}</i>
|
|
|
|
<span v-if="l.priority >= priorities.HIGH" class="high-priority" :class="{'not-so-high': l.priority === priorities.HIGH}">
|
|
|
|
<span class="icon">
|
|
|
|
<icon icon="exclamation"/>
|
|
|
|
</span>
|
|
|
|
<template v-if="l.priority === priorities.HIGH">High</template>
|
|
|
|
<template v-if="l.priority === priorities.URGENT">Urgent</template>
|
|
|
|
<template v-if="l.priority === priorities.DO_NOW">DO NOW</template>
|
|
|
|
<span class="icon" v-if="l.priority === priorities.DO_NOW">
|
|
|
|
<icon icon="exclamation"/>
|
|
|
|
</span>
|
2018-12-25 23:41:55 +01:00
|
|
|
</span>
|
2019-03-03 16:03:08 +01:00
|
|
|
</span>
|
2018-12-25 23:41:55 +01:00
|
|
|
</label>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</template>
|
|
|
|
<script>
|
|
|
|
import router from '../../router'
|
|
|
|
import message from '../../message'
|
2019-03-02 11:25:10 +01:00
|
|
|
import TaskService from '../../services/task'
|
2019-03-03 16:03:08 +01:00
|
|
|
import priorities from '../../models/priorities'
|
2018-12-25 23:41:55 +01:00
|
|
|
|
|
|
|
export default {
|
|
|
|
name: "ShowTasks",
|
|
|
|
data() {
|
|
|
|
return {
|
|
|
|
tasks: [],
|
2019-03-02 11:25:10 +01:00
|
|
|
hasUndoneTasks: false,
|
|
|
|
taskService: TaskService,
|
2019-03-03 16:03:08 +01:00
|
|
|
priorities: priorities,
|
2018-12-25 23:41:55 +01:00
|
|
|
}
|
|
|
|
},
|
|
|
|
props: {
|
|
|
|
startDate: Date,
|
|
|
|
endDate: Date,
|
|
|
|
showAll: Boolean,
|
|
|
|
},
|
|
|
|
created() {
|
2019-03-02 11:25:10 +01:00
|
|
|
this.taskService = new TaskService()
|
2018-12-25 23:41:55 +01:00
|
|
|
this.loadPendingTasks()
|
|
|
|
},
|
|
|
|
methods: {
|
|
|
|
loadPendingTasks() {
|
2019-03-10 13:59:17 +01:00
|
|
|
let params = {'sort': 'duedate'}
|
2018-12-25 23:41:55 +01:00
|
|
|
if (!this.showAll) {
|
2019-03-10 13:59:17 +01:00
|
|
|
params.startdate = Math.round(+ this.startDate / 1000)
|
|
|
|
params.enddate = Math.round(+ this.endDate / 1000)
|
2018-12-25 23:41:55 +01:00
|
|
|
}
|
|
|
|
|
2019-03-10 13:59:17 +01:00
|
|
|
this.taskService.getAll({}, params)
|
|
|
|
.then(r => {
|
|
|
|
if (r.length > 0) {
|
|
|
|
for (const index in r) {
|
|
|
|
if (r[index].done !== true) {
|
2018-12-25 23:48:32 +01:00
|
|
|
this.hasUndoneTasks = true
|
|
|
|
}
|
2018-12-25 23:41:55 +01:00
|
|
|
}
|
2019-03-10 13:59:17 +01:00
|
|
|
r.sort(this.sortyByDeadline)
|
2018-12-25 23:41:55 +01:00
|
|
|
}
|
2019-03-10 13:59:17 +01:00
|
|
|
this.$set(this, 'tasks', r)
|
2018-12-25 23:41:55 +01:00
|
|
|
})
|
|
|
|
.catch(e => {
|
2019-03-10 13:59:17 +01:00
|
|
|
message.error(e, this)
|
2018-12-25 23:41:55 +01:00
|
|
|
})
|
|
|
|
},
|
|
|
|
formatUnixDate(dateUnix) {
|
|
|
|
return (new Date(dateUnix * 1000)).toLocaleString()
|
|
|
|
},
|
|
|
|
sortyByDeadline(a, b) {
|
|
|
|
return ((a.dueDate > b.dueDate) ? -1 : ((a.dueDate < b.dueDate) ? 1 : 0));
|
|
|
|
},
|
|
|
|
gotoList(lid) {
|
|
|
|
router.push({name: 'showList', params: {id: lid}})
|
|
|
|
},
|
|
|
|
},
|
|
|
|
}
|
|
|
|
</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>
|