|
|
|
@ -1,53 +1,35 @@
|
|
|
|
|
<template>
|
|
|
|
|
<div class="is-max-width-desktop show-tasks">
|
|
|
|
|
<fancycheckbox
|
|
|
|
|
@change="setDate"
|
|
|
|
|
class="is-pulled-right"
|
|
|
|
|
v-if="!showAll"
|
|
|
|
|
v-model="showNulls"
|
|
|
|
|
>
|
|
|
|
|
{{ $t('task.show.noDates') }}
|
|
|
|
|
</fancycheckbox>
|
|
|
|
|
<h3 v-if="showAll && tasks.length > 0">
|
|
|
|
|
{{ $t('task.show.current') }}
|
|
|
|
|
<div class="is-max-width-desktop has-text-left ">
|
|
|
|
|
<h3 class="mb-2">
|
|
|
|
|
{{ pageTitle }}
|
|
|
|
|
</h3>
|
|
|
|
|
<h3 v-else-if="!showAll" class="mb-2">
|
|
|
|
|
{{ $t('task.show.from') }}
|
|
|
|
|
<flat-pickr
|
|
|
|
|
:class="{ 'disabled': loading}"
|
|
|
|
|
:config="flatPickerConfig"
|
|
|
|
|
:disabled="loading"
|
|
|
|
|
@on-close="setDate"
|
|
|
|
|
class="input"
|
|
|
|
|
v-model="cStartDate"
|
|
|
|
|
/>
|
|
|
|
|
{{ $t('task.show.until') }}
|
|
|
|
|
<flat-pickr
|
|
|
|
|
:class="{ 'disabled': loading}"
|
|
|
|
|
:config="flatPickerConfig"
|
|
|
|
|
:disabled="loading"
|
|
|
|
|
@on-close="setDate"
|
|
|
|
|
class="input"
|
|
|
|
|
v-model="cEndDate"
|
|
|
|
|
/>
|
|
|
|
|
</h3>
|
|
|
|
|
<div v-if="!showAll" class="mb-4">
|
|
|
|
|
<x-button variant="secondary" @click="showTodaysTasks()" class="mr-2">{{ $t('task.show.today') }}</x-button>
|
|
|
|
|
<x-button variant="secondary" @click="setDatesToNextWeek()" class="mr-2">{{ $t('task.show.nextWeek') }}</x-button>
|
|
|
|
|
<x-button variant="secondary" @click="setDatesToNextMonth()">{{ $t('task.show.nextMonth') }}</x-button>
|
|
|
|
|
</div>
|
|
|
|
|
<p v-if="!showAll" class="show-tasks-options">
|
|
|
|
|
<datepicker-with-range @dateChanged="setDate"/>
|
|
|
|
|
<fancycheckbox @change="setShowNulls" class="mr-2">
|
|
|
|
|
{{ $t('task.show.noDates') }}
|
|
|
|
|
</fancycheckbox>
|
|
|
|
|
<fancycheckbox @change="setShowOverdue">
|
|
|
|
|
{{ $t('task.show.overdue') }}
|
|
|
|
|
</fancycheckbox>
|
|
|
|
|
</p>
|
|
|
|
|
<template v-if="!loading && (!tasks || tasks.length === 0) && showNothingToDo">
|
|
|
|
|
<h3 class="nothing">{{ $t('task.show.noTasks') }}</h3>
|
|
|
|
|
<LlamaCool class="llama-cool" />
|
|
|
|
|
<h3 class="has-text-centered mt-6">{{ $t('task.show.noTasks') }}</h3>
|
|
|
|
|
<LlamaCool class="mt-5"/>
|
|
|
|
|
</template>
|
|
|
|
|
<div :class="{ 'is-loading': loading}" class="spinner"></div>
|
|
|
|
|
|
|
|
|
|
<card :padding="false" class="has-overflow" :has-content="false" v-if="tasks && tasks.length > 0">
|
|
|
|
|
<div class="tasks">
|
|
|
|
|
<div v-if="!hasTasks" :class="{ 'is-loading': loading}" class="spinner"></div>
|
|
|
|
|
<card
|
|
|
|
|
v-if="hasTasks"
|
|
|
|
|
:padding="false"
|
|
|
|
|
class="has-overflow"
|
|
|
|
|
:has-content="false"
|
|
|
|
|
:loading="loading"
|
|
|
|
|
>
|
|
|
|
|
<div class="p-2">
|
|
|
|
|
<single-task-in-list
|
|
|
|
|
v-for="t in tasksSorted"
|
|
|
|
|
:key="t.id"
|
|
|
|
|
class="task"
|
|
|
|
|
v-for="t in tasks"
|
|
|
|
|
:show-list="true"
|
|
|
|
|
:the-task="t"
|
|
|
|
|
@taskUpdated="updateTasks"/>
|
|
|
|
@ -56,33 +38,26 @@
|
|
|
|
|
</div>
|
|
|
|
|
</template>
|
|
|
|
|
<script>
|
|
|
|
|
import SingleTaskInList from '../../components/tasks/partials/singleTaskInList'
|
|
|
|
|
import SingleTaskInList from '@/components/tasks/partials/singleTaskInList'
|
|
|
|
|
import {mapState} from 'vuex'
|
|
|
|
|
|
|
|
|
|
import flatPickr from 'vue-flatpickr-component'
|
|
|
|
|
import 'flatpickr/dist/flatpickr.css'
|
|
|
|
|
import Fancycheckbox from '../../components/input/fancycheckbox'
|
|
|
|
|
import {LOADING, LOADING_MODULE} from '../../store/mutation-types'
|
|
|
|
|
import Fancycheckbox from '@/components/input/fancycheckbox'
|
|
|
|
|
import {LOADING, LOADING_MODULE} from '@/store/mutation-types'
|
|
|
|
|
|
|
|
|
|
import LlamaCool from '@/assets/llama-cool.svg?component'
|
|
|
|
|
import DatepickerWithRange from '@/components/date/datepickerWithRange'
|
|
|
|
|
|
|
|
|
|
export default {
|
|
|
|
|
name: 'ShowTasks',
|
|
|
|
|
components: {
|
|
|
|
|
DatepickerWithRange,
|
|
|
|
|
Fancycheckbox,
|
|
|
|
|
SingleTaskInList,
|
|
|
|
|
flatPickr,
|
|
|
|
|
LlamaCool,
|
|
|
|
|
},
|
|
|
|
|
data() {
|
|
|
|
|
return {
|
|
|
|
|
tasks: [],
|
|
|
|
|
showNulls: true,
|
|
|
|
|
showOverdue: false,
|
|
|
|
|
|
|
|
|
|
cStartDate: null,
|
|
|
|
|
cEndDate: null,
|
|
|
|
|
|
|
|
|
|
showNothingToDo: false,
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
@ -92,8 +67,6 @@ export default {
|
|
|
|
|
showAll: Boolean,
|
|
|
|
|
},
|
|
|
|
|
created() {
|
|
|
|
|
this.cStartDate = this.startDate
|
|
|
|
|
this.cEndDate = this.endDate
|
|
|
|
|
this.loadPendingTasks()
|
|
|
|
|
},
|
|
|
|
|
mounted() {
|
|
|
|
@ -104,25 +77,54 @@ export default {
|
|
|
|
|
handler: 'loadPendingTasks',
|
|
|
|
|
deep: true,
|
|
|
|
|
},
|
|
|
|
|
startDate(newVal) {
|
|
|
|
|
this.cStartDate = newVal
|
|
|
|
|
},
|
|
|
|
|
endDate(newVal) {
|
|
|
|
|
this.cEndDate = newVal
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
computed: {
|
|
|
|
|
flatPickerConfig() {
|
|
|
|
|
return {
|
|
|
|
|
altFormat: this.$t('date.altFormatLong'),
|
|
|
|
|
altInput: true,
|
|
|
|
|
dateFormat: 'Y-m-d H:i',
|
|
|
|
|
enableTime: true,
|
|
|
|
|
time_24hr: true,
|
|
|
|
|
locale: {
|
|
|
|
|
firstDayOfWeek: this.$store.state.auth.settings.weekStart,
|
|
|
|
|
},
|
|
|
|
|
}
|
|
|
|
|
dateFrom() {
|
|
|
|
|
const d = new Date(Number(this.$route.query.from))
|
|
|
|
|
|
|
|
|
|
return !isNaN(d)
|
|
|
|
|
? d
|
|
|
|
|
: this.startDate
|
|
|
|
|
},
|
|
|
|
|
dateTo() {
|
|
|
|
|
const d = new Date(Number(this.$route.query.to))
|
|
|
|
|
|
|
|
|
|
return !isNaN(d)
|
|
|
|
|
? d
|
|
|
|
|
: this.endDate
|
|
|
|
|
},
|
|
|
|
|
showNulls() {
|
|
|
|
|
return this.$route.query.showNulls === 'true'
|
|
|
|
|
},
|
|
|
|
|
showOverdue() {
|
|
|
|
|
return this.$route.query.showOverdue === 'true'
|
|
|
|
|
},
|
|
|
|
|
pageTitle() {
|
|
|
|
|
const title = this.showAll
|
|
|
|
|
? this.$t('task.show.titleCurrent')
|
|
|
|
|
: this.$t('task.show.fromuntil', {
|
|
|
|
|
from: this.format(this.dateFrom, 'PPP'),
|
|
|
|
|
until: this.format(this.dateTo, 'PPP'),
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
this.setTitle(title)
|
|
|
|
|
|
|
|
|
|
return title
|
|
|
|
|
},
|
|
|
|
|
tasksSorted() {
|
|
|
|
|
// Sort all tasks to put those with a due date before the ones without a due date, the
|
|
|
|
|
// soonest before the later ones.
|
|
|
|
|
// We can't use the api sorting here because that sorts tasks with a due date after
|
|
|
|
|
// ones without a due date.
|
|
|
|
|
return [...this.tasks].sort((a, b) => {
|
|
|
|
|
const sortByDueDate = b.dueDate - a.dueDate
|
|
|
|
|
return sortByDueDate === 0
|
|
|
|
|
? b.id - a.id
|
|
|
|
|
: sortByDueDate
|
|
|
|
|
})
|
|
|
|
|
},
|
|
|
|
|
hasTasks() {
|
|
|
|
|
return this.tasks && this.tasks.length > 0
|
|
|
|
|
},
|
|
|
|
|
...mapState({
|
|
|
|
|
userAuthenticated: state => state.auth.authenticated,
|
|
|
|
@ -130,17 +132,35 @@ export default {
|
|
|
|
|
}),
|
|
|
|
|
},
|
|
|
|
|
methods: {
|
|
|
|
|
setDate() {
|
|
|
|
|
setDate({dateFrom, dateTo}) {
|
|
|
|
|
this.$router.push({
|
|
|
|
|
name: this.$route.name,
|
|
|
|
|
query: {
|
|
|
|
|
from: +new Date(this.cStartDate),
|
|
|
|
|
to: +new Date(this.cEndDate),
|
|
|
|
|
from: +new Date(dateFrom ?? this.dateFrom),
|
|
|
|
|
to: +new Date(dateTo ?? this.dateTo),
|
|
|
|
|
showOverdue: this.showOverdue,
|
|
|
|
|
showNulls: this.showNulls,
|
|
|
|
|
},
|
|
|
|
|
})
|
|
|
|
|
},
|
|
|
|
|
setShowOverdue(show) {
|
|
|
|
|
this.$router.push({
|
|
|
|
|
name: this.$route.name,
|
|
|
|
|
query: {
|
|
|
|
|
...this.$route.query,
|
|
|
|
|
showOverdue: show,
|
|
|
|
|
},
|
|
|
|
|
})
|
|
|
|
|
},
|
|
|
|
|
setShowNulls(show) {
|
|
|
|
|
this.$router.push({
|
|
|
|
|
name: this.$route.name,
|
|
|
|
|
query: {
|
|
|
|
|
...this.$route.query,
|
|
|
|
|
showNulls: show,
|
|
|
|
|
},
|
|
|
|
|
})
|
|
|
|
|
},
|
|
|
|
|
async loadPendingTasks() {
|
|
|
|
|
// Since this route is authentication only, users would get an error message if they access the page unauthenticated.
|
|
|
|
|
// Since this component is mounted as the home page before unauthenticated users get redirected
|
|
|
|
@ -149,26 +169,6 @@ export default {
|
|
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Make sure all dates are date objects
|
|
|
|
|
if (typeof this.$route.query.from !== 'undefined' && typeof this.$route.query.to !== 'undefined') {
|
|
|
|
|
this.cStartDate = new Date(Number(this.$route.query.from))
|
|
|
|
|
this.cEndDate = new Date(Number(this.$route.query.to))
|
|
|
|
|
} else {
|
|
|
|
|
this.cStartDate = new Date(this.cStartDate)
|
|
|
|
|
this.cEndDate = new Date(this.cEndDate)
|
|
|
|
|
}
|
|
|
|
|
this.showOverdue = this.$route.query.showOverdue
|
|
|
|
|
this.showNulls = this.$route.query.showNulls
|
|
|
|
|
|
|
|
|
|
if (this.showAll) {
|
|
|
|
|
this.setTitle(this.$t('task.show.titleCurrent'))
|
|
|
|
|
} else {
|
|
|
|
|
this.setTitle(this.$t('task.show.titleDates', {
|
|
|
|
|
from: this.cStartDate.toLocaleDateString(),
|
|
|
|
|
to: this.cEndDate.toLocaleDateString(),
|
|
|
|
|
}))
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const params = {
|
|
|
|
|
sort_by: ['due_date', 'id'],
|
|
|
|
|
order_by: ['desc', 'desc'],
|
|
|
|
@ -178,41 +178,23 @@ export default {
|
|
|
|
|
filter_concat: 'and',
|
|
|
|
|
filter_include_nulls: this.showNulls,
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (!this.showAll) {
|
|
|
|
|
if (this.showNulls) {
|
|
|
|
|
params.filter_by.push('start_date')
|
|
|
|
|
params.filter_value.push(this.cStartDate)
|
|
|
|
|
params.filter_comparator.push('greater')
|
|
|
|
|
|
|
|
|
|
params.filter_by.push('end_date')
|
|
|
|
|
params.filter_value.push(this.cEndDate)
|
|
|
|
|
params.filter_comparator.push('less')
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
params.filter_by.push('due_date')
|
|
|
|
|
params.filter_value.push(this.cEndDate)
|
|
|
|
|
params.filter_value.push(this.dateTo)
|
|
|
|
|
params.filter_comparator.push('less')
|
|
|
|
|
|
|
|
|
|
// NOTE: Ideally we could also show tasks with a start or end date in the specified range, but the api
|
|
|
|
|
// is not capable (yet) of combining multiple filters with 'and' and 'or'.
|
|
|
|
|
|
|
|
|
|
if (!this.showOverdue) {
|
|
|
|
|
params.filter_by.push('due_date')
|
|
|
|
|
params.filter_value.push(this.cStartDate)
|
|
|
|
|
params.filter_value.push(this.dateFrom)
|
|
|
|
|
params.filter_comparator.push('greater')
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const tasks = await this.$store.dispatch('tasks/loadTasks', params)
|
|
|
|
|
|
|
|
|
|
// FIXME: sort tasks in computed
|
|
|
|
|
// Sort all tasks to put those with a due date before the ones without a due date, the
|
|
|
|
|
// soonest before the later ones.
|
|
|
|
|
// We can't use the api sorting here because that sorts tasks with a due date after
|
|
|
|
|
// ones without a due date.
|
|
|
|
|
this.tasks = tasks.sort((a, b) => {
|
|
|
|
|
const sortByDueDate = b.dueDate - a.dueDate
|
|
|
|
|
return sortByDueDate === 0
|
|
|
|
|
? b.id - a.id
|
|
|
|
|
: sortByDueDate
|
|
|
|
|
})
|
|
|
|
|
this.tasks = await this.$store.dispatch('tasks/loadTasks', params)
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
// FIXME: this modification should happen in the store
|
|
|
|
@ -257,18 +239,12 @@ export default {
|
|
|
|
|
</script>
|
|
|
|
|
|
|
|
|
|
<style lang="scss" scoped>
|
|
|
|
|
h3 {
|
|
|
|
|
text-align: left;
|
|
|
|
|
.show-tasks-options {
|
|
|
|
|
display: flex;
|
|
|
|
|
flex-direction: column;
|
|
|
|
|
|
|
|
|
|
&.nothing {
|
|
|
|
|
text-align: center;
|
|
|
|
|
margin-top: 3rem;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
:deep(.input) {
|
|
|
|
|
width: 190px;
|
|
|
|
|
vertical-align: middle;
|
|
|
|
|
margin: .5rem 0;
|
|
|
|
|
> :deep(a) {
|
|
|
|
|
margin-right: .5rem;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|