From f98db0e17b0d2cc7838ef4990530e8b412242234 Mon Sep 17 00:00:00 2001 From: Claude Date: Wed, 7 Oct 2026 07:27:42 +0000 Subject: [PATCH 1/3] Teacher reported today: class cards with a row per lesson and summary tiles - One card per class, one row per lesson (time, subject, teacher, missing), sorted by report hour. Cards flow in CSS columns, so no gaps. - Single missing-girls count per lesson, colored by severity (none / 1-4 / 5+); no badge covering the hour. - Date shown only when the filter spans more than one day. - Summary tiles: lessons reported, classes, teachers, total missing. Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_01Po2GocBhFneXD2k9z1f6Ld --- .../src/entities/teacher-reported-today.jsx | 208 ++++++++++-------- client/src/roadmapFeatures.js | 1 + 2 files changed, 116 insertions(+), 93 deletions(-) diff --git a/client/src/entities/teacher-reported-today.jsx b/client/src/entities/teacher-reported-today.jsx index 24cd925f..6d880448 100644 --- a/client/src/entities/teacher-reported-today.jsx +++ b/client/src/entities/teacher-reported-today.jsx @@ -1,5 +1,5 @@ -import { ChipField, DateInput, ReferenceField, RecordContextProvider, TextField, useListContext, usePermissions } from 'react-admin'; -import { Badge, Box, Card, CardContent, Typography } from '@mui/material'; +import { DateInput, ReferenceField, RecordContextProvider, TextField, useListContext, usePermissions } from 'react-admin'; +import { Box, Card, Typography } from '@mui/material'; import { getResourceComponents } from '@shared/components/crudContainers/CommonEntity'; import { CommonList } from '@shared/components/crudContainers/CommonList'; import { EmptyPage } from '@shared/components/crudContainers/EmptyPage'; @@ -29,112 +29,134 @@ const formatHour = (value) => (value ? new Date(value).toLocaleTimeString('he-IL const NO_KLASS_KEY = 'none'; -// The view has one row per lesson taught; each lesson gets its own card, -// so a teacher who taught two lessons shows as two cards. -function groupByTeacherAndDate(rows) { - const groups = new Map(); +// A lesson with this many missing girls or more is highlighted in red; fewer (but some) in orange. +const HIGH_MISSING_THRESHOLD = 5; + +const missingCount = (row) => Number(row.missingGirlsCount) || 0; + +const missingPillSx = (count) => ({ + display: 'inline-block', + minWidth: 32, + textAlign: 'center', + px: 1, + borderRadius: 999, + fontSize: 14, + fontVariantNumeric: 'tabular-nums', + ...(count === 0 + ? { color: 'text.secondary' } + : count >= HIGH_MISSING_THRESHOLD + ? { bgcolor: '#fde7e6', color: '#a5221a', fontWeight: 'bold' } + : { bgcolor: '#fff1dc', color: '#9a4a00', fontWeight: 500 }), +}); + +// The view has one row per lesson taught (already sorted by reportHour); group them into one card per class. +function groupByKlass(rows) { + const klasses = new Map(); rows.forEach((row) => { - const key = row.id; - if (!groups.has(key)) { - groups.set(key, { ...row, lessonRows: [] }); + const key = row.klassReferenceId ?? NO_KLASS_KEY; + if (!klasses.has(key)) { + klasses.set(key, { klassReferenceId: row.klassReferenceId, userId: row.userId, lessons: [] }); } - if (row.lessonReferenceId) { - groups.get(key).lessonRows.push(row); - } - }); - return [...groups.values()]; -} - -// Split teacher cards into one column per class, so reports are easy to scan by class. -function groupByKlass(groups) { - const columns = new Map(); - groups.forEach((group) => { - const key = group.klassReferenceId ?? NO_KLASS_KEY; - if (!columns.has(key)) { - columns.set(key, { klassReferenceId: group.klassReferenceId, groups: [] }); - } - columns.get(key).groups.push(group); + klasses.get(key).lessons.push(row); }); - return [...columns.values()].sort((a, b) => { + return [...klasses.values()].sort((a, b) => { if (!a.klassReferenceId) return 1; if (!b.klassReferenceId) return -1; return a.klassReferenceId - b.klassReferenceId; }); } -// Total missing girls for the whole card: sum across its lessons, or the card's own -// count when it has no per-lesson breakdown (the "ללא שיוך שיעור" case). -function getTotalMissingGirls(group) { - return group.lessonRows.length > 0 - ? group.lessonRows.reduce((sum, row) => sum + (Number(row.missingGirlsCount) || 0), 0) - : Number(group.missingGirlsCount) || 0; -} +const sumMissing = (rows) => rows.reduce((sum, row) => sum + missingCount(row), 0); + +const SummaryTiles = ({ rows, klassCount }) => { + const tiles = [ + { label: 'שיעורים שדווחו', value: rows.length }, + { label: 'כיתות', value: klassCount }, + { label: 'מורות', value: new Set(rows.map((row) => row.teacherReferenceId)).size }, + { label: 'סה״כ חסרות', value: sumMissing(rows) }, + ]; + return ( + + {tiles.map((tile) => ( + + {tile.label} + {tile.value} + + ))} + + ); +}; + +const LessonRow = ({ row, showDate }) => { + const count = missingCount(row); + return ( + + + + {showDate && `${formatDate(row.reportDate)} `}{formatHour(row.reportHour)} + + + {row.lessonReferenceId ? ( + + + + ) : 'ללא שיוך שיעור'} + + + + + + + + {count === 0 ? '–' : count} + + + + ); +}; const TeacherReportCards = ({ isAdmin }) => { const { data } = useListContext(); - const groups = groupByTeacherAndDate(data || []); - const columns = groupByKlass(groups); + const rows = data || []; + const klasses = groupByKlass(rows); + const showDate = new Set(rows.map((row) => row.reportDate)).size > 1; return ( - - {columns.map((column) => ( - - - {column.klassReferenceId ? ( - - - - - - ) : 'ללא כיתה'} - - - {column.groups.map((group) => { - const totalMissingGirls = getTotalMissingGirls(group); - return ( - - - - - - - - - - {totalMissingGirls > 0 && ( - - חסרו {totalMissingGirls} - - )} - - - {isAdmin && } - {formatDate(group.reportDate)} - {formatHour(group.reportHour)} - - - {group.lessonRows.length > 0 ? ( - group.lessonRows.map((row) => ( - - - - - - - - )) - ) : ( - ללא שיוך שיעור - )} - - - + + + + {klasses.map((klass) => { + const lessonCount = klass.lessons.length; + return ( + + + + {klass.klassReferenceId ? ( + + + + + + ) : 'ללא כיתה'} + + + {lessonCount === 1 ? 'שיעור אחד' : `${lessonCount} שיעורים`} · חסרו {sumMissing(klass.lessons)} + + + {isAdmin && ( + + + + - ); - })} - - - ))} + )} + {klass.lessons.map((row) => ( + + ))} + + ); + })} + ); }; diff --git a/client/src/roadmapFeatures.js b/client/src/roadmapFeatures.js index aed7a00d..251a8a8e 100644 --- a/client/src/roadmapFeatures.js +++ b/client/src/roadmapFeatures.js @@ -30,6 +30,7 @@ export default [ { html: 'הוספת דף "צור קשר" לשליחת פנייה עם קבצים מצורפים', status: 'בוצע', statusColor: 'success' }, { html: 'תשתית משימות רקע: ייצוא נתונים אסינכרוני, תזמונים קבועים וניטור משימות', status: 'בוצע', statusColor: 'success' }, { html: 'ניקוי אוטומטי של נוכחות שיעור נבחר, לפי כיתה/מסלול לשמירה, בכל מוצאי שבת', status: 'בוצע', statusColor: 'success' }, + { html: 'עיצוב חדש לדוח המורות שדיווחו: כרטיס לכל כיתה עם שורה לכל שיעור, צביעת מספר החסרות וריבועי סיכום', status: 'בוצע', statusColor: 'success' }, // { html: 'הגדרת תקופת זמן לפי תאריכים', status: 'בקרוב', statusColor: 'warning' }, // { html: 'הגדרת תקופת זמן לפי יום בשבוע', status: 'בוצע', statusColor: 'success' }, From 582d00516b1ccd36be881ac29429163d48beb029 Mon Sep 17 00:00:00 2001 From: Claude Date: Wed, 7 Oct 2026 07:41:17 +0000 Subject: [PATCH 2/3] Show teacher reported today report to admins The resource was gated by seminarAttendanceYemot only, so admins could not open it (and its admin-only user filter was unreachable). Gate it like the other report resources: permission or admin. Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_01Po2GocBhFneXD2k9z1f6Ld --- client/src/App.jsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/client/src/App.jsx b/client/src/App.jsx index 8d8ef24b..af065695 100644 --- a/client/src/App.jsx +++ b/client/src/App.jsx @@ -223,7 +223,7 @@ const App = () => ( options={{ menuGroup: 'report' }} icon={RuleIcon} /> - {isSeminarAttendanceYemot(permissions) && ( + {(isSeminarAttendanceYemot(permissions) || isAdmin(permissions)) && ( Date: Wed, 7 Oct 2026 07:45:19 +0000 Subject: [PATCH 3/3] Teacher reported today: per-user no-class cards, date from filter, partial-load note - Lessons without a class are grouped per user (admin view). - Date column follows the filter range, not the returned rows. - Note when the server total exceeds the loaded rows (1000 cap). Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_01Po2GocBhFneXD2k9z1f6Ld --- client/src/entities/teacher-reported-today.jsx | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/client/src/entities/teacher-reported-today.jsx b/client/src/entities/teacher-reported-today.jsx index 6d880448..1e9d78fb 100644 --- a/client/src/entities/teacher-reported-today.jsx +++ b/client/src/entities/teacher-reported-today.jsx @@ -53,9 +53,10 @@ const missingPillSx = (count) => ({ function groupByKlass(rows) { const klasses = new Map(); rows.forEach((row) => { - const key = row.klassReferenceId ?? NO_KLASS_KEY; + // Lessons without a class are grouped per user, so an admin never sees two users' rows in one card. + const key = row.klassReferenceId ?? `${NO_KLASS_KEY}_${row.userId}`; if (!klasses.has(key)) { - klasses.set(key, { klassReferenceId: row.klassReferenceId, userId: row.userId, lessons: [] }); + klasses.set(key, { key, klassReferenceId: row.klassReferenceId, userId: row.userId, lessons: [] }); } klasses.get(key).lessons.push(row); }); @@ -116,19 +117,25 @@ const LessonRow = ({ row, showDate }) => { }; const TeacherReportCards = ({ isAdmin }) => { - const { data } = useListContext(); + const { data, total, filterValues } = useListContext(); const rows = data || []; const klasses = groupByKlass(rows); - const showDate = new Set(rows.map((row) => row.reportDate)).size > 1; + // Show the date on each row unless the filter is a single day. + const showDate = !filterValues?.['reportDate:$gte'] || filterValues['reportDate:$gte'] !== filterValues['reportDate:$lte']; return ( + {total > rows.length && ( + + מוצגים {rows.length} מתוך {total} שיעורים. צמצמו את טווח התאריכים כדי לראות את כולם. + + )} {klasses.map((klass) => { const lessonCount = klass.lessons.length; return ( - + {klass.klassReferenceId ? (