feat: add prop to maybe show selected date

This commit is contained in:
kolaente 2022-01-09 17:03:08 +01:00
parent a74fc47335
commit 3a12be505d
Signed by: konrad
GPG Key ID: F40E70337AB24C9B
2 changed files with 21 additions and 2 deletions

View File

@ -3,8 +3,8 @@
<popup>
<template #trigger="{toggle}">
<slot name="trigger" :toggle="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>
</slot>
</template>
@ -187,6 +187,13 @@ 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(() => ({
@ -259,6 +266,17 @@ function setDateRange(range: string[] | null) {
const customRangeActive = computed<Boolean>(() => {
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>
<style lang="scss" scoped>

View File

@ -526,6 +526,7 @@
"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",