chore: use flatpickr range instead of two datepickers

This commit is contained in:
kolaente 2022-07-20 19:00:15 +02:00
parent ef4689335b
commit c289a6ae18
Signed by untrusted user: konrad
GPG Key ID: F40E70337AB24C9B
2 changed files with 13 additions and 20 deletions

View File

@ -287,8 +287,7 @@
"month": "Month", "month": "Month",
"day": "Day", "day": "Day",
"hour": "Hour", "hour": "Hour",
"from": "From", "range": "Range",
"to": "To",
"noDates": "This task has no dates set." "noDates": "This task has no dates set."
}, },
"table": { "table": {

View File

@ -16,26 +16,14 @@
</div> </div>
</div> </div>
<div class="field"> <div class="field">
<label class="label" for="fromDate">{{ $t('list.gantt.from') }}</label> <label class="label" for="range">{{ $t('list.gantt.range') }}</label>
<div class="control"> <div class="control">
<flat-pickr <flat-pickr
:config="flatPickerConfig" :config="flatPickerConfig"
class="input" class="input"
id="fromDate" id="range"
:placeholder="$t('list.gantt.from')" :placeholder="$t('list.gantt.range')"
v-model="dateFrom" v-model="range"
/>
</div>
</div>
<div class="field">
<label class="label" for="toDate">{{ $t('list.gantt.to') }}</label>
<div class="control">
<flat-pickr
:config="flatPickerConfig"
class="input"
id="toDate"
:placeholder="$t('list.gantt.to')"
v-model="dateTo"
/> />
</div> </div>
</div> </div>
@ -87,8 +75,13 @@ const showTaskswithoutDates = ref(false)
const precision = ref('day') const precision = ref('day')
const now = ref(new Date()) const now = ref(new Date())
const dateFrom = ref(format(new Date((new Date()).setDate(now.value.getDate() - 15)), 'yyyy-LL-dd')) const defaultFrom = format(new Date((new Date()).setDate(now.value.getDate() - 15)), 'yyyy-LL-dd')
const dateTo = ref(format(new Date((new Date()).setDate(now.value.getDate() + 30)), 'yyyy-LL-dd')) const defaultTo = format(new Date((new Date()).setDate(now.value.getDate() + 30)), 'yyyy-LL-dd')
const range = ref(`${defaultFrom} to ${defaultTo}`)
// TODO: only update once both dates are available (maybe use a watcher + refs instead?)
const dateFrom = computed(() => range.value?.split(' to ')[0] ?? defaultFrom)
const dateTo = computed(() => range.value?.split(' to ')[1] ?? defaultTo)
const {t} = useI18n({useScope: 'global'}) const {t} = useI18n({useScope: 'global'})
const authStore = useAuthStore() const authStore = useAuthStore()
@ -97,6 +90,7 @@ const flatPickerConfig = computed(() => ({
altInput: true, altInput: true,
dateFormat: 'Y-m-d', dateFormat: 'Y-m-d',
enableTime: false, enableTime: false,
mode: 'range',
locale: { locale: {
firstDayOfWeek: authStore.settings.weekStart, firstDayOfWeek: authStore.settings.weekStart,
}, },