From e7fa1d3383d19daca68c30ee431059f3d47f2589 Mon Sep 17 00:00:00 2001 From: kolaente Date: Sun, 9 Jan 2022 16:31:17 +0100 Subject: [PATCH] feat: add explanation of how date math works --- src/components/date/datepickerWithRange.vue | 128 ++++++++++++++++++++ src/components/modal/modal.vue | 1 - src/i18n/lang/en.json | 33 ++++- 3 files changed, 160 insertions(+), 2 deletions(-) diff --git a/src/components/date/datepickerWithRange.vue b/src/components/date/datepickerWithRange.vue index b6cb9a51..e2bb15b5 100644 --- a/src/components/date/datepickerWithRange.vue +++ b/src/components/date/datepickerWithRange.vue @@ -49,6 +49,122 @@ :config="flatPickerConfig" v-model="flatpickrRange" /> + +

+ {{ $t('input.datepickerRange.math.canuse') }} + {{ $t('input.datepickerRange.math.learnhow') }}. +

+ + + +

+ {{ $t('input.datepickerRange.math.intro') }} +

+

+ + now + || + +

+

+ + + Grafana + + + Elasticsearch + + +

+

{{ $t('misc.forExample') }}

+
    +
  • +1d{{ $t('input.datepickerRange.math.add1Day') }}
  • +
  • -1d{{ $t('input.datepickerRange.math.minus1Day') }}
  • +
  • /d{{ $t('input.datepickerRange.math.roundDay') }}
  • +
+

{{ $t('input.datepickerRange.math.supportedUnits') }}

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
s{{ $t('input.datepickerRange.math.units.seconds') }}
m{{ $t('input.datepickerRange.math.units.minutes') }}
h{{ $t('input.datepickerRange.math.units.hours') }}
H{{ $t('input.datepickerRange.math.units.hours') }}
d{{ $t('input.datepickerRange.math.units.days') }}
w{{ $t('input.datepickerRange.math.units.weeks') }}
M{{ $t('input.datepickerRange.math.units.months') }}
y{{ $t('input.datepickerRange.math.units.years') }}
+ +

{{ $t('input.datepickerRange.math.someExamples') }}

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
now{{ $t('input.datepickerRange.math.examples.now') }}
now+24h{{ $t('input.datepickerRange.math.examples.in24h') }}
now/d{{ $t('input.datepickerRange.math.examples.today') }}
now/w{{ $t('input.datepickerRange.math.examples.beginningOfThisWeek') }}
now/w+1w{{ $t('input.datepickerRange.math.examples.endOfThisWeek') }}
now+30d{{ $t('input.datepickerRange.math.examples.in30Days') }}
{{ exampleDate }}||+1M/d + + {{ exampleDate }} + +
+
+
@@ -62,6 +178,7 @@ import 'flatpickr/dist/flatpickr.css' 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.vue' import {dateRanges} from '@/components/date/dateRanges' @@ -84,6 +201,9 @@ const flatPickerConfig = computed(() => ({ }, })) +const showHowItWorks = ref(false) +const exampleDate = format(new Date(), 'yyyy-MM-dd') + const flatpickrRange = ref('') const from = ref('') @@ -226,4 +346,12 @@ const customRangeActive = computed(() => { } } } + +.how-it-works-modal{ + font-size: 1rem; + + p { + display: inline-block !important; + } +} diff --git a/src/components/modal/modal.vue b/src/components/modal/modal.vue index c231df67..b049f1b5 100644 --- a/src/components/modal/modal.vue +++ b/src/components/modal/modal.vue @@ -207,7 +207,6 @@ export default { display: flex; justify-content: space-between; align-items: center; - } } } diff --git a/src/i18n/lang/en.json b/src/i18n/lang/en.json index 83dadcc9..47c5f641 100644 --- a/src/i18n/lang/en.json +++ b/src/i18n/lang/en.json @@ -525,7 +525,38 @@ }, "datepickerRange": { "to": "To", - "from": "From" + "from": "From", + "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" + } + } } }, "task": {