fix: foreignKey violation bij delete assignment gefixd
This commit is contained in:
parent
7823c45851
commit
219616f4ee
3 changed files with 14 additions and 10 deletions
|
@ -1,4 +1,4 @@
|
|||
import {Cascade, Collection, Entity, ManyToMany, ManyToOne, PrimaryKey} from '@mikro-orm/core';
|
||||
import { Collection, Entity, ManyToMany, ManyToOne, PrimaryKey} from '@mikro-orm/core';
|
||||
import { Assignment } from './assignment.entity.js';
|
||||
import { Student } from '../users/student.entity.js';
|
||||
import { GroupRepository } from '../../data/assignments/group-repository.js';
|
||||
|
@ -24,7 +24,6 @@ export class Group {
|
|||
entity: () => Student,
|
||||
owner: true,
|
||||
inversedBy: 'groups',
|
||||
cascade: [Cascade.ALL],
|
||||
})
|
||||
members: Collection<Student> = new Collection<Student>(this);
|
||||
}
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
import { Student } from '../users/student.entity.js';
|
||||
import { Group } from './group.entity.js';
|
||||
import { Entity, Enum, ManyToOne, PrimaryKey, Property } from '@mikro-orm/core';
|
||||
import { Entity, Enum, ManyToOne, PrimaryKey, Property, Cascade } from '@mikro-orm/core';
|
||||
import { SubmissionRepository } from '../../data/assignments/submission-repository.js';
|
||||
import { Language } from '@dwengo-1/common/util/language';
|
||||
|
||||
|
@ -21,8 +21,8 @@ export class Submission {
|
|||
@PrimaryKey({ type: 'numeric', autoincrement: false })
|
||||
learningObjectVersion = 1;
|
||||
|
||||
@ManyToOne({
|
||||
entity: () => Group,
|
||||
@ManyToOne(() => Group, {
|
||||
cascade: [Cascade.REMOVE],
|
||||
})
|
||||
onBehalfOf!: Group;
|
||||
|
||||
|
|
|
@ -75,12 +75,17 @@
|
|||
const { valid } = await form.value.validate();
|
||||
if (!valid) return;
|
||||
|
||||
let lp = selectedLearningPath.value;
|
||||
if (!lpIsSelected) {
|
||||
lp = selectedLearningPath.value?.hruid;
|
||||
}
|
||||
|
||||
const assignmentDTO: AssignmentDTO = {
|
||||
id: 0,
|
||||
within: selectedClass.value?.id || "",
|
||||
title: assignmentTitle.value,
|
||||
description: description.value,
|
||||
learningPath: selectedLearningPath.value?.hruid || "",
|
||||
learningPath: lp || "",
|
||||
language: language.value,
|
||||
groups: groups.value,
|
||||
};
|
||||
|
@ -188,14 +193,14 @@
|
|||
color="secondary"
|
||||
type="submit"
|
||||
block
|
||||
>{{ t("submit") }}</v-btn
|
||||
>
|
||||
>{{ t("submit") }}
|
||||
</v-btn>
|
||||
<v-btn
|
||||
to="/user/assignment"
|
||||
color="grey"
|
||||
block
|
||||
>{{ t("cancel") }}</v-btn
|
||||
>
|
||||
>{{ t("cancel") }}
|
||||
</v-btn>
|
||||
</v-card-text>
|
||||
</v-container>
|
||||
</v-form>
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue