Third audit, UI half; side nav on top; request button colors
- Event cards: lazy -640 photo, only nearby slides drawn, a counter past 12 events, past grid paged with Show more - Community map: search over list and grid, 12 per region then Show all, list no longer redrawn on hover - People tiles: one clip check for the list, Show all past 30 - Person pages: 6 events and posts then Show all; excerpts load only the first paragraph - Admin: filter box on long pickers and the QR select, options sent per form, Media thumbnails from the small copy, debounced searches that drop stale answers - Pages show their last data while refreshing after the cache TTL - Side nav stacks above page content (the carousel arrows) - No event request button on National Retreats; request buttons take their section's accent - Version v1.11.1-audit Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
parent
11a4555683
commit
222c9e69a2
22 changed files with 686 additions and 259 deletions
|
|
@ -88,10 +88,11 @@
|
|||
═══════════════════════════════════════════════════════════════ */
|
||||
|
||||
import { ArrowUp, ArrowDown, CaretRight, Copy, Plus, X } from "@phosphor-icons/react";
|
||||
import { useRef, useState } from "react";
|
||||
import { useMemo, useRef, useState } from "react";
|
||||
|
||||
import { ApiError, post } from "../../lib/api.ts";
|
||||
import ContentBlocks from "../ContentBlocks.tsx";
|
||||
import { FILTER_FROM, OptionFilter, narrow } from "../OptionFilter.tsx";
|
||||
import { ImageInput, LinkPreviewInput } from "./MediaLibrary.tsx";
|
||||
import { ChooseFileButton } from "./DriveFiles.tsx";
|
||||
|
||||
|
|
@ -225,28 +226,35 @@ export function Field({ field, value, row, options, error, onChange, onPatch }:
|
|||
const widget = field.widget ?? "text";
|
||||
const locked = Boolean(field.readOnly);
|
||||
|
||||
let list: any = null;
|
||||
let orphaned = false;
|
||||
|
||||
if (widget === "select") {
|
||||
list = field.optionsFrom
|
||||
? (options?.[field.optionsFrom] ?? []).map((o) => [o.id, o.label, o])
|
||||
: (field.options ?? []).map((o) =>
|
||||
Array.isArray(o) ? [o[0], o[1]] : [o, o],
|
||||
);
|
||||
if (field.filterBy && row) {
|
||||
list = list.filter(([, , raw]) => !raw || field.filterBy(raw, row));
|
||||
// The select's options, rebuilt only when their source changes
|
||||
// (or, with filterBy, the row they're filtered by), not on every
|
||||
// keystroke elsewhere in the form.
|
||||
const source = field.optionsFrom ? options?.[field.optionsFrom] : field.options;
|
||||
const filterRow = field.filterBy ? row : null;
|
||||
const list: any[] | null = useMemo<any[] | null>(() => {
|
||||
if (widget !== "select") return null;
|
||||
let all = field.optionsFrom
|
||||
? (source ?? []).map((o) => [o.id, o.label, o])
|
||||
: (source ?? []).map((o) => (Array.isArray(o) ? [o[0], o[1]] : [o, o]));
|
||||
if (field.filterBy && filterRow) {
|
||||
all = all.filter(([, , raw]) => !raw || field.filterBy(raw, filterRow));
|
||||
}
|
||||
return all;
|
||||
}, [widget, field, source, filterRow]);
|
||||
|
||||
// A stored value with no matching option renders as the blank
|
||||
// choice, which reads as "nobody set this" and saves as a
|
||||
// deliberate clear. It usually means the row it pointed at was
|
||||
// deleted, so keep it on screen and say so.
|
||||
orphaned =
|
||||
value != null &&
|
||||
value !== "" &&
|
||||
!list.some(([optionId]) => String(optionId) === String(value));
|
||||
}
|
||||
// Past FILTER_FROM options, a box above the select narrows them.
|
||||
const [needle, setNeedle] = useState("");
|
||||
const shown: any[] = list ? narrow<any>(list, needle, ([, label]) => label, ([optionId]) => String(optionId) === String(value)) : [];
|
||||
|
||||
// A stored value with no matching option renders as the blank
|
||||
// choice, which reads as "nobody set this" and saves as a
|
||||
// deliberate clear. It usually means the row it pointed at was
|
||||
// deleted, so keep it on screen and say so.
|
||||
const orphaned =
|
||||
list != null &&
|
||||
value != null &&
|
||||
value !== "" &&
|
||||
!list.some(([optionId]) => String(optionId) === String(value));
|
||||
|
||||
// A file from the Drive library into this link field (`files`).
|
||||
const pickFile = (file) => {
|
||||
|
|
@ -297,21 +305,30 @@ export function Field({ field, value, row, options, error, onChange, onPatch }:
|
|||
// A select has no readOnly, so this one really does have
|
||||
// to be disabled: there's no way to keep it focusable
|
||||
// and still refuse a new choice.
|
||||
<select
|
||||
{...common}
|
||||
disabled={locked}
|
||||
className={`${locked ? inputLocked : common.className} ${
|
||||
orphaned && !locked ? inputError : ""
|
||||
}`}
|
||||
>
|
||||
<option value="">{field.blankLabel ?? "- Please choose from the list -"}</option>
|
||||
{orphaned && <option value={value}>{value} no longer exists</option>}
|
||||
{list.map(([id2, label]) => (
|
||||
<option key={id2} value={id2}>
|
||||
{label}
|
||||
</option>
|
||||
))}
|
||||
</select>
|
||||
<>
|
||||
{(list?.length ?? 0) > FILTER_FROM && !locked && (
|
||||
<OptionFilter
|
||||
value={needle}
|
||||
onChange={setNeedle}
|
||||
label={`Narrow the ${typeof field.label === "function" ? field.label(row) : field.label} list`}
|
||||
/>
|
||||
)}
|
||||
<select
|
||||
{...common}
|
||||
disabled={locked}
|
||||
className={`${locked ? inputLocked : common.className} ${
|
||||
orphaned && !locked ? inputError : ""
|
||||
}`}
|
||||
>
|
||||
<option value="">{field.blankLabel ?? "- Please choose from the list -"}</option>
|
||||
{orphaned && <option value={value}>{value} no longer exists</option>}
|
||||
{shown.map(([id2, label]) => (
|
||||
<option key={id2} value={id2}>
|
||||
{label}
|
||||
</option>
|
||||
))}
|
||||
</select>
|
||||
</>
|
||||
) : widget === "color" ? (
|
||||
<div className="flex gap-2">
|
||||
<input
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue