diff --git a/client/src/App.jsx b/client/src/App.jsx index 2d4414a0..ff478ad0 100644 --- a/client/src/App.jsx +++ b/client/src/App.jsx @@ -142,15 +142,6 @@ const App = () => ( } /> - - {' '} - {' '} - - } - /> } /> } /> } /> diff --git a/client/src/GeneralLayout.jsx b/client/src/GeneralLayout.jsx index b495b45b..d73f3faf 100644 --- a/client/src/GeneralLayout.jsx +++ b/client/src/GeneralLayout.jsx @@ -80,7 +80,8 @@ const customMenuItems = [ /> ), ({ permissions }) => - shouldShowLessonReports(permissions) && ( + shouldShowLessonReports(permissions) && + !isTeacherView(permissions) && ( { class MockBaseEntityService { @@ -32,6 +34,12 @@ jest.mock('@shared/base-entity/base-entity.service', () => { async doAction(req: any, body: any) { return 'success'; } + getRelationMetadata(field: string, options: any) { + return mockGetRelationMetadata(field, options); + } + async createBuilder(parsed: any, options: any, many: boolean, withDeleted: boolean) { + return mockBaseCreateBuilder(parsed, options, many, withDeleted); + } } return { BaseEntityService: MockBaseEntityService, @@ -89,6 +97,19 @@ describe('att-report-with-report-month.config', () => { (BaseEntityService as unknown as jest.Mock).mockClear?.(); }); + it('createBuilder should resolve the klass relation before the nested klass.klassType filter', async () => { + const options = { query: { join: config.query.join } }; + const parsed = { filter: [{ field: 'klass.klassType.teacherReferenceId', operator: '$eq', value: 1 }] }; + + await expect(service.createBuilder(parsed, options)).resolves.toBe('builder'); + + expect(mockGetRelationMetadata).toHaveBeenCalledWith('klass', { eager: false }); + expect(mockGetRelationMetadata.mock.invocationCallOrder[0]).toBeLessThan( + mockBaseCreateBuilder.mock.invocationCallOrder[0], + ); + expect(mockBaseCreateBuilder).toHaveBeenCalledWith(parsed, options, true, false); + }); + it('createOne should delegate to AttReport service', async () => { const req = { options: {}, parsed: {} } as any; const dto = { reportDate: '2022-01-01' }; 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 05c92f25..efadfe25 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 @@ -1,4 +1,5 @@ -import { CrudRequest, Override, CreateManyDto } from '@dataui/crud'; +import { CrudRequest, CrudRequestOptions, Override, CreateManyDto } from '@dataui/crud'; +import { ParsedRequestParams } from '@dataui/crud-request'; import { In, DeepPartial } from 'typeorm'; import { BaseEntityModuleOptions, Entity } from '@shared/base-entity/interface'; import { IHeader } from '@shared/utils/exporter/types'; @@ -83,6 +84,14 @@ class AttReportWithReportMonthService, dto: DeepPartial): Promise { const attReportService = this.getAttReportService();