Added option menu for calendar
This commit is contained in:
@@ -2,6 +2,7 @@
|
|||||||
import { useCalendar } from "@/stores/CalendarStore"
|
import { useCalendar } from "@/stores/CalendarStore"
|
||||||
|
|
||||||
import { PhMagnifyingGlass } from "@phosphor-icons/vue"
|
import { PhMagnifyingGlass } from "@phosphor-icons/vue"
|
||||||
|
import CalendarOptions from "./CalendarOptions.vue"
|
||||||
|
|
||||||
const { revealAdvancedSearch } = useCalendar()
|
const { revealAdvancedSearch } = useCalendar()
|
||||||
const { isReadOnly } = storeToRefs(useCalendar())
|
const { isReadOnly } = storeToRefs(useCalendar())
|
||||||
@@ -26,13 +27,13 @@ const { isReadOnly } = storeToRefs(useCalendar())
|
|||||||
<li>
|
<li>
|
||||||
<UiButton search-slash @click="revealAdvancedSearch()">
|
<UiButton search-slash @click="revealAdvancedSearch()">
|
||||||
<PhMagnifyingGlass size="20" weight="light" />
|
<PhMagnifyingGlass size="20" weight="light" />
|
||||||
{{ $t('entity.advancedSearch.title') }}
|
<span>
|
||||||
|
{{ $t('entity.advancedSearch.title') }}
|
||||||
|
</span>
|
||||||
</UiButton>
|
</UiButton>
|
||||||
</li>
|
</li>
|
||||||
<li>
|
<li>
|
||||||
<ClientOnly>
|
<CalendarOptions />
|
||||||
<CalendarSwitch />
|
|
||||||
</ClientOnly>
|
|
||||||
</li>
|
</li>
|
||||||
</menu>
|
</menu>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
57
components/calendar/CalendarOptions.vue
Normal file
57
components/calendar/CalendarOptions.vue
Normal file
@@ -0,0 +1,57 @@
|
|||||||
|
<script setup lang="ts">
|
||||||
|
import { cn } from "@/lib/utils"
|
||||||
|
import { useCalendar } from "@/stores/CalendarStore"
|
||||||
|
import { PhCalendarBlank, PhCheckCircle, PhGear, PhTag } from "@phosphor-icons/vue"
|
||||||
|
import { computed } from "vue"
|
||||||
|
|
||||||
|
const { currentConfig, viewTypeOptions, getViewTypeTitle, setViewType } = useCalendar()
|
||||||
|
|
||||||
|
const viewTypeTitle = computed(() => getViewTypeTitle(currentConfig.viewType))
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<template>
|
||||||
|
<UiDropdownMenu>
|
||||||
|
<UiDropdownMenuTrigger as-child>
|
||||||
|
<UiButton variant="secondary" size="icon">
|
||||||
|
<PhGear size="20" weight="fill" />
|
||||||
|
</UiButton>
|
||||||
|
</UiDropdownMenuTrigger>
|
||||||
|
<UiDropdownMenuContent :side="'bottom'" :align="'start'" :side-offset="10" :align-offset="25" :collision-padding="40" class="text-right">
|
||||||
|
<UiDropdownMenuLabel>
|
||||||
|
{{ $t('entity.calendar.seeOptions') }}
|
||||||
|
</UiDropdownMenuLabel>
|
||||||
|
<UiDropdownMenuSub>
|
||||||
|
<UiDropdownMenuSubTrigger arrow-direction="left" class="p-0 rounded-none">
|
||||||
|
<UiDropdownMenuItem class="flex gap-[1ch] justify-end items-center pointer-events-none">
|
||||||
|
{{ $t('ui.displayMode') }}
|
||||||
|
|
||||||
|
<PhCalendarBlank size="18" weight="fill" />
|
||||||
|
</UiDropdownMenuItem>
|
||||||
|
</UiDropdownMenuSubTrigger>
|
||||||
|
<UiDropdownMenuPortal>
|
||||||
|
<UiDropdownMenuSubContent>
|
||||||
|
<UiDropdownMenuItem
|
||||||
|
v-for="option in viewTypeOptions"
|
||||||
|
:key="option"
|
||||||
|
class="flex gap-[.5ch] items-center rounded-none transition-colors"
|
||||||
|
:class="cn({ 'text-emerald-600': viewTypeTitle === getViewTypeTitle(option) })"
|
||||||
|
@click="setViewType(option)"
|
||||||
|
>
|
||||||
|
<PhCheckCircle v-if="viewTypeTitle === getViewTypeTitle(option)" size="20" weight="fill" />
|
||||||
|
|
||||||
|
{{ getViewTypeTitle(option) }}
|
||||||
|
</UiDropdownMenuItem>
|
||||||
|
</UiDropdownMenuSubContent>
|
||||||
|
</UiDropdownMenuPortal>
|
||||||
|
</UiDropdownMenuSub>
|
||||||
|
|
||||||
|
<UiDropdownMenuSeparator />
|
||||||
|
|
||||||
|
<UiDropdownMenuItem class="flex gap-[1ch] justify-end items-center">
|
||||||
|
{{ $t('entity.category.namePlural') }}
|
||||||
|
|
||||||
|
<PhTag size="18" weight="fill" />
|
||||||
|
</UiDropdownMenuItem>
|
||||||
|
</UiDropdownMenuContent>
|
||||||
|
</UiDropdownMenu>
|
||||||
|
</template>
|
||||||
@@ -1,34 +0,0 @@
|
|||||||
<script setup lang="ts">
|
|
||||||
import { useCalendar } from "@/stores/CalendarStore"
|
|
||||||
import { PhCalendarBlank } from "@phosphor-icons/vue"
|
|
||||||
import { computed } from "vue"
|
|
||||||
|
|
||||||
const { currentConfig, viewTypeOptions, getViewTypeTitle, setViewType } = useCalendar()
|
|
||||||
|
|
||||||
const viewTypeTitle = computed(() => getViewTypeTitle(currentConfig.viewType))
|
|
||||||
</script>
|
|
||||||
|
|
||||||
<template>
|
|
||||||
<UiDropdownMenu>
|
|
||||||
<UiDropdownMenuTrigger as-child>
|
|
||||||
<UiButton size="sm" variant="secondary">
|
|
||||||
<PhCalendarBlank size="18" weight="fill" />
|
|
||||||
|
|
||||||
{{ viewTypeTitle }}
|
|
||||||
</UiButton>
|
|
||||||
</UiDropdownMenuTrigger>
|
|
||||||
<UiDropdownMenuContent :side="'bottom'" :collision-padding="30">
|
|
||||||
<UiDropdownMenuLabel>
|
|
||||||
{{ $t('ui.displayMode') }}
|
|
||||||
</UiDropdownMenuLabel>
|
|
||||||
<UiDropdownMenuSeparator />
|
|
||||||
<UiDropdownMenuItem
|
|
||||||
v-for="option in viewTypeOptions"
|
|
||||||
:key="option"
|
|
||||||
@click="setViewType(option)"
|
|
||||||
>
|
|
||||||
{{ getViewTypeTitle(option) }}
|
|
||||||
</UiDropdownMenuItem>
|
|
||||||
</UiDropdownMenuContent>
|
|
||||||
</UiDropdownMenu>
|
|
||||||
</template>
|
|
||||||
@@ -5,10 +5,10 @@ import {
|
|||||||
type DropdownMenuSubTriggerProps,
|
type DropdownMenuSubTriggerProps,
|
||||||
useForwardProps
|
useForwardProps
|
||||||
} from "radix-vue"
|
} from "radix-vue"
|
||||||
import { ChevronRight } from "lucide-vue-next"
|
|
||||||
import { cn } from "@/lib/utils"
|
import { cn } from "@/lib/utils"
|
||||||
|
import { PhCaretLeft, PhCaretRight } from "@phosphor-icons/vue";
|
||||||
|
|
||||||
const props = defineProps<DropdownMenuSubTriggerProps & { class?: HTMLAttributes["class"] }>()
|
const props = defineProps<DropdownMenuSubTriggerProps & { class?: HTMLAttributes["class"], arrowDirection?: "left" | "right" }>()
|
||||||
|
|
||||||
const delegatedProps = computed(() => {
|
const delegatedProps = computed(() => {
|
||||||
const { class: _, ...delegated } = props
|
const { class: _, ...delegated } = props
|
||||||
@@ -29,7 +29,17 @@ const forwardedProps = useForwardProps(delegatedProps)
|
|||||||
)
|
)
|
||||||
"
|
"
|
||||||
>
|
>
|
||||||
<slot />
|
<template v-if="props.arrowDirection === 'left'">
|
||||||
<ChevronRight class="ml-auto h-4 w-4" />
|
<PhCaretLeft class="mr-auto h-4 w-4" />
|
||||||
|
|
||||||
|
<span class="inline-block">
|
||||||
|
<slot />
|
||||||
|
</span>
|
||||||
|
</template>
|
||||||
|
<template v-else>
|
||||||
|
<slot />
|
||||||
|
|
||||||
|
<PhCaretRight class="ml-auto h-4 w-4" />
|
||||||
|
</template>
|
||||||
</DropdownMenuSubTrigger>
|
</DropdownMenuSubTrigger>
|
||||||
</template>
|
</template>
|
||||||
|
|||||||
@@ -79,7 +79,7 @@ export default defineI18nConfig(() => ({
|
|||||||
dark: "Dark",
|
dark: "Dark",
|
||||||
light: "Light",
|
light: "Light",
|
||||||
system: "System",
|
system: "System",
|
||||||
displayMode: "Display mode"
|
displayMode: "Display"
|
||||||
},
|
},
|
||||||
common: {
|
common: {
|
||||||
title: "Title",
|
title: "Title",
|
||||||
@@ -148,6 +148,7 @@ export default defineI18nConfig(() => ({
|
|||||||
backToList: "Go back to calendars",
|
backToList: "Go back to calendars",
|
||||||
isLoading: "Calendar is loading…",
|
isLoading: "Calendar is loading…",
|
||||||
hasXEvents: "{count} available events",
|
hasXEvents: "{count} available events",
|
||||||
|
seeOptions: "Calendar options",
|
||||||
date: {
|
date: {
|
||||||
start: "Start date",
|
start: "Start date",
|
||||||
end: "End date",
|
end: "End date",
|
||||||
@@ -242,26 +243,31 @@ export default defineI18nConfig(() => ({
|
|||||||
},
|
},
|
||||||
millennia: {
|
millennia: {
|
||||||
nameSingular: "Millennia",
|
nameSingular: "Millennia",
|
||||||
|
displayMode: "Millennial",
|
||||||
nextSingular: "Next millennia",
|
nextSingular: "Next millennia",
|
||||||
prevSingular: "Last millennia",
|
prevSingular: "Last millennia",
|
||||||
},
|
},
|
||||||
centuries: {
|
centuries: {
|
||||||
nameSingular: "Century",
|
nameSingular: "Century",
|
||||||
|
displayMode: "Centuries",
|
||||||
nextSingular: "Next century",
|
nextSingular: "Next century",
|
||||||
prevSingular: "Last century",
|
prevSingular: "Last century",
|
||||||
},
|
},
|
||||||
decades: {
|
decades: {
|
||||||
nameSingular: "Decade",
|
nameSingular: "Decade",
|
||||||
|
displayMode: "Decadal",
|
||||||
nextSingular: "Next decade",
|
nextSingular: "Next decade",
|
||||||
prevSingular: "Last decade",
|
prevSingular: "Last decade",
|
||||||
},
|
},
|
||||||
years: {
|
years: {
|
||||||
nameSingular: "Year",
|
nameSingular: "Year",
|
||||||
|
displayMode: "Yearly",
|
||||||
nextSingular: "Next year",
|
nextSingular: "Next year",
|
||||||
prevSingular: "Last year",
|
prevSingular: "Last year",
|
||||||
},
|
},
|
||||||
months: {
|
months: {
|
||||||
nameSingular: "Month",
|
nameSingular: "Month",
|
||||||
|
displayMode: "Monthly",
|
||||||
nextSingular: "Next month",
|
nextSingular: "Next month",
|
||||||
prevSingular: "Last month",
|
prevSingular: "Last month",
|
||||||
inputName: "Month's name",
|
inputName: "Month's name",
|
||||||
@@ -375,7 +381,7 @@ export default defineI18nConfig(() => ({
|
|||||||
dark: "Sombre",
|
dark: "Sombre",
|
||||||
light: "Clair",
|
light: "Clair",
|
||||||
system: "Système",
|
system: "Système",
|
||||||
displayMode: "Mode d'affichage",
|
displayMode: "Affichage",
|
||||||
},
|
},
|
||||||
common: {
|
common: {
|
||||||
title: "Titre",
|
title: "Titre",
|
||||||
@@ -444,6 +450,7 @@ export default defineI18nConfig(() => ({
|
|||||||
backToList: "Retourner aux calendriers",
|
backToList: "Retourner aux calendriers",
|
||||||
isLoading: "Chargement du calendrier…",
|
isLoading: "Chargement du calendrier…",
|
||||||
hasXEvents: "{count} évènements disponibles",
|
hasXEvents: "{count} évènements disponibles",
|
||||||
|
seeOptions: "Options du calendrier",
|
||||||
date: {
|
date: {
|
||||||
start: "Date de début",
|
start: "Date de début",
|
||||||
end: "Date de fin",
|
end: "Date de fin",
|
||||||
@@ -541,26 +548,31 @@ export default defineI18nConfig(() => ({
|
|||||||
},
|
},
|
||||||
millennia: {
|
millennia: {
|
||||||
nameSingular: "Millénaire",
|
nameSingular: "Millénaire",
|
||||||
|
displayMode: "Par millénaire",
|
||||||
nextSingular: "Millénaire suivant",
|
nextSingular: "Millénaire suivant",
|
||||||
prevSingular: "Millénaire précédent",
|
prevSingular: "Millénaire précédent",
|
||||||
},
|
},
|
||||||
centuries: {
|
centuries: {
|
||||||
nameSingular: "Siècle",
|
nameSingular: "Siècle",
|
||||||
|
displayMode: "Par siècle",
|
||||||
nextSingular: "Siècle suivant",
|
nextSingular: "Siècle suivant",
|
||||||
prevSingular: "Siècle précédent",
|
prevSingular: "Siècle précédent",
|
||||||
},
|
},
|
||||||
decades: {
|
decades: {
|
||||||
nameSingular: "Décennie",
|
nameSingular: "Décennie",
|
||||||
|
displayMode: "Par décennie",
|
||||||
nextSingular: "Décennie suivante",
|
nextSingular: "Décennie suivante",
|
||||||
prevSingular: "Décennie précédente",
|
prevSingular: "Décennie précédente",
|
||||||
},
|
},
|
||||||
years: {
|
years: {
|
||||||
nameSingular: "Année",
|
nameSingular: "Année",
|
||||||
|
displayMode: "Annuel",
|
||||||
nextSingular: "Année suivante",
|
nextSingular: "Année suivante",
|
||||||
prevSingular: "Année précédente",
|
prevSingular: "Année précédente",
|
||||||
},
|
},
|
||||||
months: {
|
months: {
|
||||||
nameSingular: "Mois",
|
nameSingular: "Mois",
|
||||||
|
displayMode: "Mensuel",
|
||||||
nextSingular: "Mois suivant",
|
nextSingular: "Mois suivant",
|
||||||
prevSingular: "Mois précédent",
|
prevSingular: "Mois précédent",
|
||||||
inputName: "Nom du mois",
|
inputName: "Nom du mois",
|
||||||
|
|||||||
@@ -345,17 +345,17 @@ export const useCalendar = defineStore("calendar", () => {
|
|||||||
function getViewTypeTitle(viewType: CalendarViewType): string {
|
function getViewTypeTitle(viewType: CalendarViewType): string {
|
||||||
switch (viewType) {
|
switch (viewType) {
|
||||||
case "year":
|
case "year":
|
||||||
return t("entity.calendar.years.nameSingular")
|
return t("entity.calendar.years.displayMode")
|
||||||
|
|
||||||
case "decade":
|
case "decade":
|
||||||
return "Décennie"
|
return t("entity.calendar.decades.displayMode")
|
||||||
|
|
||||||
case "century":
|
case "century":
|
||||||
return "Siècle"
|
return t("entity.calendar.centuries.displayMode")
|
||||||
|
|
||||||
case "month":
|
case "month":
|
||||||
default:
|
default:
|
||||||
return t("entity.calendar.months.nameSingular")
|
return t("entity.calendar.months.displayMode")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user