Add calendar color support (DAVx5 calendar-color)
Calendars can now have a color (hex, e.g. #3b82f6) that DAVx5 and other
CalDAV clients pick up via the Apple/dav4jvm calendar-color property.
- db: add calendars.color column with migration for existing DBs;
CreateCalendarWithColor, SetCalendarColor, GetCalendarColor;
ListCalendars now returns []Calendar{Name, Color} instead of []string
- caldav: since go-webdav's caldav.Backend interface has no extension
point for vendor properties, wrap the handler with a response-rewriting
middleware that injects <calendar-color xmlns="http://apple.com/ns/ical/">
into PROPFIND responses for calendars that have a color set
- web: color picker on the "New calendar" form and an inline color swatch/
picker on each calendar card (calendars only, not address books)
- nidusctl: `calendar create --color` flag and a new `calendar color`
subcommand; `calendar list` now also prints the color if set
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
This commit is contained in:
@@ -13,6 +13,7 @@ type ShareRow struct {
|
||||
type ResourceCard struct {
|
||||
Kind string // "calendar" or "addressbook"
|
||||
Name string
|
||||
Color string // hex color like "#3b82f6"; only used for calendars
|
||||
Shares []ShareRow
|
||||
}
|
||||
|
||||
@@ -43,6 +44,11 @@ templ Dashboard(username string, resources []ResourceCard, sharedWithMe []Shared
|
||||
placeholder="e.g. work"
|
||||
class="w-full rounded-md border-gray-300 border px-2 py-1.5 text-sm"/>
|
||||
</div>
|
||||
<div>
|
||||
<label class="block text-xs text-gray-500 mb-1">Color</label>
|
||||
<input name="color" type="color" value="#3b82f6"
|
||||
class="w-12 h-9 rounded-md border-gray-300 border p-0.5"/>
|
||||
</div>
|
||||
<button type="submit"
|
||||
class="w-full sm:w-auto bg-indigo-600 text-white rounded-md px-3 py-1.5 text-sm font-medium hover:bg-indigo-700">
|
||||
Add
|
||||
@@ -106,7 +112,24 @@ templ ResourceList(resources []ResourceCard) {
|
||||
templ ResourceCardView(r ResourceCard) {
|
||||
<div id={ "resource-" + r.Kind + "-" + r.Name } class="bg-white rounded-lg border border-gray-200 p-5">
|
||||
<div class="flex items-center justify-between mb-3">
|
||||
<h2 class="font-medium">
|
||||
<h2 class="font-medium flex items-center gap-2">
|
||||
if r.Kind == "calendar" {
|
||||
<form
|
||||
hx-post="/web/resources/calendar/color"
|
||||
hx-target={ "#resource-" + r.Kind + "-" + r.Name }
|
||||
hx-swap="outerHTML"
|
||||
hx-trigger="change"
|
||||
>
|
||||
<input type="hidden" name="name" value={ r.Name }/>
|
||||
<input
|
||||
name="color"
|
||||
type="color"
|
||||
value={ colorOrDefault(r.Color) }
|
||||
title="Calendar color"
|
||||
class="w-6 h-6 rounded border border-gray-300 p-0 align-middle"
|
||||
/>
|
||||
</form>
|
||||
}
|
||||
{ r.Name }
|
||||
<span class="text-xs uppercase tracking-wide text-gray-400 ml-2">{ r.Kind }</span>
|
||||
</h2>
|
||||
@@ -195,3 +218,10 @@ func resourceVals(name string) string {
|
||||
return `{"name": "` + name + `"}`
|
||||
}
|
||||
|
||||
func colorOrDefault(c string) string {
|
||||
if c == "" {
|
||||
return "#3b82f6"
|
||||
}
|
||||
return c
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user