Website 1.7.1: move and zoom for ministries', leaders' and events' photos

1.7.0 had Move and zoom in page sections only. Ministries, Leadership
and Events now have it on their photo, in the frame the site uses for
the current template and layouts. Saved with the row as `framing`
({ x, y, zoom }, null for centred; cleared when the photo changes).
Ministries and leaders are drafts until Publish (snapshot, Discard and
Restore carry it); an event's shows once the event is published.
Versions published before this compare unchanged.

One migration: a nullable JSONB `framing` column on Ministry, Leader
and SimpleEvent.

Also: the 1.7.0 e2e test waits for the media library to load before
counting it (it could count an empty list).

Checked: Website backend tests (136) and typecheck, frontend typecheck
and lint, production build, admin e2e suite in Chromium (12).
Lighthouse not run.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-11-28 00:27:54 +02:00
co-authored by Claude Opus 5.5
parent 4897489fb1
commit 0c521ff614
23 changed files with 212 additions and 40 deletions
@@ -8,15 +8,17 @@
*/
import { useState } from "react";
import { api, canEdit } from "@/admin/api";
import { RowFraming } from "@/admin/framing";
import { ImagePicker } from "@/admin/media";
import type { Focus } from "@/site/types";
import { Btn, Field, inputClass, Loading, Notice, Panel, Title, useAction, useAdmin, when } from "@/admin/ui";
import { CalendarDays } from "lucide-react";
type Ev = {
id: string; slug: string; title: string; startsAt: string; endsAt: string | null; allDay: boolean; location: string | null; description: string | null;
imageId: string | null; image: string | null; link: string | null; ministryId: string | null; cancelled: boolean; published: boolean; updatedAt: string;
imageId: string | null; image: string | null; framing: Focus | null; link: string | null; ministryId: string | null; cancelled: boolean; published: boolean; updatedAt: string;
};
type Form = { title: string; date: string; time: string; endDate: string; endTime: string; allDay: boolean; location: string; description: string; imageId: string | null; link: string; ministryId: string | null };
type Form = { title: string; date: string; time: string; endDate: string; endTime: string; allDay: boolean; location: string; description: string; imageId: string | null; framing: Focus | null; link: string; ministryId: string | null };
type Me = { user: { role: string; ministryId: string | null } };
/** "2026-12-05" + "18:30" in the browser's time zone (the church's, for its admins) → ISO with offset. */
@@ -53,11 +55,14 @@ function EventForm({ initial, ministries, fixedMinistry, onSave, onCancel }: { i
</select>
</Field>
)}
<ImagePicker label="Photo" value={v.imageId} onChange={(id) => set("imageId", id)} />
<RowFraming type="event" value={v.framing} onChange={(f) => set("framing", f)}>
{/* Another photo starts centred. */}
<ImagePicker label="Photo" slot={{ key: "imageId" }} value={v.imageId} onChange={(id) => setV({ ...v, imageId: id, framing: null })} />
</RowFraming>
<div className="flex gap-2">
<Btn kind="primary" busy={busy} onClick={() => run(() => onSave({
title: v.title, startsAt: iso(v.date, v.allDay ? "00:00" : v.time), endsAt: v.endDate ? iso(v.endDate, v.allDay ? "23:59" : v.endTime) : null,
allDay: v.allDay, location: v.location || null, description: v.description || null, imageId: v.imageId, link: v.link || null, ministryId: fixedMinistry ?? v.ministryId,
allDay: v.allDay, location: v.location || null, description: v.description || null, imageId: v.imageId, framing: v.framing, link: v.link || null, ministryId: fixedMinistry ?? v.ministryId,
}))}>Save</Btn>
<Btn onClick={onCancel}>Cancel</Btn>
</div>
@@ -66,7 +71,7 @@ function EventForm({ initial, ministries, fixedMinistry, onSave, onCancel }: { i
);
}
const empty: Form = { title: "", date: "", time: "10:00", endDate: "", endTime: "", allDay: false, location: "", description: "", imageId: null, link: "", ministryId: null };
const empty: Form = { title: "", date: "", time: "10:00", endDate: "", endTime: "", allDay: false, location: "", description: "", imageId: null, framing: null, link: "", ministryId: null };
export default function Events() {
const me = useAdmin<Me>("/me");
@@ -82,7 +87,7 @@ export default function Events() {
const toForm = (e: Ev): Form => {
const s = local(e.startsAt);
const f = local(e.endsAt);
return { title: e.title, date: s.d, time: s.t, endDate: f.d, endTime: f.t, allDay: e.allDay, location: e.location ?? "", description: e.description ?? "", imageId: e.imageId, link: e.link ?? "", ministryId: e.ministryId };
return { title: e.title, date: s.d, time: s.t, endDate: f.d, endTime: f.t, allDay: e.allDay, location: e.location ?? "", description: e.description ?? "", imageId: e.imageId, framing: e.framing ?? null, link: e.link ?? "", ministryId: e.ministryId };
};
const state = (e: Ev, change: object, done: string) => run(async () => { await api(`/events/${e.id}/state`, { body: change }); await reload(); }, done);
const form = (e: Ev | null) => (
@@ -15,7 +15,7 @@ export default function Leaders() {
{ key: "name", label: "Name", kind: "text", max: 120 },
{ key: "role", label: "Role", kind: "text", max: 120, hint: "E.g. “Lead pastor”." },
{ key: "bio", label: "About them", kind: "textarea", max: 4000 },
{ key: "photoId", label: "Photo", kind: "image" },
{ key: "photoId", label: "Photo", kind: "image", frame: "leader" },
]} />
</>
);
@@ -15,7 +15,7 @@ export default function Ministries() {
{ key: "name", label: "Name", kind: "text", max: 120 },
{ key: "summary", label: "In one line", kind: "text", max: 300, hint: "E.g. “Ages 3 to 12, every Sunday at 10:00.”" },
{ key: "body", label: "More about it", kind: "textarea", max: 8000 },
{ key: "imageId", label: "Photo", kind: "image" },
{ key: "imageId", label: "Photo", kind: "image", frame: "ministry" },
]} />
</>
);