From 3a12be505d9c28f987eb81b9436d4bbb9cb3eaaf Mon Sep 17 00:00:00 2001 From: kolaente Date: Sun, 9 Jan 2022 17:03:08 +0100 Subject: [PATCH] feat: add prop to maybe show selected date --- src/components/date/datepickerWithRange.vue | 22 +++++++++++++++++++-- src/i18n/lang/en.json | 1 + 2 files changed, 21 insertions(+), 2 deletions(-) diff --git a/src/components/date/datepickerWithRange.vue b/src/components/date/datepickerWithRange.vue index 67aac3257..d06cd2e2a 100644 --- a/src/components/date/datepickerWithRange.vue +++ b/src/components/date/datepickerWithRange.vue @@ -3,8 +3,8 @@ @@ -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(() => store.state.auth.settings.weekStart ?? 0) const flatPickerConfig = computed(() => ({ @@ -259,6 +266,17 @@ function setDateRange(range: string[] | null) { const customRangeActive = computed(() => { return !Object.values(dateRanges).some(el => from.value === el[0] && to.value === el[1]) }) + +const buttonText = computed(() => { + if(props.showSelectedOnButton && from.value !== '' && to.value !== '') { + return t('input.datepickerRange.fromto', { + from: from.value, + to: to.value, + }) + } + + return t('task.show.select') +})