From b294bba66b244d4d21cbd2a882f4c5cff9fbb450 Mon Sep 17 00:00:00 2001 From: Oliver Date: Sun, 14 Jun 2026 10:52:22 +1000 Subject: [PATCH] [UI] Calendar Updates (#12161) * Adjust delay values * Add extra info to tooltip * Additional padding * Adjust padding for scrollbar * Adjust month title as calendar scrolls --- .../src/components/calendar/Calendar.tsx | 55 +++++++++++++++++-- .../src/components/calendar/OrderCalendar.tsx | 2 +- .../calendar/OrderCalendarToolTip.tsx | 30 ++++++++-- src/frontend/src/pages/build/BuildIndex.tsx | 15 ++++- 4 files changed, 91 insertions(+), 11 deletions(-) diff --git a/src/frontend/src/components/calendar/Calendar.tsx b/src/frontend/src/components/calendar/Calendar.tsx index a579c87ae1..0a4dd18096 100644 --- a/src/frontend/src/components/calendar/Calendar.tsx +++ b/src/frontend/src/components/calendar/Calendar.tsx @@ -41,6 +41,7 @@ import { useCallback, useEffect, useMemo, + useRef, useState } from 'react'; import { useShallow } from 'zustand/react/shallow'; @@ -168,8 +169,8 @@ export default function Calendar({ return ( @@ -183,6 +184,40 @@ export default function Calendar({ [calendarProps.eventContent, eventTooltipContent] ); + const scrollBoxRef = useRef(null); + + const updateMonthFromScroll = useCallback(() => { + if (!scrollBoxRef.current) return; + const container = scrollBoxRef.current; + const containerTop = container.getBoundingClientRect().top; + + const cells = Array.from( + container.querySelectorAll( + '.fc-daygrid-day[data-date$="-01"]' + ) + ); + + let dateStr: string | null = null; + for (const cell of cells) { + if (cell.getBoundingClientRect().top <= containerTop + 1) { + dateStr = cell.getAttribute('data-date'); + } else { + break; + } + } + if (!dateStr) dateStr = cells[0]?.getAttribute('data-date') ?? null; + + if (dateStr) { + const date = new Date(`${dateStr}T12:00:00`); + state.setMonthName( + new Intl.DateTimeFormat(calendarLocale, { + month: 'long', + year: 'numeric' + }).format(date) + ); + } + }, [calendarLocale, state.setMonthName]); + const monthDayCellClassNames = useCallback( (arg: DayCellContentArg): string[] => { const monthClass = @@ -303,7 +338,19 @@ export default function Calendar({ )} - + + {order.overdue && ( + - + {order.reference} {order.description || order.title} + {entries.map((entry, index) => ( + + + {entry.label} + + {entry.value} + + ))} {order.start_date && ( - + {t`Start Date`} {formatDate(order.start_date)} )} {order.target_date && ( - + {t`Target Date`} {formatDate(order.target_date)} {order.overdue && ( @@ -51,7 +71,7 @@ export default function OrderCalendarToolTip({ )} {order.responsible && ( - + {t`Responsible`} diff --git a/src/frontend/src/pages/build/BuildIndex.tsx b/src/frontend/src/pages/build/BuildIndex.tsx index 43456c6138..4b1f7a2a70 100644 --- a/src/frontend/src/pages/build/BuildIndex.tsx +++ b/src/frontend/src/pages/build/BuildIndex.tsx @@ -37,10 +37,23 @@ function BuildOrderCalendar() { }, [globalSettings]); const renderTooltip = useCallback((event: EventContentArg) => { + const order = event?.event?._def?.extendedProps?.order; + + const extraEntries: { label: string; value: string | React.ReactNode }[] = + []; + + if (order?.quantity) { + extraEntries.push({ + label: t`Quantity`, + value: order.quantity + }); + } + return OrderCalendarToolTip({ event: event, modelType: ModelType.part, - instanceLookup: 'part_detail' + instanceLookup: 'part_detail', + extraEntries: extraEntries }); }, []);