AccompanyingCourseWorkEdit: fix bug, remove goal one by one

(adding a temporary negative index on just created goals)
This commit is contained in:
Mathieu Jaumotte 2021-12-20 12:52:29 +01:00
parent c7e992fd1a
commit 6a4d7fbece
3 changed files with 12 additions and 7 deletions

View File

@ -7,7 +7,7 @@ and this project adheres to
* [Semantic Versioning](https://semver.org/spec/v2.0.0.html) for stable releases;
* date versioning for test releases
* [accompanyingCourse_work] fix styles conflicts
* [accompanyingCourse_work] fix styles conflicts + fix bug with remove goal (remove goals one at a time)
## Unreleased

View File

@ -50,7 +50,7 @@
</div>
<!-- results which **are** attached to an objective -->
<div v-for="g in goalsPicked" :key="g.id">
<div v-for="g in goalsPicked" :key="g.goal.id">
<div class="item-title" @click="removeGoal(g)">
<span class="removable">{{ g.goal.title.fr }}</span>
</div>
@ -428,11 +428,9 @@ export default {
this.isExpanded = !this.isExpanded;
},
addGoal(g) {
this.$store.commit('addGoal', g);
},
removeGoal(g) {
this.$store.commit('removeGoal', g);
},
addEvaluation(e) {

View File

@ -164,7 +164,14 @@ const store = createStore({
note: '',
results: []
}
const tmpIndex = () => {
let ar = state.goalsPicked.map(g => g.id),
s = Math.min(...ar);
return (s < 0) ? s : 0
};
g.id = tmpIndex() -1
state.goalsPicked.push(g);
//console.log('goals picked ids', state.goalsPicked.map(g => g.id))
},
removeGoal(state, goal) {
state.goalsPicked = state.goalsPicked.filter(g => g.id !== goal.id);