diff --git a/client/shared b/client/shared index e9728015..4b62749c 160000 --- a/client/shared +++ b/client/shared @@ -1 +1 @@ -Subproject commit e97280151cc346a5597ef07e94dd2c43054d962d +Subproject commit 4b62749c04a60cc97d6bf47b611d719f31b490d1 diff --git a/server/shared b/server/shared index cc6d2bf6..85cf1993 160000 --- a/server/shared +++ b/server/shared @@ -1 +1 @@ -Subproject commit cc6d2bf6e71c0cb123fbb47484014afd4eaaae27 +Subproject commit 85cf19932ecbcb0f25582dc41241996d37f5387b 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 131605d7..e75dd653 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 @@ -89,7 +89,14 @@ describe('att-report-with-report-month.config', () => { // Mock getOne on the service instance itself since it calls this.getOne() service.getOne = jest.fn().mockResolvedValue({ id: 1, reportDate: '2022-01-01' }); // By default every selected id is accessible to the caller - service.getManyByIds = jest.fn().mockImplementation((req, ids) => Promise.resolve(ids.map((id) => ({ id })))); + service.getSelectedIds = jest.fn().mockImplementation((req) => + Promise.resolve( + String(req.parsed.extra.ids ?? '') + .split(',') + .filter(Boolean) + .map(Number), + ), + ); mockBaseCreateOne.mockClear(); mockBaseCreateMany.mockClear(); @@ -155,19 +162,19 @@ describe('att-report-with-report-month.config', () => { }); it('bulkKnownAbsences should only use ids the caller can access', async () => { - service.getManyByIds.mockResolvedValueOnce([{ id: 1 }]); + service.getSelectedIds.mockResolvedValueOnce([1]); mockRepo.findBy.mockResolvedValueOnce([]); const req = { parsed: { extra: { action: 'bulkKnownAbsences', ids: '1,99' } } } as any; // An empty insert fails validation; only the lookup matters here await service.doAction(req, {}).catch(() => undefined); - expect(service.getManyByIds).toHaveBeenCalledWith(req, [1, 99]); + expect(service.getSelectedIds).toHaveBeenCalledWith(req); expect(mockRepo.findBy.mock.calls[0][0].id.value).toEqual([1]); }); it('bulkKnownAbsences should do nothing when no selected id is accessible', async () => { - service.getManyByIds.mockResolvedValueOnce([]); + service.getSelectedIds.mockResolvedValueOnce([]); const req = { parsed: { extra: { action: 'bulkKnownAbsences', ids: '99' } } } as any; const result = await service.doAction(req, {}); diff --git a/server/src/entity-modules/__tests__/student-klass.config.spec.ts b/server/src/entity-modules/__tests__/student-klass.config.spec.ts index bbcc90f8..abfc6053 100644 --- a/server/src/entity-modules/__tests__/student-klass.config.spec.ts +++ b/server/src/entity-modules/__tests__/student-klass.config.spec.ts @@ -169,7 +169,14 @@ describe('StudentKlassConfig', () => { const Service = config.service; service = new Service(mockRepository as Repository, mockMailService); service.dataSource = mockDataSource as DataSource; - service.getManyByIds = jest.fn().mockImplementation((req, ids) => Promise.resolve(ids.map((id) => ({ id })))); + service.getSelectedIds = jest.fn().mockImplementation((req) => + Promise.resolve( + String(req.parsed.extra.ids ?? '') + .split(',') + .filter(Boolean) + .map(Number), + ), + ); }); describe('getReportData', () => { @@ -228,7 +235,7 @@ describe('StudentKlassConfig', () => { it('should only fix references of ids the caller can access', async () => { const req = createMockCrudRequest({ action: 'fixReferences', ids: '1,99' }); - service.getManyByIds.mockResolvedValueOnce([{ id: 1 }]); + service.getSelectedIds.mockResolvedValueOnce([1]); mockRepository.findBy.mockResolvedValueOnce([createMockStudentKlass({ id: 1, studentTz: '123', klassId: 1 })]); await service.doAction(req, {}); 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 efadfe25..7f5987c8 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 @@ -11,7 +11,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 { getAsDate, getAsNumber, getAsBoolean, getAsString, getAsNumberArray } from '@shared/utils/queryParam.util'; +import { getAsDate, getAsNumber, getAsBoolean, getAsString } from '@shared/utils/queryParam.util'; function getConfig(): BaseEntityModuleOptions { return { @@ -139,9 +139,7 @@ class AttReportWithReportMonthService): Promise { - const ids = getAsNumberArray(req.parsed.extra.ids); - const entities = await this.getManyByIds(req, ids); - return entities.map((entity: any) => entity.id); + return this.getSelectedIds(req); } private async bulkKnownAbsences(extra: Record, ids: number[]): Promise { diff --git a/server/src/entity-modules/klass.config.ts b/server/src/entity-modules/klass.config.ts index 57cbb60b..95ea0a7b 100644 --- a/server/src/entity-modules/klass.config.ts +++ b/server/src/entity-modules/klass.config.ts @@ -26,9 +26,7 @@ class KlassService extends BaseEntityService { async doAction(req: CrudRequest, body: any): Promise { switch (req.parsed.extra.action) { case 'fixReferences': { - const ids = (await this.getManyByIds(req, getAsNumberArray(req.parsed.extra.ids))).map( - (entity: any) => entity.id, - ); + const ids = await this.getSelectedIds(req); if (!ids.length) return 'לא נבחרו רשומות'; const referenceFields = { klassTypeId: 'klassTypeReferenceId', diff --git a/server/src/entity-modules/report-group-session.config.ts b/server/src/entity-modules/report-group-session.config.ts index a69dcb0b..92161030 100644 --- a/server/src/entity-modules/report-group-session.config.ts +++ b/server/src/entity-modules/report-group-session.config.ts @@ -38,9 +38,7 @@ class ReportGroupSessionService extends B async doAction(req: CrudRequest, body: any): Promise { switch (req.parsed.extra.action) { case 'adjustTime': { - const ids = (await this.getManyByIds(req, getAsNumberArray(req.parsed.extra.ids))).map( - (entity: any) => entity.id, - ); + const ids = await this.getSelectedIds(req); const hoursAdjustment = getAsNumber(req.parsed.extra.hoursAdjustment) || 0; if (hoursAdjustment === 0) { diff --git a/server/src/entity-modules/report-group.config.ts b/server/src/entity-modules/report-group.config.ts index 2662866c..916c6c8f 100644 --- a/server/src/entity-modules/report-group.config.ts +++ b/server/src/entity-modules/report-group.config.ts @@ -40,9 +40,7 @@ class ReportGroupService extends BaseEntityServi async doAction(req: CrudRequest, body: any): Promise { switch (req.parsed.extra.action) { case 'updateSignatureData': { - const ids = (await this.getManyByIds(req, getAsNumberArray(req.parsed.extra.ids))).map( - (entity: any) => entity.id, - ); + const ids = await this.getSelectedIds(req); if (!ids.length) return 'לא נבחרו רשומות'; const signatureData = getAsString(req.parsed.extra.signatureData); await this.updateSignatureData(ids, signatureData); diff --git a/server/src/entity-modules/student-klass.config.ts b/server/src/entity-modules/student-klass.config.ts index 38642b95..f94f4b82 100644 --- a/server/src/entity-modules/student-klass.config.ts +++ b/server/src/entity-modules/student-klass.config.ts @@ -66,9 +66,7 @@ class StudentKlassService extends BaseEntitySer async doAction(req: CrudRequest, body: any): Promise { switch (req.parsed.extra.action) { case 'fixReferences': { - const ids = (await this.getManyByIds(req, getAsNumberArray(req.parsed.extra.ids))).map( - (entity: any) => entity.id, - ); + const ids = await this.getSelectedIds(req); if (!ids.length) return 'לא נבחרו רשומות'; const referenceFields = { studentTz: 'studentReferenceId', diff --git a/server/src/reports/lessonSignaturePdfReport.tsx b/server/src/reports/lessonSignaturePdfReport.tsx index 1f32c59c..8b853cc9 100644 --- a/server/src/reports/lessonSignaturePdfReport.tsx +++ b/server/src/reports/lessonSignaturePdfReport.tsx @@ -500,7 +500,6 @@ const LessonSignatureReport: React.FunctionComponent ); @@ -519,7 +518,6 @@ const LessonSignatureReport: React.FunctionComponent )} @@ -695,13 +693,11 @@ const LessonDetailsSection: React.FC = ({ interface StudentRecordsTableProps { studentRecords: LessonSignaturePdfData['studentRecords']; entityConfig: ReturnType; - entityName: string; } const StudentRecordsTable: React.FC = ({ studentRecords, entityConfig, - entityName }) => { const containerStyle: React.CSSProperties = { marginBottom: '30px', diff --git a/server/src/reports/studentReportCardReact.tsx b/server/src/reports/studentReportCardReact.tsx index 95429af2..202c38ae 100644 --- a/server/src/reports/studentReportCardReact.tsx +++ b/server/src/reports/studentReportCardReact.tsx @@ -571,7 +571,7 @@ function getReports( ): AppProps['reports'] { const dataMap = groupDataByKeys(reports, ['teacherReferenceId', 'klassReferenceId', 'lessonReferenceId']); - const data = Object.entries(dataMap).map(([key, val]) => { + const data = Object.entries(dataMap).map(([, val]) => { const { userId, year, studentReferenceId, klassReferenceId, lessonReferenceId, teacherReferenceId } = val[0]; const knownAbsences = knownAbsMap[klassReferenceId]?.[lessonReferenceId]; const { lessonsCount, absCount, approvedAbsCount, attPercents, absPercents, gradeAvg, lastGrade, maxGrade } = calcReportsData(val, [{ absnceCount: knownAbsences }]);