fix(backend): Foreign constraint probleem bij het verwijderen van leerpaden opgelost
This commit is contained in:
parent
63cf60409f
commit
9400b7f33c
7 changed files with 20 additions and 16 deletions
|
@ -9,6 +9,7 @@ export class Attachment {
|
|||
@ManyToOne({
|
||||
entity: () => LearningObject,
|
||||
primary: true,
|
||||
deleteRule: 'cascade'
|
||||
})
|
||||
learningObject!: LearningObject;
|
||||
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
import {
|
||||
ArrayType,
|
||||
Cascade,
|
||||
Collection,
|
||||
Embedded,
|
||||
Entity,
|
||||
|
@ -93,8 +92,7 @@ export class LearningObject {
|
|||
|
||||
@OneToMany({
|
||||
entity: () => Attachment,
|
||||
mappedBy: 'learningObject',
|
||||
cascade: [Cascade.ALL]
|
||||
mappedBy: 'learningObject'
|
||||
})
|
||||
attachments: Collection<Attachment> = new Collection<Attachment>(this);
|
||||
|
||||
|
|
|
@ -72,8 +72,6 @@ const learningObjectService = {
|
|||
learningObject.hruid = getEnvVar(envVars.UserContentPrefix) + learningObject.hruid;
|
||||
}
|
||||
|
||||
await learningObjectRepository.getEntityManager().flush();
|
||||
|
||||
// Lookup the admin teachers based on their usernames and add them to the admins of the learning object.
|
||||
const teacherRepo = getTeacherRepository();
|
||||
const adminTeachers = await Promise.all(
|
||||
|
@ -85,7 +83,13 @@ const learningObjectService = {
|
|||
}
|
||||
});
|
||||
|
||||
await learningObjectRepository.save(learningObject, {preventOverwrite: true});
|
||||
try {
|
||||
await learningObjectRepository.save(learningObject, {preventOverwrite: true});
|
||||
} catch (e: unknown) {
|
||||
learningObjectRepository.getEntityManager().clear();
|
||||
throw e;
|
||||
}
|
||||
|
||||
return learningObject;
|
||||
},
|
||||
|
||||
|
|
0
frontend/src/components/ButtonWithConfirmation.vue
Normal file
0
frontend/src/components/ButtonWithConfirmation.vue
Normal file
|
@ -138,5 +138,6 @@
|
|||
"open": "open",
|
||||
"editLearningPath": "Edit learning path",
|
||||
"newLearningPath": "Create a new learning path",
|
||||
"saveChanges": "Save changes"
|
||||
"saveChanges": "Save changes",
|
||||
"newLearningObject": "Upload learning object"
|
||||
}
|
||||
|
|
|
@ -32,7 +32,13 @@
|
|||
<template>
|
||||
<v-dialog max-width="500" v-model="dialogOpen">
|
||||
<template v-slot:activator="{ props: activatorProps }">
|
||||
<v-fab icon="mdi mdi-plus" v-bind="activatorProps" color="rgb(14, 105, 66)" size="large"></v-fab>
|
||||
<v-btn
|
||||
prepend-icon="mdi mdi-plus"
|
||||
:text="t('newLearningObject')"
|
||||
v-bind="activatorProps"
|
||||
color="rgb(14, 105, 66)"
|
||||
size="large">
|
||||
</v-btn>
|
||||
</template>
|
||||
|
||||
<template v-slot:default="{ isActive }">
|
||||
|
|
|
@ -30,6 +30,7 @@
|
|||
<template>
|
||||
<div class="root">
|
||||
<div class="table-container">
|
||||
<learning-object-upload-button/>
|
||||
<v-data-table
|
||||
class="table"
|
||||
v-model="selectedLearningObjects"
|
||||
|
@ -44,17 +45,9 @@
|
|||
<learning-object-preview-card class="preview" :selectedLearningObject="selectedLearningObject"/>
|
||||
</div>
|
||||
</div>
|
||||
<div class="fab">
|
||||
<learning-object-upload-button/>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<style scoped>
|
||||
.fab {
|
||||
position: absolute;
|
||||
right: 20px;
|
||||
bottom: 20px;
|
||||
}
|
||||
.root {
|
||||
display: flex;
|
||||
gap: 20px;
|
||||
|
@ -73,5 +66,6 @@
|
|||
}
|
||||
.table {
|
||||
width: 100%;
|
||||
margin-top: 20px;
|
||||
}
|
||||
</style>
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue