1
0

feat: add more pre-defined ranges

This commit is contained in:
kolaente
2022-01-09 16:46:12 +01:00
parent e7fa1d3383
commit 0ae8a0e6ef
4 changed files with 43 additions and 20 deletions

View File

@ -1,10 +1,21 @@
// TODO: more ranges!
export const dateRanges = {
'task.show.today': ['now/d', 'now/d+1d'],
'task.show.thisWeek': ['now/w', 'now/w+1w'],
'task.show.nextWeek': ['now/w+1w', 'now/w+2w'],
'task.show.next7Days': ['now', 'now+7d'],
'task.show.thisMonth': ['now/M', 'now/M+1M'],
'task.show.nextMonth': ['now/M+1M', 'now/M+2M'],
'task.show.next30Days': ['now', 'now+30d'],
// 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'],
}

View File

@ -11,15 +11,15 @@
<template #content="{isOpen}">
<div class="datepicker-with-range" :class="{'is-open': isOpen}">
<div class="selections">
<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(text) }}
</button>
<button @click="setDateRange(null)" :class="{'is-active': customRangeActive}">
{{ $t('misc.custom') }}
{{ $t(`input.datepickerRange.ranges.${text}`) }}
</button>
</div>
<div class="flatpickr-container input-group">
@ -324,6 +324,7 @@ const customRangeActive = computed<Boolean>(() => {
display: flex;
flex-direction: column;
padding-top: .5rem;
overflow-y: scroll;
button {
display: block;