1
0

feat(filters): add date values

This commit is contained in:
kolaente
2024-02-17 17:57:50 +01:00
parent c22daab28c
commit 992d108bfa
3 changed files with 56 additions and 6 deletions

View File

@ -19,3 +19,28 @@ export const DATE_RANGES = {
'thisYear': ['now/y', 'now/y+1y'],
'restOfThisYear': ['now', 'now/y+1y'],
}
export const DATE_VALUES = {
'now': 'now',
'startOfToday': 'now/d',
'endOfToday': 'now/d+1d',
'beginningOflastWeek': 'now/w-1w',
'endOfLastWeek': 'now/w-2w',
'beginningOfThisWeek': 'now/w',
'endOfThisWeek': 'now/w+1w',
'startOfNextWeek': 'now/w+1w',
'endOfNextWeek': 'now/w+2w',
'in7Days': 'now+7d',
'beginningOfLastMonth': 'now/M-1M',
'endOfLastMonth': 'now/M-2M',
'startOfThisMonth': 'now/M',
'endOfThisMonth': 'now/M+1M',
'startOfNextMonth': 'now/M+1M',
'endOfNextMonth': 'now/M+2M',
'in30Days': 'now+30d',
'startOfThisYear': 'now/y',
'endOfThisYear': 'now/y+1y',
}

View File

@ -17,12 +17,12 @@
{{ $t('misc.custom') }}
</BaseButton>
<BaseButton
v-for="(value, text) in DATE_RANGES"
v-for="(value, text) in DATE_VALUES"
:key="text"
:class="{'is-active': date === value[0]}"
@click="setDate(value[0])"
:class="{'is-active': date === value}"
@click="setDate(value)"
>
{{ $t(`input.datepickerRange.ranges.${text}`) }}
{{ $t(`input.datepickerRange.values.${text}`) }}
</BaseButton>
</div>
<div class="flatpickr-container input-group">
@ -86,7 +86,7 @@ import 'flatpickr/dist/flatpickr.css'
import {parseDateOrString} from '@/helpers/time/parseDateOrString'
import Popup from '@/components/misc/popup.vue'
import {DATE_RANGES} from '@/components/date/dateRanges'
import {DATE_VALUES} from '@/components/date/dateRanges'
import BaseButton from '@/components/base/BaseButton.vue'
import DatemathHelp from '@/components/date/datemathHelp.vue'
import {getFlatpickrLanguage} from '@/helpers/flatpickrLanguage'
@ -162,7 +162,7 @@ function setDate(range: string | null) {
}
const customRangeActive = computed<boolean>(() => {
return !Object.values(DATE_RANGES).some(d => date.value === d)
return !Object.values(DATE_VALUES).some(d => date.value === d)
})
</script>