Compare commits
14 Commits
main
...
feature/da
Author | SHA1 | Date |
---|---|---|
kolaente | 3b73925de5 | |
kolaente | d4f4ebb66b | |
kolaente | ac0182cbc2 | |
kolaente | 60c3bf819b | |
kolaente | 3a54402b95 | |
kolaente | 69b516a3fb | |
kolaente | 2a884dfd45 | |
kolaente | c04530c540 | |
kolaente | fd4eec4769 | |
kolaente | d128c4a71f | |
kolaente | fe85611286 | |
kolaente | 6ed80df297 | |
kolaente | 6a62fdd963 | |
kolaente | fda94799b4 |
|
@ -0,0 +1,21 @@
|
|||
export const dateRanges = {
|
||||
// Format:
|
||||
// Key is the title, as a translation string, the first entry of the value array
|
||||
// is the "from" date, the second one is the "to" date.
|
||||
'today': ['now/d', 'now/d+1d'],
|
||||
|
||||
'lastWeek': ['now/w-1w', 'now/w-2w'],
|
||||
'thisWeek': ['now/w', 'now/w+1w'],
|
||||
'restOfThisWeek': ['now', 'now/w+1w'],
|
||||
'nextWeek': ['now/w+1w', 'now/w+2w'],
|
||||
'next7Days': ['now', 'now+7d'],
|
||||
|
||||
'lastMonth': ['now/M-1M', 'now/M-2M'],
|
||||
'thisMonth': ['now/M', 'now/M+1M'],
|
||||
'restOfThisMonth': ['now', 'now/M+1M'],
|
||||
'nextMonth': ['now/M+1M', 'now/M+2M'],
|
||||
'next30Days': ['now', 'now+30d'],
|
||||
|
||||
'thisYear': ['now/y', 'now/y+1y'],
|
||||
'restOfThisYear': ['now', 'now/y+1y'],
|
||||
}
|
|
@ -2,49 +2,167 @@
|
|||
<div class="datepicker-with-range-container">
|
||||
<popup>
|
||||
<template #trigger="{toggle}">
|
||||
<x-button @click.prevent.stop="toggle()" type="secondary" :shadow="false" class="mb-2">
|
||||
{{ $t('task.show.select') }}
|
||||
<x-button @click.prevent.stop="toggle()" variant="secondary" :shadow="false" class="mb-2">
|
||||
{{ buttonText }}
|
||||
</x-button>
|
||||
</template>
|
||||
<template #content="{isOpen}">
|
||||
<div class="datepicker-with-range" :class="{'is-open': isOpen}">
|
||||
<div class="selections">
|
||||
<button @click="setDateRange(datesToday)" :class="{'is-active': dateRange === datesToday}">
|
||||
{{ $t('task.show.today') }}
|
||||
</button>
|
||||
<button @click="setDateRange(datesThisWeek)"
|
||||
:class="{'is-active': dateRange === datesThisWeek}">
|
||||
{{ $t('task.show.thisWeek') }}
|
||||
</button>
|
||||
<button @click="setDateRange(datesNextWeek)"
|
||||
:class="{'is-active': dateRange === datesNextWeek}">
|
||||
{{ $t('task.show.nextWeek') }}
|
||||
</button>
|
||||
<button @click="setDateRange(datesNext7Days)"
|
||||
:class="{'is-active': dateRange === datesNext7Days}">
|
||||
{{ $t('task.show.next7Days') }}
|
||||
</button>
|
||||
<button @click="setDateRange(datesThisMonth)"
|
||||
:class="{'is-active': dateRange === datesThisMonth}">
|
||||
{{ $t('task.show.thisMonth') }}
|
||||
</button>
|
||||
<button @click="setDateRange(datesNextMonth)"
|
||||
:class="{'is-active': dateRange === datesNextMonth}">
|
||||
{{ $t('task.show.nextMonth') }}
|
||||
</button>
|
||||
<button @click="setDateRange(datesNext30Days)"
|
||||
:class="{'is-active': dateRange === datesNext30Days}">
|
||||
{{ $t('task.show.next30Days') }}
|
||||
</button>
|
||||
<button @click="setDateRange('')" :class="{'is-active': customRangeActive}">
|
||||
<button @click="setDateRange(null)" :class="{'is-active': customRangeActive}">
|
||||
{{ $t('misc.custom') }}
|
||||
</button>
|
||||
<button
|
||||
v-for="(value, text) in dateRanges"
|
||||
:key="text"
|
||||
@click="setDateRange(value)"
|
||||
:class="{'is-active': from === value[0] && to === value[1]}">
|
||||
{{ $t(`input.datepickerRange.ranges.${text}`) }}
|
||||
</button>
|
||||
</div>
|
||||
<div class="flatpickr-container">
|
||||
<div class="flatpickr-container input-group">
|
||||
<label class="label">
|
||||
{{ $t('input.datepickerRange.from') }}
|
||||
<div class="field has-addons">
|
||||
<div class="control is-fullwidth">
|
||||
<input class="input" type="text" v-model="from" @change="inputChanged"/>
|
||||
</div>
|
||||
<div class="control">
|
||||
<x-button icon="calendar" variant="secondary" data-toggle/>
|
||||
</div>
|
||||
</div>
|
||||
</label>
|
||||
<label class="label">
|
||||
{{ $t('input.datepickerRange.to') }}
|
||||
<div class="field has-addons">
|
||||
<div class="control is-fullwidth">
|
||||
<input class="input" type="text" v-model="to" @change="inputChanged"/>
|
||||
</div>
|
||||
<div class="control">
|
||||
<x-button icon="calendar" variant="secondary" data-toggle/>
|
||||
</div>
|
||||
</div>
|
||||
</label>
|
||||
<flat-pickr
|
||||
:config="flatPickerConfig"
|
||||
v-model="dateRange"
|
||||
v-model="flatpickrRange"
|
||||
/>
|
||||
|
||||
<p>
|
||||
{{ $t('input.datepickerRange.math.canuse') }}
|
||||
<a @click="showHowItWorks = true">{{ $t('input.datepickerRange.math.learnhow') }}</a>.
|
||||
</p>
|
||||
|
||||
<modal
|
||||
@close="() => showHowItWorks = false"
|
||||
:enabled="showHowItWorks"
|
||||
transition-name="fade"
|
||||
:overflow="true"
|
||||
variant="hint-modal"
|
||||
>
|
||||
<card class="has-no-shadow how-it-works-modal" :title="$t('input.datepickerRange.math.title')">
|
||||
<p>
|
||||
{{ $t('input.datepickerRange.math.intro') }}
|
||||
</p>
|
||||
<p>
|
||||
<i18n-t keypath="input.datepickerRange.math.expression">
|
||||
<code>now</code>
|
||||
<code>||</code>
|
||||
</i18n-t>
|
||||
</p>
|
||||
<p>
|
||||
<i18n-t keypath="input.datepickerRange.math.similar">
|
||||
<a href="https://grafana.com/docs/grafana/latest/dashboards/time-range-controls/" rel="noreferrer noopener nofollow" target="_blank">
|
||||
Grafana
|
||||
</a>
|
||||
<a href="https://www.elastic.co/guide/en/elasticsearch/reference/7.3/common-options.html#date-math" rel="noreferrer noopener nofollow" target="_blank">
|
||||
Elasticsearch
|
||||
</a>
|
||||
</i18n-t>
|
||||
</p>
|
||||
<p>{{ $t('misc.forExample') }}</p>
|
||||
<ul>
|
||||
<li><code>+1d</code>{{ $t('input.datepickerRange.math.add1Day') }}</li>
|
||||
<li><code>-1d</code>{{ $t('input.datepickerRange.math.minus1Day') }}</li>
|
||||
<li><code>/d</code>{{ $t('input.datepickerRange.math.roundDay') }}</li>
|
||||
</ul>
|
||||
<p>{{ $t('input.datepickerRange.math.supportedUnits') }}</p>
|
||||
<table class="table">
|
||||
<tbody>
|
||||
<tr>
|
||||
<td><code>s</code></td>
|
||||
<td>{{ $t('input.datepickerRange.math.units.seconds') }}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><code>m</code></td>
|
||||
<td>{{ $t('input.datepickerRange.math.units.minutes') }}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><code>h</code></td>
|
||||
<td>{{ $t('input.datepickerRange.math.units.hours') }}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><code>H</code></td>
|
||||
<td>{{ $t('input.datepickerRange.math.units.hours') }}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><code>d</code></td>
|
||||
<td>{{ $t('input.datepickerRange.math.units.days') }}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><code>w</code></td>
|
||||
<td>{{ $t('input.datepickerRange.math.units.weeks') }}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><code>M</code></td>
|
||||
<td>{{ $t('input.datepickerRange.math.units.months') }}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><code>y</code></td>
|
||||
<td>{{ $t('input.datepickerRange.math.units.years') }}</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
<p>{{ $t('input.datepickerRange.math.someExamples') }}</p>
|
||||
<table class="table">
|
||||
<tbody>
|
||||
<tr>
|
||||
<td><code>now</code></td>
|
||||
<td>{{ $t('input.datepickerRange.math.examples.now') }}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><code>now+24h</code></td>
|
||||
<td>{{ $t('input.datepickerRange.math.examples.in24h') }}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><code>now/d</code></td>
|
||||
<td>{{ $t('input.datepickerRange.math.examples.today') }}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><code>now/w</code></td>
|
||||
<td>{{ $t('input.datepickerRange.math.examples.beginningOfThisWeek') }}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><code>now/w+1w</code></td>
|
||||
<td>{{ $t('input.datepickerRange.math.examples.endOfThisWeek') }}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><code>now+30d</code></td>
|
||||
<td>{{ $t('input.datepickerRange.math.examples.in30Days') }}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><code>{{ exampleDate }}||+1M/d</code></td>
|
||||
<td>
|
||||
<i18n-t keypath="input.datepickerRange.math.examples.datePlusMonth">
|
||||
<code>{{ exampleDate }}</code>
|
||||
</i18n-t>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</card>
|
||||
</modal>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
@ -59,12 +177,21 @@ import {computed, ref, watch} from 'vue'
|
|||
import {useI18n} from 'vue-i18n'
|
||||
import {store} from '@/store'
|
||||
import {format} from 'date-fns'
|
||||
import Popup from '@/components/misc/popup'
|
||||
import Popup from '@/components/misc/popup.vue'
|
||||
|
||||
import {dateRanges} from '@/components/date/dateRanges'
|
||||
|
||||
const {t} = useI18n()
|
||||
|
||||
const emit = defineEmits(['dateChanged'])
|
||||
|
||||
const props = defineProps({
|
||||
showSelectedOnButton: {
|
||||
type: Boolean,
|
||||
default: false,
|
||||
},
|
||||
})
|
||||
|
||||
// FIXME: This seems to always contain the default value - that breaks the picker
|
||||
const weekStart = computed<number>(() => store.state.auth.settings.weekStart ?? 0)
|
||||
const flatPickerConfig = computed(() => ({
|
||||
|
@ -72,17 +199,35 @@ const flatPickerConfig = computed(() => ({
|
|||
altInput: true,
|
||||
dateFormat: 'Y-m-d H:i',
|
||||
enableTime: false,
|
||||
inline: true,
|
||||
wrap: true,
|
||||
mode: 'range',
|
||||
locale: {
|
||||
firstDayOf7Days: weekStart.value,
|
||||
},
|
||||
}))
|
||||
|
||||
const dateRange = ref<string>('')
|
||||
const showHowItWorks = ref<boolean>(false)
|
||||
const exampleDate = format(new Date(), 'yyyy-MM-dd')
|
||||
|
||||
const flatpickrRange = ref<string>('')
|
||||
|
||||
const from = ref<string>('')
|
||||
const to = ref<string>('')
|
||||
|
||||
function emitChanged() {
|
||||
emit('dateChanged', {
|
||||
dateFrom: from.value === '' ? null : from.value,
|
||||
dateTo: to.value === '' ? null : to.value,
|
||||
})
|
||||
}
|
||||
|
||||
function inputChanged() {
|
||||
flatpickrRange.value = ''
|
||||
emitChanged()
|
||||
}
|
||||
|
||||
watch(
|
||||
() => dateRange.value,
|
||||
() => flatpickrRange.value,
|
||||
(newVal: string | null) => {
|
||||
if (newVal === null) {
|
||||
return
|
||||
|
@ -94,115 +239,41 @@ watch(
|
|||
return
|
||||
}
|
||||
|
||||
emit('dateChanged', {
|
||||
dateFrom: new Date(fromDate),
|
||||
dateTo: new Date(toDate),
|
||||
})
|
||||
from.value = fromDate
|
||||
to.value = toDate
|
||||
|
||||
emitChanged()
|
||||
},
|
||||
)
|
||||
|
||||
function formatDate(date: Date): string {
|
||||
return format(date, 'yyyy-MM-dd HH:mm')
|
||||
}
|
||||
function setDateRange(range: string[] | null) {
|
||||
if (range === null) {
|
||||
from.value = ''
|
||||
to.value = ''
|
||||
inputChanged()
|
||||
|
||||
function startOfDay(date: Date): Date {
|
||||
date.setHours(0)
|
||||
date.setMinutes(0)
|
||||
|
||||
return date
|
||||
}
|
||||
|
||||
function endOfDay(date: Date): Date {
|
||||
date.setHours(23)
|
||||
date.setMinutes(59)
|
||||
|
||||
return date
|
||||
}
|
||||
|
||||
const datesToday = computed<string>(() => {
|
||||
const startDate = startOfDay(new Date())
|
||||
const endDate = endOfDay(new Date())
|
||||
|
||||
return `${formatDate(startDate)} to ${formatDate(endDate)}`
|
||||
})
|
||||
|
||||
function thisWeek() {
|
||||
const startDate = startOfDay(new Date())
|
||||
const first = startDate.getDate() - startDate.getDay() + weekStart.value
|
||||
startDate.setDate(first)
|
||||
const endDate = endOfDay(new Date((new Date(startDate).setDate(first + 6))))
|
||||
|
||||
return {
|
||||
startDate,
|
||||
endDate,
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
const datesThisWeek = computed<string>(() => {
|
||||
const {startDate, endDate} = thisWeek()
|
||||
from.value = range[0]
|
||||
to.value = range[1]
|
||||
|
||||
return `${formatDate(startDate)} to ${formatDate(endDate)}`
|
||||
})
|
||||
|
||||
const datesNextWeek = computed<string>(() => {
|
||||
const {startDate, endDate} = thisWeek()
|
||||
startDate.setDate(startDate.getDate() + 7)
|
||||
endDate.setDate(endDate.getDate() + 7)
|
||||
|
||||
return `${formatDate(startDate)} to ${formatDate(endDate)}`
|
||||
})
|
||||
|
||||
const datesNext7Days = computed<string>(() => {
|
||||
const startDate = startOfDay(new Date())
|
||||
const endDate = endOfDay(new Date((new Date()).getTime() + 7 * 24 * 60 * 60 * 1000))
|
||||
return `${formatDate(startDate)} to ${formatDate(endDate)}`
|
||||
})
|
||||
|
||||
function thisMonth() {
|
||||
const startDate = startOfDay(new Date())
|
||||
startDate.setDate(1)
|
||||
const endDate = endOfDay(new Date((new Date()).getFullYear(), (new Date()).getMonth() + 1, 0))
|
||||
|
||||
return {
|
||||
startDate,
|
||||
endDate,
|
||||
}
|
||||
}
|
||||
|
||||
const datesThisMonth = computed<string>(() => {
|
||||
const {startDate, endDate} = thisMonth()
|
||||
|
||||
return `${formatDate(startDate)} to ${formatDate(endDate)}`
|
||||
})
|
||||
|
||||
const datesNextMonth = computed<string>(() => {
|
||||
const {startDate, endDate} = thisMonth()
|
||||
|
||||
startDate.setMonth(startDate.getMonth() + 1)
|
||||
endDate.setMonth(endDate.getMonth() + 1)
|
||||
|
||||
return `${formatDate(startDate)} to ${formatDate(endDate)}`
|
||||
})
|
||||
|
||||
const datesNext30Days = computed<string>(() => {
|
||||
const startDate = startOfDay(new Date())
|
||||
const endDate = endOfDay(new Date((new Date()).setMonth((new Date()).getMonth() + 1)))
|
||||
|
||||
return `${formatDate(startDate)} to ${formatDate(endDate)}`
|
||||
})
|
||||
|
||||
function setDateRange(range: string) {
|
||||
dateRange.value = range
|
||||
inputChanged()
|
||||
}
|
||||
|
||||
const customRangeActive = computed<Boolean>(() => {
|
||||
return dateRange.value !== datesToday.value &&
|
||||
dateRange.value !== datesThisWeek.value &&
|
||||
dateRange.value !== datesNextWeek.value &&
|
||||
dateRange.value !== datesNext7Days.value &&
|
||||
dateRange.value !== datesThisMonth.value &&
|
||||
dateRange.value !== datesNextMonth.value &&
|
||||
dateRange.value !== datesNext30Days.value
|
||||
return !Object.values(dateRanges).some(el => from.value === el[0] && to.value === el[1])
|
||||
})
|
||||
|
||||
const buttonText = computed<string>(() => {
|
||||
if(props.showSelectedOnButton && from.value !== '' && to.value !== '') {
|
||||
return t('input.datepickerRange.fromto', {
|
||||
from: from.value,
|
||||
to: to.value,
|
||||
})
|
||||
}
|
||||
|
||||
return t('task.show.select')
|
||||
})
|
||||
</script>
|
||||
|
||||
|
@ -240,9 +311,27 @@ const customRangeActive = computed<Boolean>(() => {
|
|||
.flatpickr-container {
|
||||
width: 70%;
|
||||
border-left: 1px solid var(--grey-200);
|
||||
padding: 1rem;
|
||||
font-size: .9rem;
|
||||
|
||||
:deep(input.input) {
|
||||
display: none;
|
||||
// Flatpickr has no option to use it without an input field so we're hiding it instead
|
||||
:deep(input.form-control.input) {
|
||||
height: 0;
|
||||
padding: 0;
|
||||
border: 0;
|
||||
}
|
||||
|
||||
.field .control :deep(.button) {
|
||||
border: 1px solid var(--input-border-color);
|
||||
height: 2.25rem;
|
||||
|
||||
&:hover {
|
||||
border: 1px solid var(--input-hover-border-color);
|
||||
}
|
||||
}
|
||||
|
||||
.label, .input, :deep(.button) {
|
||||
font-size: .9rem;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -251,6 +340,7 @@ const customRangeActive = computed<Boolean>(() => {
|
|||
display: flex;
|
||||
flex-direction: column;
|
||||
padding-top: .5rem;
|
||||
overflow-y: scroll;
|
||||
|
||||
button {
|
||||
display: block;
|
||||
|
@ -273,4 +363,12 @@ const customRangeActive = computed<Boolean>(() => {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
.how-it-works-modal{
|
||||
font-size: 1rem;
|
||||
|
||||
p {
|
||||
display: inline-block !important;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
>
|
||||
{{ $t('filters.clear') }}
|
||||
</x-button>
|
||||
<popup>
|
||||
<popup :has-overflow="true">
|
||||
<template #trigger="{toggle}">
|
||||
<x-button
|
||||
@click.prevent.stop="toggle()"
|
||||
|
|
|
@ -67,49 +67,25 @@
|
|||
<div class="field">
|
||||
<label class="label">{{ $t('task.attributes.dueDate') }}</label>
|
||||
<div class="control">
|
||||
<flat-pickr
|
||||
:config="flatPickerConfig"
|
||||
@on-close="setDueDateFilter"
|
||||
class="input"
|
||||
:placeholder="$t('filters.attributes.dueDateRange')"
|
||||
v-model="filters.dueDate"
|
||||
/>
|
||||
<datepicker-with-range :show-selected-on-button="true" @dateChanged="setDueDateFilter"/>
|
||||
</div>
|
||||
</div>
|
||||
<div class="field">
|
||||
<label class="label">{{ $t('task.attributes.startDate') }}</label>
|
||||
<div class="control">
|
||||
<flat-pickr
|
||||
:config="flatPickerConfig"
|
||||
@on-close="setStartDateFilter"
|
||||
class="input"
|
||||
:placeholder="$t('filters.attributes.startDateRange')"
|
||||
v-model="filters.startDate"
|
||||
/>
|
||||
<datepicker-with-range :show-selected-on-button="true" @dateChanged="setStartDateFilter"/>
|
||||
</div>
|
||||
</div>
|
||||
<div class="field">
|
||||
<label class="label">{{ $t('task.attributes.endDate') }}</label>
|
||||
<div class="control">
|
||||
<flat-pickr
|
||||
:config="flatPickerConfig"
|
||||
@on-close="setEndDateFilter"
|
||||
class="input"
|
||||
:placeholder="$t('filters.attributes.endDateRange')"
|
||||
v-model="filters.endDate"
|
||||
/>
|
||||
<datepicker-with-range :show-selected-on-button="true" @dateChanged="setEndDateFilter"/>
|
||||
</div>
|
||||
</div>
|
||||
<div class="field">
|
||||
<label class="label">{{ $t('task.attributes.reminders') }}</label>
|
||||
<div class="control">
|
||||
<flat-pickr
|
||||
:config="flatPickerConfig"
|
||||
@on-close="setReminderFilter"
|
||||
class="input"
|
||||
:placeholder="$t('filters.attributes.reminderRange')"
|
||||
v-model="filters.reminders"
|
||||
/>
|
||||
<datepicker-with-range :show-selected-on-button="true" @dateChanged="setReminderFilter"/>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
@ -175,15 +151,14 @@
|
|||
</template>
|
||||
|
||||
<script>
|
||||
import DatepickerWithRange from '@/components/date/datepickerWithRange'
|
||||
import Fancycheckbox from '../../input/fancycheckbox'
|
||||
import flatPickr from 'vue-flatpickr-component'
|
||||
import 'flatpickr/dist/flatpickr.css'
|
||||
|
||||
import {includesById} from '@/helpers/utils'
|
||||
import {formatISO} from 'date-fns'
|
||||
import PrioritySelect from '@/components/tasks/partials/prioritySelect.vue'
|
||||
import PercentDoneSelect from '@/components/tasks/partials/percentDoneSelect.vue'
|
||||
import Multiselect from '@/components/input/multiselect.vue'
|
||||
import {parseDateOrString} from '@/helpers/time/parseDateOrString'
|
||||
|
||||
import UserService from '@/services/user'
|
||||
import ListService from '@/services/list'
|
||||
|
@ -222,15 +197,15 @@ const DEFAULT_FILTERS = {
|
|||
namespace: '',
|
||||
}
|
||||
|
||||
export const ALPHABETICAL_SORT = 'title'
|
||||
export const ALPHABETICAL_SORT = 'title'
|
||||
|
||||
export default {
|
||||
name: 'filters',
|
||||
components: {
|
||||
DatepickerWithRange,
|
||||
EditLabels,
|
||||
PrioritySelect,
|
||||
Fancycheckbox,
|
||||
flatPickr,
|
||||
PercentDoneSelect,
|
||||
Multiselect,
|
||||
},
|
||||
|
@ -281,7 +256,7 @@ export default {
|
|||
return this.params?.sort_by?.find(sortBy => sortBy === ALPHABETICAL_SORT) !== undefined
|
||||
},
|
||||
set(sortAlphabetically) {
|
||||
this.params.sort_by = sortAlphabetically
|
||||
this.params.sort_by = sortAlphabetically
|
||||
? [ALPHABETICAL_SORT]
|
||||
: getDefaultParams().sort_by
|
||||
|
||||
|
@ -291,19 +266,6 @@ export default {
|
|||
foundLabels() {
|
||||
return this.$store.getters['labels/filterLabelsByQuery'](this.labels, this.query)
|
||||
},
|
||||
flatPickerConfig() {
|
||||
return {
|
||||
altFormat: this.$t('date.altFormatLong'),
|
||||
altInput: true,
|
||||
dateFormat: 'Y-m-d H:i',
|
||||
enableTime: true,
|
||||
time_24hr: true,
|
||||
mode: 'range',
|
||||
locale: {
|
||||
firstDayOfWeek: this.$store.state.auth.settings.weekStart,
|
||||
},
|
||||
}
|
||||
},
|
||||
},
|
||||
methods: {
|
||||
change() {
|
||||
|
@ -343,19 +305,12 @@ export default {
|
|||
}
|
||||
}
|
||||
},
|
||||
setDateFilter(filterName, variableName = null) {
|
||||
if (variableName === null) {
|
||||
variableName = filterName
|
||||
}
|
||||
setDateFilter(filterName, {dateFrom, dateTo}) {
|
||||
dateFrom = parseDateOrString(dateFrom, null)
|
||||
dateTo = parseDateOrString(dateTo, null)
|
||||
|
||||
// Only filter if we have a start and end due date
|
||||
if (this.filters[variableName] !== '') {
|
||||
|
||||
const parts = this.filters[variableName].split(' to ')
|
||||
|
||||
if (parts.length < 2) {
|
||||
return
|
||||
}
|
||||
// Only filter if we have a date
|
||||
if (dateFrom !== null && dateTo !== null) {
|
||||
|
||||
// Check if we already have values in params and only update them if we do
|
||||
let foundStart = false
|
||||
|
@ -363,23 +318,23 @@ export default {
|
|||
this.params.filter_by.forEach((f, i) => {
|
||||
if (f === filterName && this.params.filter_comparator[i] === 'greater_equals') {
|
||||
foundStart = true
|
||||
this.params.filter_value[i] = formatISO(new Date(parts[0]))
|
||||
this.params.filter_value[i] = dateFrom
|
||||
}
|
||||
if (f === filterName && this.params.filter_comparator[i] === 'less_equals') {
|
||||
foundEnd = true
|
||||
this.params.filter_value[i] = formatISO(new Date(parts[1]))
|
||||
this.params.filter_value[i] = dateTo
|
||||
}
|
||||
})
|
||||
|
||||
if (!foundStart) {
|
||||
this.params.filter_by.push(filterName)
|
||||
this.params.filter_comparator.push('greater_equals')
|
||||
this.params.filter_value.push(formatISO(new Date(parts[0])))
|
||||
this.params.filter_value.push(dateFrom)
|
||||
}
|
||||
if (!foundEnd) {
|
||||
this.params.filter_by.push(filterName)
|
||||
this.params.filter_comparator.push('less_equals')
|
||||
this.params.filter_value.push(formatISO(new Date(parts[1])))
|
||||
this.params.filter_value.push(dateTo)
|
||||
}
|
||||
this.change()
|
||||
return
|
||||
|
@ -513,23 +468,23 @@ export default {
|
|||
this.params.filter_concat = 'or'
|
||||
}
|
||||
},
|
||||
setDueDateFilter() {
|
||||
this.setDateFilter('due_date', 'dueDate')
|
||||
},
|
||||
setPriority() {
|
||||
this.setSingleValueFilter('priority', 'priority', 'usePriority')
|
||||
},
|
||||
setStartDateFilter() {
|
||||
this.setDateFilter('start_date', 'startDate')
|
||||
},
|
||||
setEndDateFilter() {
|
||||
this.setDateFilter('end_date', 'endDate')
|
||||
},
|
||||
setPercentDoneFilter() {
|
||||
this.setSingleValueFilter('percent_done', 'percentDone', 'usePercentDone')
|
||||
},
|
||||
setReminderFilter() {
|
||||
this.setDateFilter('reminders')
|
||||
setDueDateFilter(values) {
|
||||
this.setDateFilter('due_date', values)
|
||||
},
|
||||
setStartDateFilter(values) {
|
||||
this.setDateFilter('start_date', values)
|
||||
},
|
||||
setEndDateFilter(values) {
|
||||
this.setDateFilter('end_date', values)
|
||||
},
|
||||
setReminderFilter(values) {
|
||||
this.setDateFilter('reminders', values)
|
||||
},
|
||||
clear(kind) {
|
||||
this[`found${kind}`] = []
|
||||
|
@ -618,4 +573,8 @@ export default {
|
|||
margin-left: .5rem;
|
||||
}
|
||||
}
|
||||
|
||||
.datepicker-with-range-container .popup {
|
||||
right: 0;
|
||||
}
|
||||
</style>
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
<template>
|
||||
<slot name="trigger" :isOpen="open" :toggle="toggle"></slot>
|
||||
<div class="popup" :class="{'is-open': open}" ref="popup">
|
||||
<div class="popup" :class="{'is-open': open, 'has-overflow': props.hasOverflow}" ref="popup">
|
||||
<slot name="content" :isOpen="open"/>
|
||||
</div>
|
||||
</template>
|
||||
|
@ -16,6 +16,13 @@ const toggle = () => {
|
|||
open.value = !open.value
|
||||
}
|
||||
|
||||
const props = defineProps({
|
||||
hasOverflow: {
|
||||
type: Boolean,
|
||||
default: false,
|
||||
},
|
||||
})
|
||||
|
||||
function hidePopup(e) {
|
||||
if (!open.value) {
|
||||
return
|
||||
|
|
|
@ -192,13 +192,10 @@ export default {
|
|||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
/* Transitions */
|
||||
|
||||
.modal-enter,
|
||||
|
|
|
@ -0,0 +1,12 @@
|
|||
export function parseDateOrString(rawValue: string, fallback: any) {
|
||||
if (typeof rawValue === 'undefined') {
|
||||
return fallback
|
||||
}
|
||||
|
||||
const d = new Date(rawValue)
|
||||
|
||||
// @ts-ignore if rawValue is an invalid date, isNan will return false.
|
||||
return !isNaN(d)
|
||||
? d
|
||||
: rawValue
|
||||
}
|
|
@ -516,6 +516,60 @@
|
|||
"multiselect": {
|
||||
"createPlaceholder": "Create new",
|
||||
"selectPlaceholder": "Click or press enter to select"
|
||||
},
|
||||
"datepickerRange": {
|
||||
"to": "To",
|
||||
"from": "From",
|
||||
"fromto": "{from} to {to}",
|
||||
"math": {
|
||||
"canuse": "You can use date math to filter for relative dates.",
|
||||
"learnhow": "Check out how it works",
|
||||
"title": "Date Math",
|
||||
"intro": "Date Math allows you to specifiy relative dates which are resolved on the fly by Vikunja when applying the filter.",
|
||||
"expression": "Each Date Math expression starts with an anchor date, which can either be {0}, or a date string ending with {1}. This anchor date can optionally be followed by one or more maths expressions.",
|
||||
"similar": "These expressions are similar to the ones provided by {0} and {1}.",
|
||||
"add1Day": "Add one day",
|
||||
"minus1Day": "Subtract one day",
|
||||
"roundDay": "Round down to the nearest day",
|
||||
"supportedUnits": "Supported time units are:",
|
||||
"someExamples": "Some examples of time expressions:",
|
||||
"units": {
|
||||
"seconds": "Seconds",
|
||||
"minutes": "Minutes",
|
||||
"hours": "Hours",
|
||||
"days": "Days",
|
||||
"weeks": "Weeks",
|
||||
"months": "Months",
|
||||
"years": "Years"
|
||||
},
|
||||
"examples": {
|
||||
"now": "Right now",
|
||||
"in24h": "In 24h",
|
||||
"today": "Today at 00:00",
|
||||
"beginningOfThisWeek": "The beginning of this week at 00:00",
|
||||
"endOfThisWeek": "The end of this week",
|
||||
"in30Days": "In 30 days",
|
||||
"datePlusMonth": "{0} plus one month at 00:00 of that day"
|
||||
}
|
||||
},
|
||||
"ranges": {
|
||||
"today": "Today",
|
||||
|
||||
"thisWeek": "This Week",
|
||||
"restOfThisWeek": "The Rest of This Week",
|
||||
"nextWeek": "Next Week",
|
||||
"next7Days": "Next 7 Days",
|
||||
"lastWeek": "Last Week",
|
||||
|
||||
"thisMonth": "This Month",
|
||||
"restOfThisMonth": "The Rest of This Month",
|
||||
"nextMonth": "Next Month",
|
||||
"next30Days": "Next 30 Days",
|
||||
"lastMonth": "Last Month",
|
||||
|
||||
"thisYear": "This Year",
|
||||
"restOfThisYear": "The Rest of This Year"
|
||||
}
|
||||
}
|
||||
},
|
||||
"task": {
|
||||
|
@ -536,13 +590,6 @@
|
|||
"overdue": "Show overdue tasks",
|
||||
"fromuntil": "Tasks from {from} until {until}",
|
||||
"select": "Select a date range",
|
||||
"today": "Today",
|
||||
"thisWeek": "This Week",
|
||||
"nextWeek": "Next Week",
|
||||
"next7Days": "Next 7 Days",
|
||||
"thisMonth": "This Month",
|
||||
"nextMonth": "Next Month",
|
||||
"next30Days": "Next 30 Days",
|
||||
"noTasks": "Nothing to do — Have a nice day!"
|
||||
},
|
||||
"detail": {
|
||||
|
|
|
@ -65,7 +65,7 @@ h6 {
|
|||
}
|
||||
|
||||
.has-overflow {
|
||||
overflow: visible;
|
||||
overflow: visible !important;
|
||||
}
|
||||
|
||||
.has-horizontal-overflow {
|
||||
|
|
|
@ -14,7 +14,7 @@
|
|||
</p>
|
||||
<template v-if="!loading && (!tasks || tasks.length === 0) && showNothingToDo">
|
||||
<h3 class="has-text-centered mt-6">{{ $t('task.show.noTasks') }}</h3>
|
||||
<LlamaCool class="mt-5"/>
|
||||
<LlamaCool class="llama-cool"/>
|
||||
</template>
|
||||
|
||||
<div v-if="!hasTasks" :class="{ 'is-loading': loading}" class="spinner"></div>
|
||||
|
@ -38,7 +38,9 @@
|
|||
</div>
|
||||
</template>
|
||||
<script>
|
||||
import {dateRanges} from '@/components/date/dateRanges'
|
||||
import SingleTaskInList from '@/components/tasks/partials/singleTaskInList'
|
||||
import {parseDateOrString} from '@/helpers/time/parseDateOrString'
|
||||
import {mapState} from 'vuex'
|
||||
|
||||
import Fancycheckbox from '@/components/input/fancycheckbox'
|
||||
|
@ -80,18 +82,10 @@ export default {
|
|||
},
|
||||
computed: {
|
||||
dateFrom() {
|
||||
const d = new Date(Number(this.$route.query.from))
|
||||
|
||||
return !isNaN(d)
|
||||
? d
|
||||
: this.startDate
|
||||
return parseDateOrString(this.$route.query.from, this.startDate)
|
||||
},
|
||||
dateTo() {
|
||||
const d = new Date(Number(this.$route.query.to))
|
||||
|
||||
return !isNaN(d)
|
||||
? d
|
||||
: this.endDate
|
||||
return parseDateOrString(this.$route.query.to, this.endDate)
|
||||
},
|
||||
showNulls() {
|
||||
return this.$route.query.showNulls === 'true'
|
||||
|
@ -100,12 +94,21 @@ export default {
|
|||
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'),
|
||||
})
|
||||
let title = ''
|
||||
|
||||
// We need to define "key" because it is the first parameter in the array and we need the second
|
||||
// eslint-disable-next-line no-unused-vars
|
||||
const predefinedRange = Object.entries(dateRanges).find(([key, value]) => this.dateFrom === value[0] && this.dateTo === value[1])
|
||||
if (typeof predefinedRange !== 'undefined') {
|
||||
title = this.$t(`input.datepickerRange.ranges.${predefinedRange[0]}`)
|
||||
} else {
|
||||
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)
|
||||
|
||||
|
@ -136,8 +139,8 @@ export default {
|
|||
this.$router.push({
|
||||
name: this.$route.name,
|
||||
query: {
|
||||
from: +new Date(dateFrom ?? this.dateFrom),
|
||||
to: +new Date(dateTo ?? this.dateTo),
|
||||
from: dateFrom ?? this.dateFrom,
|
||||
to: dateTo ?? this.dateTo,
|
||||
showOverdue: this.showOverdue,
|
||||
showNulls: this.showNulls,
|
||||
},
|
||||
|
@ -183,7 +186,7 @@ export default {
|
|||
params.filter_by.push('due_date')
|
||||
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'.
|
||||
|
||||
|
@ -224,4 +227,9 @@ export default {
|
|||
margin-right: .5rem;
|
||||
}
|
||||
}
|
||||
|
||||
.llama-cool {
|
||||
margin: 3rem auto 0;
|
||||
display: block;
|
||||
}
|
||||
</style>
|
Reference in New Issue