Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion client/src/components/StudentView/student-event-report.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@ import { defaultYearFilter } from '@shared/utils/yearFilter';
import { CommonYearInput } from '@shared/components/fields/CommonYear';
import { handleActionSuccess, handleError } from '@shared/utils/notifyUtil';
import SignatureInput from '@shared/components/fields/signature/SignatureInput';
import { useObjectStore } from 'src/utils/storeUtil';
import { useObjectStore } from "src/utils/storeUtil";
import { CommonFileInput } from '@shared/components/fields/CommonFileInput';

const DynamicFields = ({ absenceType, isLoading }) => {
if (isLoading) return <Loading loadingPrimary="טוען שדות..." />;
Expand Down Expand Up @@ -63,6 +64,8 @@ const extractBasePayload = (rootValues, reportValues, userId, studentId, absence
reason: finalReason,
absenceTypeId: rootValues.absenceTypeId,
absnceCode: rootValues.absnceCode,
fileData: rootValues.fileData

};
};

Expand Down Expand Up @@ -230,6 +233,7 @@ const StudentEventReport = (props) => {
</div>
</SimpleFormIterator>
</ArrayInput>
<CommonFileInput source="fileData" validate={absenceType?.isFileRequired ? [required()] : []} label=" צירוף קובץ אסמכתא לאירוע" />
<NumberInput source="absnceCode" validate={required()} />
<CommonYearInput disabled />
<BooleanInput source="isApproved" defaultValue={true} disabled />
Expand Down
4 changes: 3 additions & 1 deletion client/src/domainTranslations.js
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,8 @@ export default {
comment: 'הערה',
isApproved: 'מאושר',
absenceTypeId: 'סוג אירוע',
},
fileData: 'קובץ מצורף',
}
},
lesson: {
name: 'שיעור |||| שיעורים',
Expand Down Expand Up @@ -219,6 +220,7 @@ export default {
name: 'שם האירוע',
quota: 'מכסה שנתית',
requiredLabels: 'שדות חובה לדיווח',
isFileRequired:'חובה לצרף קובץ',
},
},
student_klass_report: {
Expand Down
10 changes: 7 additions & 3 deletions client/src/entities/absenceType.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,9 @@ import {
NumberInput,
maxLength,
ArrayInput,
SimpleFormIterator
SimpleFormIterator,
BooleanInput,
BooleanField,
} from 'react-admin';
import { CommonDatagrid } from '@shared/components/crudContainers/CommonList';
import { getResourceComponents } from '@shared/components/crudContainers/CommonEntity';
Expand Down Expand Up @@ -38,6 +40,7 @@ const Datagrid = ({ isAdmin, children, ...props }) => {

<TextField source="name" />
<TextField source="quota" />
<BooleanField source="isFileRequired" />
<CommonYearField />

<TextField source="requiredLabels" />
Expand All @@ -61,6 +64,7 @@ const Inputs = ({ isCreate, isAdmin }) => {
<TextInput fullWidth />
</SimpleFormIterator>
</ArrayInput>
<BooleanInput source="isFileRequired" />

{!isCreate && isAdmin && <DateTimeInput source="createdAt" disabled />}
{!isCreate && isAdmin && <DateTimeInput source="updatedAt" disabled />}
Expand All @@ -71,7 +75,7 @@ const Inputs = ({ isCreate, isAdmin }) => {
const Representation = CommonRepresentation;

const importer = {
fields: ['name', 'quota', 'requiredLabels', 'year'],
fields: ['name', 'quota', 'requiredLabels', 'year', 'isFileRequired'],
};

const entity = {
Expand All @@ -83,4 +87,4 @@ const entity = {
importer,
};

export default getResourceComponents(entity);
export default getResourceComponents(entity);
11 changes: 10 additions & 1 deletion client/src/entities/known-absence.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,9 @@ import { BulkApproveAbsences } from 'src/components/BulkApproveAbsences';
import { commonAdminFilters } from '@shared/components/fields/PermissionFilter';
import { useIsAbsenceType } from 'src/utils/appPermissions';

import CommonFileField from '@shared/components/fields/CommonFileField';
import { CommonFileDownloadButton } from '@shared/components/fields/CommonFilePreviewButton';

const filters = [
...commonAdminFilters,
<CommonReferenceInputFilter
Expand Down Expand Up @@ -98,6 +101,8 @@ const Datagrid = ({ isAdmin, children, isPreview, ...props }) => {
<TextField source="senderName" />
<TextField source="reason" />
<TextField source="comment" />
<CommonFileField source="fileData" />
<CommonFileDownloadButton source="fileData" label="הורד קובץ" />
<BooleanField source="isApproved" />
{!isPreview && <CommonYearField />}
{isAdmin && <DateField showDate showTime source="createdAt" />}
Expand Down Expand Up @@ -142,6 +147,8 @@ const Inputs = ({ isCreate, isAdmin }) => {
<TextInput source="senderName" validate={maxLength(100)} />
<TextInput source="reason" validate={maxLength(500)} />
<TextInput source="comment" validate={maxLength(500)} />
<CommonFileField source="fileData" />
<CommonFileDownloadButton source="fileData" label="הורד קובץ" />
<BooleanInput source="isApproved" defaultValue={true} />
<CommonYearInput />
{!isCreate && isAdmin && <DateTimeInput source="createdAt" disabled />}
Expand All @@ -155,13 +162,15 @@ const importer = {
'studentTz',
'klassId',
'lessonId',
'absenceTypeId',
'reportDate',
'absnceCount',
'absnceCode',
'senderName',
'reason',
'comment',
'isApproved',
'fileData',
],
};

Expand All @@ -178,4 +187,4 @@ const entity = {
additionalListActions,
};

export default getResourceComponents(entity);
export default getResourceComponents(entity);
4 changes: 4 additions & 0 deletions server/src/db/entities/AbsenceType.entity.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,10 @@ export class AbsenceType implements IHasUserId {
})
requiredLabels: string[] | null;

@IsOptional({ always: true })
@Column('boolean', { name: 'is_file_required', default: false })
isFileRequired: boolean;

@CreatedAtColumn()
createdAt: Date;

Expand Down
46 changes: 25 additions & 21 deletions server/src/db/entities/KnownAbsence.entity.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,26 +8,27 @@ import {
JoinColumn,
ManyToOne,
PrimaryGeneratedColumn,
} from 'typeorm';
import { IHasUserId } from '@shared/base-entity/interface';
import { User } from 'src/db/entities/User.entity';
import { findOneAndAssignReferenceId, getDataSource } from '@shared/utils/entity/foreignKey.util';
import { Student } from './Student.entity';
import { IsOptional, ValidateIf } from 'class-validator';
import { CrudValidationGroups } from '@dataui/crud';
import { IsBoolean, IsDate, IsNotEmpty, IsNumber, MaxLength } from '@shared/utils/validation/class-validator-he';
import { fillDefaultYearValue } from '@shared/utils/entity/year.util';
import { fillDefaultReportDateValue } from '@shared/utils/entity/deafultValues.util';
import { Klass } from './Klass.entity';
import { Lesson } from './Lesson.entity';
import { KlassType } from './KlassType.entity';
import { Teacher } from './Teacher.entity';
import { AbsenceType } from './AbsenceType.entity';
import { BooleanType, DateType, NumberType, StringType } from '@shared/utils/entity/class-transformer';
import { LessonKlassName } from '../view-entities/LessonKlassName.entity';
import { CreatedAtColumn, UpdatedAtColumn } from '@shared/utils/entity/column-types.util';

@Index('known_users_idx', ['userId'], {})
} from "typeorm";
import { IHasUserId } from "@shared/base-entity/interface";
import { User } from "src/db/entities/User.entity";
import { findOneAndAssignReferenceId, getDataSource } from "@shared/utils/entity/foreignKey.util";
import { Student } from "./Student.entity";
import { IsOptional, ValidateIf } from "class-validator";
import { CrudValidationGroups } from "@dataui/crud";
import { IsBoolean, IsDate, IsNotEmpty, IsNumber, MaxLength } from "@shared/utils/validation/class-validator-he";
import { fillDefaultYearValue } from "@shared/utils/entity/year.util";
import { fillDefaultReportDateValue } from "@shared/utils/entity/deafultValues.util";
import { Klass } from "./Klass.entity";
import { Lesson } from "./Lesson.entity";
import { KlassType } from "./KlassType.entity";
import { Teacher } from "./Teacher.entity";
import { AbsenceType } from "./AbsenceType.entity";
import { BooleanType, DateType, NumberType, StringType } from "@shared/utils/entity/class-transformer";
import { LessonKlassName } from "../view-entities/LessonKlassName.entity";
import { CreatedAtColumn, UpdatedAtColumn } from "@shared/utils/entity/column-types.util";
import { FileData } from "@shared/entities/Image.entity";

@Index("known_users_idx", ["userId"], {})
@Index(['studentReferenceId', 'year'])
@Index('known_absences_lookup_idx', ['userId', 'year', 'isApproved', 'studentReferenceId'])
@Entity('known_absences')
Expand Down Expand Up @@ -176,6 +177,9 @@ export class KnownAbsence implements IHasUserId {
@Column('int', { name: 'absence_type_id', nullable: true })
absenceTypeId: number | null;

@Column(() => FileData)
fileData: FileData;

@CreatedAtColumn()
createdAt: Date;

Expand Down Expand Up @@ -204,4 +208,4 @@ export class KnownAbsence implements IHasUserId {
@ManyToOne(() => AbsenceType, { createForeignKeyConstraints: false })
@JoinColumn({ name: 'absence_type_id' })
absenceType: AbsenceType;
}
}
27 changes: 27 additions & 0 deletions server/src/migrations/1780311399994-addFileToKnownAbsence.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
import { MigrationInterface, QueryRunner } from "typeorm";

export class addFileToKnownAbsence1780311399994 implements MigrationInterface {
name = 'addFileToKnownAbsence1780311399994'

public async up(queryRunner: QueryRunner): Promise<void> {
await queryRunner.query(`
ALTER TABLE \`known_absences\`
ADD \`fileDataSrc\` mediumtext NOT NULL
`);
await queryRunner.query(`
ALTER TABLE \`known_absences\`
ADD \`fileDataTitle\` text NOT NULL
`);
}

public async down(queryRunner: QueryRunner): Promise<void> {
await queryRunner.query(`
ALTER TABLE \`known_absences\` DROP COLUMN \`fileDataTitle\`
`);
await queryRunner.query(`
ALTER TABLE \`known_absences\` DROP COLUMN \`fileDataSrc\`
`);

}

}
22 changes: 22 additions & 0 deletions server/src/migrations/1780316945862-AddFileRequiredColumn.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import { MigrationInterface, QueryRunner } from "typeorm";

export class AddFileRequiredColumn1780316945862 implements MigrationInterface {
name = 'AddFileRequiredColumn1780316945862'

public async up(queryRunner: QueryRunner): Promise<void> {

await queryRunner.query(`
ALTER TABLE \`absenceTypes\`
ADD \`is_file_required\` tinyint NOT NULL DEFAULT 0
`);
}

public async down(queryRunner: QueryRunner): Promise<void> {
await queryRunner.query(`
ALTER TABLE \`absenceTypes\` DROP COLUMN \`is_file_required\`
`);


}

}
Loading