From 3ab9048ca5abc8deb10394318749f1ea569011de Mon Sep 17 00:00:00 2001 From: Claude Date: Mon, 12 Oct 2026 18:23:09 +0000 Subject: [PATCH 1/3] feat: bulk change report date on attendance reports Co-Authored-By: Claude Opus 5.5 (1M context) Claude-Session: https://claude.ai/code/session_01AfCNveaaEyDu2irhQkQ7oQ --- .../entities/att-report-with-report-month.jsx | 11 ++++++++++ client/src/roadmapFeatures.js | 1 + ...tt-report-with-report-month.config.spec.ts | 21 +++++++++++++++++++ .../att-report-with-report-month.config.ts | 11 ++++++++++ 4 files changed, 44 insertions(+) diff --git a/client/src/entities/att-report-with-report-month.jsx b/client/src/entities/att-report-with-report-month.jsx index 27fb2ba0..9ef2d718 100644 --- a/client/src/entities/att-report-with-report-month.jsx +++ b/client/src/entities/att-report-with-report-month.jsx @@ -9,11 +9,13 @@ import { BooleanInput, NullableBooleanInput, maxLength, + required, } from 'react-admin'; import PlaylistRemoveIcon from '@mui/icons-material/PlaylistRemove'; import HelpIcon from '@mui/icons-material/Help'; import ClassIcon from '@mui/icons-material/Class'; import PersonIcon from '@mui/icons-material/Person'; +import EventIcon from '@mui/icons-material/Event'; import { CommonDatagrid } from '@shared/components/crudContainers/CommonList'; import { MultiReferenceField } from '@shared/components/fields/CommonReferenceField'; import { getResourceComponents } from '@shared/components/crudContainers/CommonEntity'; @@ -98,6 +100,15 @@ export const Datagrid = ({ isAdmin, children, ...props }) => { {isAdmin && } , + } + name="bulkChangeReportDate" + key="bulkChangeReportDate" + reloadOnEnd + > + + , } name="bulkKnownAbsences"> diff --git a/client/src/roadmapFeatures.js b/client/src/roadmapFeatures.js index 1c6576b4..10a52657 100644 --- a/client/src/roadmapFeatures.js +++ b/client/src/roadmapFeatures.js @@ -33,6 +33,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' }, diff --git a/server/src/entity-modules/__tests__/att-report-with-report-month.config.spec.ts b/server/src/entity-modules/__tests__/att-report-with-report-month.config.spec.ts index f8a9b947..8226ffd4 100644 --- a/server/src/entity-modules/__tests__/att-report-with-report-month.config.spec.ts +++ b/server/src/entity-modules/__tests__/att-report-with-report-month.config.spec.ts @@ -69,6 +69,7 @@ describe('att-report-with-report-month.config', () => { findBy: jest.fn(), insert: jest.fn(), save: jest.fn(), + update: jest.fn().mockResolvedValue({ affected: 2 }), }; mockDataSource = { getRepository: jest.fn().mockReturnValue(mockRepo), @@ -121,5 +122,25 @@ describe('att-report-with-report-month.config', () => { expect(mockDataSource.getRepository).toHaveBeenCalledWith(AttReport); expect(mockBaseCreateMany).toHaveBeenCalledWith(req, dto); }); + + it('bulkChangeReportDate should update reportDate of selected reports', async () => { + const req = { parsed: { extra: { action: 'bulkChangeReportDate', ids: '1,2', reportDate: '2026-10-11' } } } as any; + + const result = await service.doAction(req, {}); + + expect(mockDataSource.getRepository).toHaveBeenCalledWith(AttReport); + expect(mockRepo.update).toHaveBeenCalledWith({ id: expect.anything() }, { reportDate: expect.any(Date) }); + expect(mockRepo.update.mock.calls[0][0].id.value).toEqual([1, 2]); + expect(result).toBe('עודכנו 2 רשומות'); + }); + + it('bulkChangeReportDate should not update without a date', async () => { + const req = { parsed: { extra: { action: 'bulkChangeReportDate', ids: '1,2' } } } as any; + + const result = await service.doAction(req, {}); + + expect(mockRepo.update).not.toHaveBeenCalled(); + expect(result).toBe('לא נבחר תאריך'); + }); }); }); diff --git a/server/src/entity-modules/att-report-with-report-month.config.ts b/server/src/entity-modules/att-report-with-report-month.config.ts index ebff4d6f..f0ca9190 100644 --- a/server/src/entity-modules/att-report-with-report-month.config.ts +++ b/server/src/entity-modules/att-report-with-report-month.config.ts @@ -116,6 +116,8 @@ class AttReportWithReportMonthService): Promise { + const ids = getAsNumberArray(extra.ids); + if (!ids || ids.length === 0) return 'לא נבחרו רשומות'; + const reportDate = getAsDate(extra.reportDate); + if (!reportDate) return 'לא נבחר תאריך'; + const result = await this.dataSource.getRepository(AttReport).update({ id: In(ids) }, { reportDate }); + return `עודכנו ${result.affected} רשומות`; + } + private async bulkKnownAbsences(extra: Record): Promise { const ids = getAsArray(extra.ids); if (!ids) return 'לא נבחרו רשומות'; From 6428aa916151ba8626f30e536585a0c1011bfaa5 Mon Sep 17 00:00:00 2001 From: Claude Date: Mon, 12 Oct 2026 18:31:56 +0000 Subject: [PATCH 2/3] feat: replace change-date action with generic bulk edit on attendance reports Co-Authored-By: Claude Opus 5.5 (1M context) Claude-Session: https://claude.ai/code/session_01AfCNveaaEyDu2irhQkQ7oQ --- .../entities/att-report-with-report-month.jsx | 56 +++++++++---------- client/src/roadmapFeatures.js | 2 +- ...tt-report-with-report-month.config.spec.ts | 37 ++++++++++-- .../att-report-with-report-month.config.ts | 48 ++++++++-------- 4 files changed, 81 insertions(+), 62 deletions(-) diff --git a/client/src/entities/att-report-with-report-month.jsx b/client/src/entities/att-report-with-report-month.jsx index 9ef2d718..c136d11b 100644 --- a/client/src/entities/att-report-with-report-month.jsx +++ b/client/src/entities/att-report-with-report-month.jsx @@ -9,13 +9,13 @@ import { BooleanInput, NullableBooleanInput, maxLength, - required, + useResourceContext, + useStore, } from 'react-admin'; +import { useEffect } from 'react'; import PlaylistRemoveIcon from '@mui/icons-material/PlaylistRemove'; import HelpIcon from '@mui/icons-material/Help'; -import ClassIcon from '@mui/icons-material/Class'; -import PersonIcon from '@mui/icons-material/Person'; -import EventIcon from '@mui/icons-material/Event'; +import EditIcon from '@mui/icons-material/Edit'; import { CommonDatagrid } from '@shared/components/crudContainers/CommonList'; import { MultiReferenceField } from '@shared/components/fields/CommonReferenceField'; import { getResourceComponents } from '@shared/components/crudContainers/CommonEntity'; @@ -76,39 +76,37 @@ const filterDefaultValues = { ...defaultYearFilter, }; +// Fields left empty are not changed, so the dialog must not reopen with the last submitted values +const BulkEditButton = (props) => { + const resource = useResourceContext(); + const [cachedValues, setCachedValues] = useStore(`common.BulkRequestButton.${resource}.${props.name}`, {}); + useEffect(() => { + if (Object.keys(cachedValues ?? {}).length) { + setCachedValues({}); + } + }, [cachedValues, setCachedValues]); + return ; +}; + export const Datagrid = ({ isAdmin, children, ...props }) => { const additionalBulkButtons = [ - } - name="bulkChangeKlass" - key="bulkChangeKlass" + } + name="bulkEdit" + key="bulkEdit" reloadOnEnd > {isAdmin && } {isAdmin && } + - , - } - name="bulkChangeTeacher" - key="bulkChangeTeacher" - reloadOnEnd - > - {isAdmin && } - {isAdmin && } - , - } - name="bulkChangeReportDate" - key="bulkChangeReportDate" - reloadOnEnd - > - - , + + + + + , } name="bulkKnownAbsences"> diff --git a/client/src/roadmapFeatures.js b/client/src/roadmapFeatures.js index 10a52657..0ae709b7 100644 --- a/client/src/roadmapFeatures.js +++ b/client/src/roadmapFeatures.js @@ -33,7 +33,7 @@ export default [ { html: 'עיצוב חדש לדוח המורות שדיווחו: כרטיס לכל כיתה עם שורה לכל שיעור, צביעת מספר החסרות וריבועי סיכום', status: 'בוצע', statusColor: 'success' }, { html: 'דוח המורות שדיווחו: לחיצה על מספר החסרות מציגה את שמות הבנות שחסרו', status: 'בוצע', statusColor: 'success' }, { html: 'דוח חדש "מעקב חיסורים": כרטיס לכל כיתה, סף חיסורים לבחירה, כמה חיסורים נשארו לכל תלמידה עד הסף ופירוט בלחיצה', status: 'בוצע', statusColor: 'success' }, - { html: 'רשימת דיווחי נוכחות: פעולה מרוכזת "שינוי תאריך" לתיקון תאריך דיווח של מספר רשומות יחד', status: 'בוצע', statusColor: 'success' }, + { html: 'רשימת דיווחי נוכחות: פעולה "עריכה מרוכזת" לשינוי תאריך, כיתה, מורה, שיעור ועוד במספר רשומות יחד (שדה ריק לא משתנה)', status: 'בוצע', statusColor: 'success' }, // { html: 'הגדרת תקופת זמן לפי תאריכים', status: 'בקרוב', statusColor: 'warning' }, // { html: 'הגדרת תקופת זמן לפי יום בשבוע', status: 'בוצע', statusColor: 'success' }, diff --git a/server/src/entity-modules/__tests__/att-report-with-report-month.config.spec.ts b/server/src/entity-modules/__tests__/att-report-with-report-month.config.spec.ts index 8226ffd4..09695051 100644 --- a/server/src/entity-modules/__tests__/att-report-with-report-month.config.spec.ts +++ b/server/src/entity-modules/__tests__/att-report-with-report-month.config.spec.ts @@ -123,24 +123,49 @@ describe('att-report-with-report-month.config', () => { expect(mockBaseCreateMany).toHaveBeenCalledWith(req, dto); }); - it('bulkChangeReportDate should update reportDate of selected reports', async () => { - const req = { parsed: { extra: { action: 'bulkChangeReportDate', ids: '1,2', reportDate: '2026-10-11' } } } as any; + it('bulkEdit should update only filled fields', async () => { + const req = { + parsed: { + extra: { + action: 'bulkEdit', + ids: '1,2', + reportDate: '2026-10-11', + klassReferenceId: '5', + teacherReferenceId: 'undefined', + lessonReferenceId: 'null', + howManyLessons: '', + absCount: '0', + }, + }, + } as any; const result = await service.doAction(req, {}); expect(mockDataSource.getRepository).toHaveBeenCalledWith(AttReport); - expect(mockRepo.update).toHaveBeenCalledWith({ id: expect.anything() }, { reportDate: expect.any(Date) }); + expect(mockRepo.update).toHaveBeenCalledWith( + { id: expect.anything() }, + { reportDate: new Date('2026-10-11'), klassReferenceId: 5, absCount: 0 }, + ); expect(mockRepo.update.mock.calls[0][0].id.value).toEqual([1, 2]); expect(result).toBe('עודכנו 2 רשומות'); }); - it('bulkChangeReportDate should not update without a date', async () => { - const req = { parsed: { extra: { action: 'bulkChangeReportDate', ids: '1,2' } } } as any; + it('bulkEdit should not update when no field is filled', async () => { + const req = { parsed: { extra: { action: 'bulkEdit', ids: '1,2', reportDate: 'null' } } } as any; const result = await service.doAction(req, {}); expect(mockRepo.update).not.toHaveBeenCalled(); - expect(result).toBe('לא נבחר תאריך'); + expect(result).toBe('לא נבחרו שדות לעדכון'); + }); + + it('bulkEdit should reject invalid values', async () => { + const req = { parsed: { extra: { action: 'bulkEdit', ids: '1', absCount: 'abc' } } } as any; + + const result = await service.doAction(req, {}); + + expect(mockRepo.update).not.toHaveBeenCalled(); + expect(result).toBe('ערך לא תקין'); }); }); }); diff --git a/server/src/entity-modules/att-report-with-report-month.config.ts b/server/src/entity-modules/att-report-with-report-month.config.ts index f0ca9190..db3103de 100644 --- a/server/src/entity-modules/att-report-with-report-month.config.ts +++ b/server/src/entity-modules/att-report-with-report-month.config.ts @@ -112,12 +112,8 @@ class AttReportWithReportMonthService, body: any): Promise { switch (req.parsed.extra.action) { - case 'bulkChangeKlass': - return this.bulkChangeKlass(req.parsed.extra); - case 'bulkChangeTeacher': - return this.bulkChangeTeacher(req.parsed.extra); - case 'bulkChangeReportDate': - return this.bulkChangeReportDate(req.parsed.extra); + case 'bulkEdit': + return this.bulkEdit(req.parsed.extra); case 'bulkKnownAbsences': return this.bulkKnownAbsences(req.parsed.extra); case 'fixStudentReferenceV2': @@ -128,30 +124,30 @@ class AttReportWithReportMonthService): Promise { + private async bulkEdit(extra: Record): Promise { const ids = getAsNumberArray(extra.ids); if (!ids || ids.length === 0) return 'לא נבחרו רשומות'; - const klassReferenceId = getAsNumber(extra.klassReferenceId); - if (!klassReferenceId) return 'לא נבחרה כיתה'; - const result = await this.dataSource.getRepository(AttReport).update({ id: In(ids) }, { klassReferenceId }); - return `עודכנו ${result.affected} רשומות`; - } - private async bulkChangeTeacher(extra: Record): Promise { - const ids = getAsNumberArray(extra.ids); - if (!ids || ids.length === 0) return 'לא נבחרו רשומות'; - const teacherReferenceId = getAsNumber(extra.teacherReferenceId); - if (!teacherReferenceId) return 'לא נבחר מורה'; - const result = await this.dataSource.getRepository(AttReport).update({ id: In(ids) }, { teacherReferenceId }); - return `עודכנו ${result.affected} רשומות`; - } + const isEmpty = (value: string) => value === undefined || value === 'undefined' || value === 'null' || value === ''; + const numberFields = ['klassReferenceId', 'teacherReferenceId', 'lessonReferenceId', 'howManyLessons', 'absCount']; + const update: Partial = {}; + for (const field of numberFields) { + if (isEmpty(extra[field])) continue; + const value = getAsNumber(extra[field]); + if (isNaN(value)) return 'ערך לא תקין'; + update[field] = value; + } + if (!isEmpty(extra.reportDate)) { + const reportDate = getAsDate(extra.reportDate); + if (isNaN(reportDate.getTime())) return 'תאריך לא תקין'; + update.reportDate = reportDate; + } + if (!isEmpty(extra.comments)) { + update.comments = getAsString(extra.comments); + } + if (Object.keys(update).length === 0) return 'לא נבחרו שדות לעדכון'; - private async bulkChangeReportDate(extra: Record): Promise { - const ids = getAsNumberArray(extra.ids); - if (!ids || ids.length === 0) return 'לא נבחרו רשומות'; - const reportDate = getAsDate(extra.reportDate); - if (!reportDate) return 'לא נבחר תאריך'; - const result = await this.dataSource.getRepository(AttReport).update({ id: In(ids) }, { reportDate }); + const result = await this.dataSource.getRepository(AttReport).update({ id: In(ids) }, update); return `עודכנו ${result.affected} רשומות`; } From fd1a7d52f5404a85bc9e5db9f720205e21a054dd Mon Sep 17 00:00:00 2001 From: Claude Date: Mon, 12 Oct 2026 18:52:30 +0000 Subject: [PATCH 3/3] refactor: bulk edit uses shared getBulkEditUpdate and cacheValues={false} Bumps client/shared and server/shared to branches adding those helpers. Co-Authored-By: Claude Opus 5.5 (1M context) Claude-Session: https://claude.ai/code/session_01AfCNveaaEyDu2irhQkQ7oQ --- client/shared | 2 +- .../entities/att-report-with-report-month.jsx | 20 +++------------- server/shared | 2 +- ...tt-report-with-report-month.config.spec.ts | 4 +--- .../att-report-with-report-month.config.ts | 23 +++++-------------- 5 files changed, 12 insertions(+), 39 deletions(-) diff --git a/client/shared b/client/shared index 46e2e98d..e7f2d9cf 160000 --- a/client/shared +++ b/client/shared @@ -1 +1 @@ -Subproject commit 46e2e98df63b51374174b30536dcd71f1140c06d +Subproject commit e7f2d9cff57c30639c6daae22261576af0486d97 diff --git a/client/src/entities/att-report-with-report-month.jsx b/client/src/entities/att-report-with-report-month.jsx index c136d11b..e1e15515 100644 --- a/client/src/entities/att-report-with-report-month.jsx +++ b/client/src/entities/att-report-with-report-month.jsx @@ -9,10 +9,7 @@ import { BooleanInput, NullableBooleanInput, maxLength, - useResourceContext, - useStore, } from 'react-admin'; -import { useEffect } from 'react'; import PlaylistRemoveIcon from '@mui/icons-material/PlaylistRemove'; import HelpIcon from '@mui/icons-material/Help'; import EditIcon from '@mui/icons-material/Edit'; @@ -76,26 +73,15 @@ const filterDefaultValues = { ...defaultYearFilter, }; -// Fields left empty are not changed, so the dialog must not reopen with the last submitted values -const BulkEditButton = (props) => { - const resource = useResourceContext(); - const [cachedValues, setCachedValues] = useStore(`common.BulkRequestButton.${resource}.${props.name}`, {}); - useEffect(() => { - if (Object.keys(cachedValues ?? {}).length) { - setCachedValues({}); - } - }, [cachedValues, setCachedValues]); - return ; -}; - export const Datagrid = ({ isAdmin, children, ...props }) => { const additionalBulkButtons = [ - } name="bulkEdit" key="bulkEdit" reloadOnEnd + cacheValues={false} > {isAdmin && } {isAdmin && } @@ -106,7 +92,7 @@ export const Datagrid = ({ isAdmin, children, ...props }) => { - , + , } name="bulkKnownAbsences"> diff --git a/server/shared b/server/shared index fc2c5f4f..1e1060ed 160000 --- a/server/shared +++ b/server/shared @@ -1 +1 @@ -Subproject commit fc2c5f4f8787e2e3bd93714171996c0c70198f07 +Subproject commit 1e1060ed55a9360a9b66c9c34d8bcf2f10505a19 diff --git a/server/src/entity-modules/__tests__/att-report-with-report-month.config.spec.ts b/server/src/entity-modules/__tests__/att-report-with-report-month.config.spec.ts index 09695051..3caf0026 100644 --- a/server/src/entity-modules/__tests__/att-report-with-report-month.config.spec.ts +++ b/server/src/entity-modules/__tests__/att-report-with-report-month.config.spec.ts @@ -162,10 +162,8 @@ describe('att-report-with-report-month.config', () => { it('bulkEdit should reject invalid values', async () => { const req = { parsed: { extra: { action: 'bulkEdit', ids: '1', absCount: 'abc' } } } as any; - const result = await service.doAction(req, {}); - + await expect(service.doAction(req, {})).rejects.toThrow('ערך לא תקין'); expect(mockRepo.update).not.toHaveBeenCalled(); - expect(result).toBe('ערך לא תקין'); }); }); }); diff --git a/server/src/entity-modules/att-report-with-report-month.config.ts b/server/src/entity-modules/att-report-with-report-month.config.ts index db3103de..2295147b 100644 --- a/server/src/entity-modules/att-report-with-report-month.config.ts +++ b/server/src/entity-modules/att-report-with-report-month.config.ts @@ -10,6 +10,7 @@ import { validateBulk } from '@shared/base-entity/base-entity.util'; import { fixReferences } from '@shared/utils/entity/fixReference.util'; import { getHebrewDateFormatter } from '@shared/utils/formatting/formatter.util'; import { shouldShowTopic } from './att-report.config'; +import { getBulkEditUpdate } from '@shared/utils/entity/bulkEdit.util'; import { getAsArray, getAsDate, @@ -128,23 +129,11 @@ class AttReportWithReportMonthService value === undefined || value === 'undefined' || value === 'null' || value === ''; - const numberFields = ['klassReferenceId', 'teacherReferenceId', 'lessonReferenceId', 'howManyLessons', 'absCount']; - const update: Partial = {}; - for (const field of numberFields) { - if (isEmpty(extra[field])) continue; - const value = getAsNumber(extra[field]); - if (isNaN(value)) return 'ערך לא תקין'; - update[field] = value; - } - if (!isEmpty(extra.reportDate)) { - const reportDate = getAsDate(extra.reportDate); - if (isNaN(reportDate.getTime())) return 'תאריך לא תקין'; - update.reportDate = reportDate; - } - if (!isEmpty(extra.comments)) { - update.comments = getAsString(extra.comments); - } + const update = getBulkEditUpdate(extra, { + numbers: ['klassReferenceId', 'teacherReferenceId', 'lessonReferenceId', 'howManyLessons', 'absCount'], + dates: ['reportDate'], + strings: ['comments'], + }); if (Object.keys(update).length === 0) return 'לא נבחרו שדות לעדכון'; const result = await this.dataSource.getRepository(AttReport).update({ id: In(ids) }, update);