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 { Assignment } from './assignment.entity.js'; | ||||||
| import { Student } from '../users/student.entity.js'; | import { Student } from '../users/student.entity.js'; | ||||||
| import { GroupRepository } from '../../data/assignments/group-repository.js'; | import { GroupRepository } from '../../data/assignments/group-repository.js'; | ||||||
|  | @ -24,7 +24,6 @@ export class Group { | ||||||
|         entity: () => Student, |         entity: () => Student, | ||||||
|         owner: true, |         owner: true, | ||||||
|         inversedBy: 'groups', |         inversedBy: 'groups', | ||||||
|         cascade: [Cascade.ALL], |  | ||||||
|     }) |     }) | ||||||
|     members: Collection<Student> = new Collection<Student>(this); |     members: Collection<Student> = new Collection<Student>(this); | ||||||
| } | } | ||||||
|  |  | ||||||
|  | @ -1,6 +1,6 @@ | ||||||
| import { Student } from '../users/student.entity.js'; | import { Student } from '../users/student.entity.js'; | ||||||
| import { Group } from './group.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 { SubmissionRepository } from '../../data/assignments/submission-repository.js'; | ||||||
| import { Language } from '@dwengo-1/common/util/language'; | import { Language } from '@dwengo-1/common/util/language'; | ||||||
| 
 | 
 | ||||||
|  | @ -21,8 +21,8 @@ export class Submission { | ||||||
|     @PrimaryKey({ type: 'numeric', autoincrement: false }) |     @PrimaryKey({ type: 'numeric', autoincrement: false }) | ||||||
|     learningObjectVersion = 1; |     learningObjectVersion = 1; | ||||||
| 
 | 
 | ||||||
|     @ManyToOne({ |     @ManyToOne(() => Group, { | ||||||
|         entity: () => Group, |         cascade: [Cascade.REMOVE], | ||||||
|     }) |     }) | ||||||
|     onBehalfOf!: Group; |     onBehalfOf!: Group; | ||||||
| 
 | 
 | ||||||
|  |  | ||||||
|  | @ -75,12 +75,17 @@ | ||||||
|         const { valid } = await form.value.validate(); |         const { valid } = await form.value.validate(); | ||||||
|         if (!valid) return; |         if (!valid) return; | ||||||
| 
 | 
 | ||||||
|  |         let lp = selectedLearningPath.value; | ||||||
|  |         if (!lpIsSelected) { | ||||||
|  |             lp = selectedLearningPath.value?.hruid; | ||||||
|  |         } | ||||||
|  | 
 | ||||||
|         const assignmentDTO: AssignmentDTO = { |         const assignmentDTO: AssignmentDTO = { | ||||||
|             id: 0, |             id: 0, | ||||||
|             within: selectedClass.value?.id || "", |             within: selectedClass.value?.id || "", | ||||||
|             title: assignmentTitle.value, |             title: assignmentTitle.value, | ||||||
|             description: description.value, |             description: description.value, | ||||||
|             learningPath: selectedLearningPath.value?.hruid || "", |             learningPath: lp || "", | ||||||
|             language: language.value, |             language: language.value, | ||||||
|             groups: groups.value, |             groups: groups.value, | ||||||
|         }; |         }; | ||||||
|  | @ -188,14 +193,14 @@ | ||||||
|                             color="secondary" |                             color="secondary" | ||||||
|                             type="submit" |                             type="submit" | ||||||
|                             block |                             block | ||||||
|                             >{{ t("submit") }}</v-btn |                             >{{ t("submit") }} | ||||||
|                         > |                         </v-btn> | ||||||
|                         <v-btn |                         <v-btn | ||||||
|                             to="/user/assignment" |                             to="/user/assignment" | ||||||
|                             color="grey" |                             color="grey" | ||||||
|                             block |                             block | ||||||
|                             >{{ t("cancel") }}</v-btn |                             >{{ t("cancel") }} | ||||||
|                         > |                         </v-btn> | ||||||
|                     </v-card-text> |                     </v-card-text> | ||||||
|                 </v-container> |                 </v-container> | ||||||
|             </v-form> |             </v-form> | ||||||
|  |  | ||||||
		Reference in a new issue
	
	 Joyelle Ndagijimana
						Joyelle Ndagijimana