Today menu is disabled only if current screen is not the default one
This commit is contained in:
@@ -1,20 +1,20 @@
|
|||||||
<script lang="ts" setup>
|
<script lang="ts" setup>
|
||||||
import { storeToRefs } from "pinia"
|
|
||||||
import { computed } from "vue"
|
import { computed } from "vue"
|
||||||
|
|
||||||
const { defaultDate, areDatesIdentical, jumpToDefaultDate, getFormattedDateTitle } = useCalendar()
|
const { defaultDate, jumpToDefaultDate, getFormattedDateTitle, currentDate } = useCalendar()
|
||||||
const { selectedDate } = storeToRefs(useCalendar())
|
|
||||||
|
|
||||||
const defaultDateFormatted: string = getFormattedDateTitle(defaultDate, true)
|
const defaultDateFormatted: string = getFormattedDateTitle(defaultDate, true)
|
||||||
|
|
||||||
const isDefaultDate: ComputedRef<boolean> = computed<boolean>(() => areDatesIdentical(selectedDate.value, defaultDate))
|
const buttonDisabledState: ComputedRef<boolean> = computed<boolean>(() => {
|
||||||
|
return currentDate.currentMonth === defaultDate.month && currentDate.currentYear === defaultDate.year
|
||||||
|
})
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
<UiTooltipProvider :delay-duration="250">
|
<UiTooltipProvider :delay-duration="250">
|
||||||
<UiTooltip>
|
<UiTooltip>
|
||||||
<UiTooltipTrigger as-child>
|
<UiTooltipTrigger as-child>
|
||||||
<UiButton size="sm" :disabled="isDefaultDate" @click="jumpToDefaultDate">
|
<UiButton size="sm" :disabled="buttonDisabledState" @click="jumpToDefaultDate">
|
||||||
{{ $t('entity.calendar.date.today') }}
|
{{ $t('entity.calendar.date.today') }}
|
||||||
</UiButton>
|
</UiButton>
|
||||||
</UiTooltipTrigger>
|
</UiTooltipTrigger>
|
||||||
|
|||||||
Reference in New Issue
Block a user