diff --git a/web/src/editor/JournalPanel.tsx b/web/src/editor/JournalPanel.tsx index fba7d63..5b6ec4d 100644 --- a/web/src/editor/JournalPanel.tsx +++ b/web/src/editor/JournalPanel.tsx @@ -37,6 +37,8 @@ export function JournalPanel({ objects, scopeObjectId, onScopeChange, + scopePlantingId = null, + onScopePlantingChange, }: { gardenId: number canEdit: boolean @@ -46,13 +48,23 @@ export function JournalPanel({ /** Which bed the panel is filtered to, if any. */ scopeObjectId: number | null onScopeChange: (id: number | null) => void + /** Which single plop the panel is filtered to, if any (#85). Mutually + * exclusive with scopeObjectId — the editor store enforces that. */ + scopePlantingId?: number | null + onScopePlantingChange?: (id: number | null) => void }) { // Date-range narrowing (#85): the backend and JournalFilter already supported // from/to; they just had no UI. Empty inputs don't filter. const [from, setFrom] = useState('') const [to, setTo] = useState('') + // A plop scope wins over a bed scope — the two are mutually exclusive in the + // store, but guard here too so the filter is never double-scoped. const filter = { - ...(scopeObjectId != null ? { objectId: scopeObjectId } : {}), + ...(scopePlantingId != null + ? { plantingId: scopePlantingId } + : scopeObjectId != null + ? { objectId: scopeObjectId } + : {}), ...(from ? { from } : {}), ...(to ? { to } : {}), } @@ -83,6 +95,21 @@ export function JournalPanel({ )} + {scopePlantingId != null && ( +
+ Notes about one planting + {onScopePlantingChange && ( + + )} +
+ )} +