fix: assignment verwijderen gefixd
This commit is contained in:
parent
fac31b3f64
commit
a963cf472c
2 changed files with 14 additions and 16 deletions
|
@ -1,8 +1,8 @@
|
|||
import { Collection, Entity, Enum, ManyToOne, OneToMany, PrimaryKey, Property } from '@mikro-orm/core';
|
||||
import { Class } from '../classes/class.entity.js';
|
||||
import { Group } from './group.entity.js';
|
||||
import { Language } from '@dwengo-1/common/util/language';
|
||||
import { AssignmentRepository } from '../../data/assignments/assignment-repository.js';
|
||||
import {Cascade, Collection, Entity, Enum, ManyToOne, OneToMany, PrimaryKey, Property} from '@mikro-orm/core';
|
||||
import {Class} from '../classes/class.entity.js';
|
||||
import {Group} from './group.entity.js';
|
||||
import {Language} from '@dwengo-1/common/util/language';
|
||||
import {AssignmentRepository} from '../../data/assignments/assignment-repository.js';
|
||||
|
||||
@Entity({
|
||||
repository: () => AssignmentRepository,
|
||||
|
@ -34,6 +34,7 @@ export class Assignment {
|
|||
@OneToMany({
|
||||
entity: () => Group,
|
||||
mappedBy: 'assignment',
|
||||
cascade: [Cascade.ALL]
|
||||
})
|
||||
groups: Collection<Group> = new Collection<Group>(this);
|
||||
}
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
<script setup lang="ts">
|
||||
import { ref, computed, onMounted, watch } from "vue";
|
||||
import { ref, computed, onMounted } from "vue";
|
||||
import { useI18n } from "vue-i18n";
|
||||
import { useRouter } from "vue-router";
|
||||
import auth from "@/services/auth/auth-service.ts";
|
||||
|
@ -30,6 +30,7 @@
|
|||
//TODO: remove later
|
||||
const classController = new ClassController();
|
||||
|
||||
const deletedAssignments = ref<Set<number>>(new Set());
|
||||
//TODO: replace by query that fetches all user's assignment
|
||||
const assignments = asyncComputed(async () => {
|
||||
const classes = classesQueryResults?.data?.value?.classes;
|
||||
|
@ -49,7 +50,7 @@
|
|||
}),
|
||||
);
|
||||
|
||||
return result.flat();
|
||||
return result.flat().filter(a => !deletedAssignments.value.has(a.id));
|
||||
}, []);
|
||||
|
||||
async function goToCreateAssignment(): Promise<void> {
|
||||
|
@ -60,17 +61,13 @@
|
|||
await router.push(`/assignment/${clsId}/${id}`);
|
||||
}
|
||||
|
||||
const { mutate, isSuccess } = useDeleteAssignmentMutation();
|
||||
watch(isSuccess, async (success) => {
|
||||
if (success) {
|
||||
await router.push("/user/assignment");
|
||||
}
|
||||
});
|
||||
const { mutate } = useDeleteAssignmentMutation();
|
||||
|
||||
async function goToDeleteAssignment(num: number, clsId: string): Promise<void> {
|
||||
mutate({
|
||||
cid: clsId,
|
||||
an: num,
|
||||
mutate({ cid: clsId, an: num }, {
|
||||
onSuccess: () => {
|
||||
deletedAssignments.value.add(num);
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue