Skip to content
Snippets Groups Projects
Commit 4cce9316 authored by Julian's avatar Julian
Browse files

Allow updating of grades

parent 289404f4
No related branches found
No related tags found
1 merge request!2Frontend
<script>
import { createGrades } from "./grades.graphql";
import { createGrades, updateGrades } from "./grades.graphql";
import mutateMixin from "aleksis.core/mixins/mutateMixin.js";
export default {
......@@ -58,6 +58,31 @@ export default {
// TODO
if (this.value) {
// → Preexisting grade, edit mutation
this.mutate(
updateGrades,
{
input: [
{
id: this.value.id,
person: this.personId,
effort: this.effort.id,
grade: newValue,
},
],
},
(storedEfforts, incomingGrades) => {
const effort = storedEfforts.find(
(effort) => effort.id === this.effort.id,
);
incomingGrades.forEach((newGrade) => {
const index = effort.grades.findIndex(g => g.id === newGrade.id);
effort.grades[index].grade = newGrade.grade;
});
return storedEfforts;
},
);
} else {
// Create and return a grade object
this.mutate(
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment