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 27fb2ba0..e1e15515 100644 --- a/client/src/entities/att-report-with-report-month.jsx +++ b/client/src/entities/att-report-with-report-month.jsx @@ -12,8 +12,7 @@ import { } 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 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'; @@ -77,26 +76,22 @@ const filterDefaultValues = { export const Datagrid = ({ isAdmin, children, ...props }) => { const additionalBulkButtons = [ } - name="bulkChangeKlass" - key="bulkChangeKlass" + label="עריכה מרוכזת" + icon={} + name="bulkEdit" + key="bulkEdit" reloadOnEnd + cacheValues={false} > {isAdmin && } {isAdmin && } + - , - } - name="bulkChangeTeacher" - key="bulkChangeTeacher" - reloadOnEnd - > - {isAdmin && } - {isAdmin && } + + + + , } name="bulkKnownAbsences"> diff --git a/client/src/roadmapFeatures.js b/client/src/roadmapFeatures.js index 444699a2..b3f79345 100644 --- a/client/src/roadmapFeatures.js +++ b/client/src/roadmapFeatures.js @@ -34,6 +34,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/shared b/server/shared index 8622a336..c7558b33 160000 --- a/server/shared +++ b/server/shared @@ -1 +1 @@ -Subproject commit 8622a33656f804d88e2d45d81438002f3ee9dcbb +Subproject commit c7558b330f8468a16ab6013f143041b7ed950afe 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..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 @@ -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,48 @@ describe('att-report-with-report-month.config', () => { expect(mockDataSource.getRepository).toHaveBeenCalledWith(AttReport); expect(mockBaseCreateMany).toHaveBeenCalledWith(req, dto); }); + + 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: 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('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('לא נבחרו שדות לעדכון'); + }); + + it('bulkEdit should reject invalid values', async () => { + const req = { parsed: { extra: { action: 'bulkEdit', ids: '1', absCount: 'abc' } } } as any; + + await expect(service.doAction(req, {})).rejects.toThrow('ערך לא תקין'); + expect(mockRepo.update).not.toHaveBeenCalled(); + }); }); }); 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..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, @@ -112,10 +113,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 'bulkEdit': + return this.bulkEdit(req.parsed.extra); case 'bulkKnownAbsences': return this.bulkKnownAbsences(req.parsed.extra); case 'fixStudentReferenceV2': @@ -126,21 +125,18 @@ 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 }); + 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); return `עודכנו ${result.affected} רשומות`; }