feat: add prop to maybe show selected date

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

View File

@ -2,8 +2,8 @@
<div class="datepicker-with-range-container">
<popup>
<template #trigger="{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>
</template>
<template #content="{isOpen}">
@ -185,6 +185,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(() => ({
@ -257,6 +264,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

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