Basic CalDav UI (Calendar)
This implements a basic CalDav UI, titled "Calendar". It allows creating new calendars and events with a start and end date, URL, location, and description.
You can also import and export ICS (VCALENDAR + VEVENT) files.
It allows editing the ICS directly, for power users.
Additionally, you can hide/display events from certain calendars, change their names and their colors. If there's no calendar created yet in your CalDav server (first-time setup), it'll automatically create one, titled "Calendar".
You can also change the display timezone for the calendar from the settings.
Finally, there's some minor documentation fixes and some other minor tweaks.
Closes #56
Closes #89
2025-09-06 11:46:13 +00:00
|
|
|
import { useSignal } from '@preact/signals';
|
|
|
|
|
import { useEffect } from 'preact/hooks';
|
|
|
|
|
|
|
|
|
|
import { Calendar, CalendarEvent } from '/lib/models/calendar.ts';
|
|
|
|
|
|
|
|
|
|
interface AddEventModalProps {
|
|
|
|
|
isOpen: boolean;
|
|
|
|
|
initialStartDate?: Date;
|
|
|
|
|
initiallyAllDay?: boolean;
|
|
|
|
|
calendars: Calendar[];
|
|
|
|
|
onClickSave: (newEvent: CalendarEvent) => Promise<void>;
|
|
|
|
|
onClose: () => void;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export default function AddEventModal(
|
|
|
|
|
{ isOpen, initialStartDate, initiallyAllDay, calendars, onClickSave, onClose }: AddEventModalProps,
|
|
|
|
|
) {
|
|
|
|
|
const newEvent = useSignal<CalendarEvent | null>(null);
|
|
|
|
|
|
|
|
|
|
useEffect(() => {
|
|
|
|
|
if (!isOpen) {
|
|
|
|
|
newEvent.value = null;
|
|
|
|
|
} else {
|
|
|
|
|
const startDate = new Date(initialStartDate || new Date());
|
|
|
|
|
|
|
|
|
|
startDate.setUTCMinutes(0);
|
|
|
|
|
startDate.setUTCSeconds(0);
|
|
|
|
|
startDate.setUTCMilliseconds(0);
|
|
|
|
|
|
|
|
|
|
const endDate = new Date(startDate);
|
|
|
|
|
endDate.setUTCHours(startDate.getUTCHours() + 1);
|
|
|
|
|
|
|
|
|
|
if (initiallyAllDay) {
|
|
|
|
|
startDate.setUTCHours(9);
|
|
|
|
|
endDate.setUTCHours(18);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
newEvent.value = {
|
|
|
|
|
uid: 'new',
|
|
|
|
|
url: '',
|
|
|
|
|
title: '',
|
|
|
|
|
calendarId: calendars[0]!.uid!,
|
|
|
|
|
startDate: startDate,
|
|
|
|
|
endDate: endDate,
|
|
|
|
|
isAllDay: initiallyAllDay || false,
|
|
|
|
|
organizerEmail: '',
|
|
|
|
|
transparency: 'opaque',
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
}, [isOpen]);
|
|
|
|
|
|
|
|
|
|
return (
|
|
|
|
|
<>
|
|
|
|
|
<section
|
Remove fresh
This implements a huge change, where Fresh is removed as a framework and serving files, allowing more control over importing, bundling, and serving files and components.
The biggest challenge was to continue making sure that there weren't too many places to look into for import versions, and `PasswordlessPasskeyLogin.tsx` became a prototype in migrating a component to fully SSR, no need for frontend parsing (via Babel) or bundling (via a custom-script, downloading frontend dependencies from esm.sh). Still, there are too many components to migrate like that, and it's all working, so I likely won't even attempt it unless there's some bug, new feature, or security vulnerability to address that warrants a rewrite of those.
This also updates all dependencies (except `@libs/xml` because that still causes some breaking in DAV endpoints), including Deno!
All other advantages can be seen in the related issues, and the breaking change this (v4.0.0) introduces is related simply to `config.email.tlsMode` (which had a deprecation warning throughout v3), and because, while I tested many things exhaustively, it's not impossible something broke that I didn't see.
Closes #141
Closes #132
2026-02-20 10:54:31 +00:00
|
|
|
class={`fixed ${isOpen ? 'block' : 'hidden'} z-40 w-screen h-screen inset-0 bg-gray-900/60`}
|
Basic CalDav UI (Calendar)
This implements a basic CalDav UI, titled "Calendar". It allows creating new calendars and events with a start and end date, URL, location, and description.
You can also import and export ICS (VCALENDAR + VEVENT) files.
It allows editing the ICS directly, for power users.
Additionally, you can hide/display events from certain calendars, change their names and their colors. If there's no calendar created yet in your CalDav server (first-time setup), it'll automatically create one, titled "Calendar".
You can also change the display timezone for the calendar from the settings.
Finally, there's some minor documentation fixes and some other minor tweaks.
Closes #56
Closes #89
2025-09-06 11:46:13 +00:00
|
|
|
>
|
|
|
|
|
</section>
|
|
|
|
|
|
|
|
|
|
<section
|
|
|
|
|
class={`fixed ${
|
|
|
|
|
newEvent.value ? 'block' : 'hidden'
|
|
|
|
|
} z-50 top-1/2 left-1/2 -translate-x-1/2 -translate-y-1/2 min-w-96 max-w-lg bg-slate-600 text-white rounded-md px-8 py-6 drop-shadow-lg overflow-y-scroll max-h-[80%]`}
|
|
|
|
|
>
|
|
|
|
|
<h1 class='text-2xl font-semibold my-5'>New Event</h1>
|
|
|
|
|
<section class='py-5 my-2 border-y border-slate-500'>
|
|
|
|
|
<fieldset class='block mb-2'>
|
|
|
|
|
<label class='text-slate-300 block pb-1' for='event_title'>Title</label>
|
|
|
|
|
<input
|
|
|
|
|
class='input-field'
|
|
|
|
|
type='text'
|
|
|
|
|
name='event_title'
|
|
|
|
|
id='event_title'
|
|
|
|
|
value={newEvent.value?.title || ''}
|
|
|
|
|
onInput={(event) => newEvent.value = { ...newEvent.value!, title: event.currentTarget.value }}
|
|
|
|
|
placeholder='Dentist'
|
|
|
|
|
/>
|
|
|
|
|
</fieldset>
|
|
|
|
|
<fieldset class='block mb-2'>
|
|
|
|
|
<label class='text-slate-300 block pb-1' for='event_calendar'>Calendar</label>
|
|
|
|
|
<section class='flex items-center justify-between'>
|
|
|
|
|
<select
|
Remove fresh
This implements a huge change, where Fresh is removed as a framework and serving files, allowing more control over importing, bundling, and serving files and components.
The biggest challenge was to continue making sure that there weren't too many places to look into for import versions, and `PasswordlessPasskeyLogin.tsx` became a prototype in migrating a component to fully SSR, no need for frontend parsing (via Babel) or bundling (via a custom-script, downloading frontend dependencies from esm.sh). Still, there are too many components to migrate like that, and it's all working, so I likely won't even attempt it unless there's some bug, new feature, or security vulnerability to address that warrants a rewrite of those.
This also updates all dependencies (except `@libs/xml` because that still causes some breaking in DAV endpoints), including Deno!
All other advantages can be seen in the related issues, and the breaking change this (v4.0.0) introduces is related simply to `config.email.tlsMode` (which had a deprecation warning throughout v3), and because, while I tested many things exhaustively, it's not impossible something broke that I didn't see.
Closes #141
Closes #132
2026-02-20 10:54:31 +00:00
|
|
|
class='input-field mr-2 w-5/6!'
|
Basic CalDav UI (Calendar)
This implements a basic CalDav UI, titled "Calendar". It allows creating new calendars and events with a start and end date, URL, location, and description.
You can also import and export ICS (VCALENDAR + VEVENT) files.
It allows editing the ICS directly, for power users.
Additionally, you can hide/display events from certain calendars, change their names and their colors. If there's no calendar created yet in your CalDav server (first-time setup), it'll automatically create one, titled "Calendar".
You can also change the display timezone for the calendar from the settings.
Finally, there's some minor documentation fixes and some other minor tweaks.
Closes #56
Closes #89
2025-09-06 11:46:13 +00:00
|
|
|
name='event_calendar'
|
|
|
|
|
id='event_calendar'
|
|
|
|
|
value={newEvent.value?.calendarId || ''}
|
|
|
|
|
onChange={(event) => newEvent.value = { ...newEvent.value!, calendarId: event.currentTarget.value }}
|
|
|
|
|
>
|
|
|
|
|
{calendars.map((calendar) => (
|
|
|
|
|
<option key={calendar.uid} value={calendar.uid}>{calendar.displayName}</option>
|
|
|
|
|
))}
|
|
|
|
|
</select>
|
|
|
|
|
<span
|
|
|
|
|
class={`w-5 h-5 block rounded-full`}
|
|
|
|
|
style={{
|
|
|
|
|
backgroundColor: calendars.find((calendar) => calendar.uid === newEvent.value?.calendarId)
|
|
|
|
|
?.calendarColor,
|
|
|
|
|
}}
|
|
|
|
|
title={calendars.find((calendar) => calendar.uid === newEvent.value?.calendarId)?.calendarColor}
|
|
|
|
|
>
|
|
|
|
|
</span>
|
|
|
|
|
</section>
|
|
|
|
|
</fieldset>
|
|
|
|
|
<fieldset class='block mb-2'>
|
|
|
|
|
<label class='text-slate-300 block pb-1' for='event_start_date'>Start date</label>
|
|
|
|
|
<input
|
|
|
|
|
class='input-field'
|
|
|
|
|
type='datetime-local'
|
|
|
|
|
name='event_start_date'
|
|
|
|
|
id='event_start_date'
|
|
|
|
|
value={newEvent.value?.startDate ? new Date(newEvent.value.startDate).toISOString().substring(0, 16) : ''}
|
|
|
|
|
onInput={(event) =>
|
|
|
|
|
newEvent.value = { ...newEvent.value!, startDate: new Date(event.currentTarget.value) }}
|
|
|
|
|
/>
|
|
|
|
|
<aside class='text-sm text-slate-400 p-2 '>
|
|
|
|
|
Dates are set in the default calendar timezone, controlled by Radicale.
|
|
|
|
|
</aside>
|
|
|
|
|
</fieldset>
|
|
|
|
|
<fieldset class='block mb-2'>
|
|
|
|
|
<label class='text-slate-300 block pb-1' for='event_end_date'>End date</label>
|
|
|
|
|
<input
|
|
|
|
|
class='input-field'
|
|
|
|
|
type='datetime-local'
|
|
|
|
|
name='event_end_date'
|
|
|
|
|
id='event_end_date'
|
|
|
|
|
value={newEvent.value?.endDate ? new Date(newEvent.value.endDate).toISOString().substring(0, 16) : ''}
|
|
|
|
|
onInput={(event) => newEvent.value = { ...newEvent.value!, endDate: new Date(event.currentTarget.value) }}
|
|
|
|
|
/>
|
|
|
|
|
<aside class='text-sm text-slate-400 p-2 '>
|
|
|
|
|
Dates are set in the default calendar timezone, controlled by Radicale.
|
|
|
|
|
</aside>
|
|
|
|
|
</fieldset>
|
|
|
|
|
<fieldset class='block mb-2'>
|
|
|
|
|
<label class='text-slate-300 block pb-1' for='event_is_all_day'>All-day?</label>
|
|
|
|
|
<input
|
|
|
|
|
type='checkbox'
|
|
|
|
|
name='event_is_all_day'
|
|
|
|
|
id='event_is_all_day'
|
|
|
|
|
value='true'
|
|
|
|
|
checked={newEvent.value?.isAllDay}
|
|
|
|
|
onChange={(event) => newEvent.value = { ...newEvent.value!, isAllDay: event.currentTarget.checked }}
|
|
|
|
|
/>
|
|
|
|
|
</fieldset>
|
|
|
|
|
</section>
|
|
|
|
|
<footer class='flex justify-between'>
|
|
|
|
|
<button
|
|
|
|
|
type='button'
|
|
|
|
|
class='px-5 py-2 bg-slate-600 hover:bg-slate-500 text-white cursor-pointer rounded-md'
|
|
|
|
|
onClick={() => onClickSave(newEvent.value!)}
|
|
|
|
|
>
|
|
|
|
|
Save
|
|
|
|
|
</button>
|
|
|
|
|
<button
|
|
|
|
|
type='button'
|
|
|
|
|
class='px-5 py-2 bg-slate-600 hover:bg-slate-500 text-white cursor-pointer rounded-md'
|
|
|
|
|
onClick={() => onClose()}
|
|
|
|
|
>
|
|
|
|
|
Close
|
|
|
|
|
</button>
|
|
|
|
|
</footer>
|
|
|
|
|
</section>
|
|
|
|
|
</>
|
|
|
|
|
);
|
|
|
|
|
}
|