RTL fixes for event dialog

This commit is contained in:
Leo Vasanko 2025-08-26 10:52:47 -06:00
parent 3e8cdf1b75
commit 090e564bb0
4 changed files with 34 additions and 38 deletions

View File

@ -1,12 +1,10 @@
<script setup> <script setup>
import { ref, onMounted, onBeforeUnmount, watch } from 'vue' import { ref, onMounted, onBeforeUnmount, watch } from 'vue'
import CalendarView from './components/CalendarView.vue' import CalendarView from './components/CalendarView.vue'
import EventDialog from './components/EventDialog.vue'
import { useCalendarStore } from './stores/CalendarStore' import { useCalendarStore } from './stores/CalendarStore'
import { lang } from './utils/locale' import { lang } from './utils/locale'
import { formatTodayString } from './utils/date' import { formatTodayString } from './utils/date'
const eventDialog = ref(null)
const calendarStore = useCalendarStore() const calendarStore = useCalendarStore()
// Initialize holidays when app starts // Initialize holidays when app starts
@ -47,24 +45,6 @@ onBeforeUnmount(() => {
document.removeEventListener('keydown', handleGlobalKey) document.removeEventListener('keydown', handleGlobalKey)
}) })
const handleCreateEvent = (eventData) => {
if (eventDialog.value) {
const selectionData = {
startDate: eventData.startDate,
dayCount: eventData.dayCount,
}
setTimeout(() => eventDialog.value.openCreateDialog(selectionData), 50)
}
}
const handleEditEvent = (eventClickPayload) => {
if (eventDialog.value) {
eventDialog.value.openEditDialog(eventClickPayload)
}
}
const handleClearSelection = () => {}
// Watch today's date to update document title // Watch today's date to update document title
watch( watch(
() => calendarStore.now, () => calendarStore.now,
@ -76,12 +56,7 @@ watch(
</script> </script>
<template> <template>
<CalendarView @create-event="handleCreateEvent" @edit-event="handleEditEvent" /> <CalendarView />
<EventDialog
ref="eventDialog"
:selection="{ startDate: null, dayCount: 0 }"
@clear-selection="handleClearSelection"
/>
</template> </template>
<style scoped></style> <style scoped></style>

View File

@ -14,9 +14,20 @@ import { toLocalString, fromLocalString, DEFAULT_TZ } from '@/utils/date'
import { addDays, differenceInWeeks } from 'date-fns' import { addDays, differenceInWeeks } from 'date-fns'
import { createVirtualWeekManager } from '@/plugins/virtualWeeks' import { createVirtualWeekManager } from '@/plugins/virtualWeeks'
import { rtl } from '@/utils/locale' import { rtl } from '@/utils/locale'
import EventDialog from '@/components/EventDialog.vue'
const calendarStore = useCalendarStore() const calendarStore = useCalendarStore()
const emit = defineEmits(['create-event', 'edit-event']) defineEmits([]) // previously emitted create/edit events externally
import { shallowRef } from 'vue'
const eventDialogRef = shallowRef(null)
function openCreateEventDialog(eventData) {
if (!eventDialogRef.value) return
const selectionData = { startDate: eventData.startDate, dayCount: eventData.dayCount }
setTimeout(() => eventDialogRef.value?.openCreateDialog(selectionData), 30)
}
function openEditEventDialog(eventClickPayload) {
eventDialogRef.value?.openEditDialog(eventClickPayload)
}
const viewport = ref(null) const viewport = ref(null)
const viewportHeight = ref(600) const viewportHeight = ref(600)
const rowHeight = ref(64) const rowHeight = ref(64)
@ -207,7 +218,7 @@ function finalizeDragAndCreate() {
const eventData = createEventFromSelection() const eventData = createEventFromSelection()
if (eventData) { if (eventData) {
clearSelection() clearSelection()
emit('create-event', eventData) openCreateEventDialog(eventData)
} }
removeGlobalTouchListeners() removeGlobalTouchListeners()
} }
@ -373,7 +384,7 @@ const handleDayMouseUp = (d) => {
const ev = createEventFromSelection() const ev = createEventFromSelection()
if (ev) { if (ev) {
clearSelection() clearSelection()
emit('create-event', ev) openCreateEventDialog(ev)
} }
} }
const handleDayTouchStart = (d) => { const handleDayTouchStart = (d) => {
@ -383,7 +394,7 @@ const handleDayTouchStart = (d) => {
} }
const handleEventClick = (payload) => { const handleEventClick = (payload) => {
emit('edit-event', payload) openEditEventDialog(payload)
} }
// Heuristic: rotate month label (180deg) only for predominantly Latin text. // Heuristic: rotate month label (180deg) only for predominantly Latin text.
@ -489,6 +500,7 @@ window.addEventListener('resize', () => {
</div> </div>
</div> </div>
</div> </div>
<EventDialog ref="eventDialogRef" :selection="{ startDate: null, dayCount: 0 }" />
</div> </div>
</div> </div>
</template> </template>

View File

@ -594,8 +594,10 @@ const recurrenceSummary = computed(() => {
<template> <template>
<BaseDialog v-model="showDialog" :anchor-el="anchorElement" @submit="saveEvent"> <BaseDialog v-model="showDialog" :anchor-el="anchorElement" @submit="saveEvent">
<template #title> <template #title>
{{ dialogMode === 'create' ? 'Create Event' : 'Edit Event' <div class="dialog-title-row">
}}<template v-if="headerDateShort"> · {{ headerDateShort }}</template> {{ dialogMode === 'create' ? 'Create Event' : 'Edit Event' }}
<span> · {{ headerDateShort }}</span>
</div>
</template> </template>
<label class="ec-field"> <label class="ec-field">
<input type="text" v-model="title" autocomplete="off" ref="titleInput" /> <input type="text" v-model="title" autocomplete="off" ref="titleInput" />
@ -620,9 +622,7 @@ const recurrenceSummary = computed(() => {
</label> </label>
<span class="recurrence-summary" v-if="recurrenceEnabled"> <span class="recurrence-summary" v-if="recurrenceEnabled">
{{ recurrenceSummary }} {{ recurrenceSummary }}
<template v-if="recurrenceOccurrences > 0"> <span v-if="recurrenceOccurrences > 0"> until {{ formattedFinalOccurrence }} </span>
until {{ formattedFinalOccurrence }}</template
>
</span> </span>
<span class="recurrence-summary muted" v-else>Does not recur</span> <span class="recurrence-summary muted" v-else>Does not recur</span>
</div> </div>
@ -668,7 +668,7 @@ const recurrenceSummary = computed(() => {
<template v-if="showDeleteVariants"> <template v-if="showDeleteVariants">
<div class="ec-delete-group"> <div class="ec-delete-group">
<button type="button" class="ec-btn delete-btn" @click="deleteEventOne"> <button type="button" class="ec-btn delete-btn" @click="deleteEventOne">
Delete {{ formattedOccurrenceShort }} Delete <span>{{ formattedOccurrenceShort }}</span>
</button> </button>
<button <button
v-if="!isLastOccurrence" v-if="!isLastOccurrence"
@ -676,7 +676,7 @@ const recurrenceSummary = computed(() => {
class="ec-btn delete-btn" class="ec-btn delete-btn"
@click="deleteEventFrom" @click="deleteEventFrom"
> >
Rest + Rest
</button> </button>
<button type="button" class="ec-btn delete-btn" @click="deleteEventAll">All</button> <button type="button" class="ec-btn delete-btn" @click="deleteEventAll">All</button>
</div> </div>
@ -1003,4 +1003,7 @@ const recurrenceSummary = computed(() => {
.ec-occurrences-field .ec-field input[type='number'] { .ec-occurrences-field .ec-field input[type='number'] {
max-width: 6rem; max-width: 6rem;
} }
span {
unicode-bidi: isolate;
}
</style> </style>

View File

@ -159,7 +159,13 @@ defineExpose({ open })
v-model="show" v-model="show"
title="Settings" title="Settings"
class="settings-modal" class="settings-modal"
:style="{ top: '4.5rem', insetInlineEnd: '2rem', bottom: 'auto', insetInlineStart: 'auto', transform: 'none' }" :style="{
top: '4.5rem',
insetInlineEnd: '2rem',
bottom: 'auto',
insetInlineStart: 'auto',
transform: 'none',
}"
> >
<div class="setting-group"> <div class="setting-group">
<label class="ec-field"> <label class="ec-field">