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; * [Semantic Versioning](https://semver.org/spec/v2.0.0.html) for stable releases;
* date versioning for test 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 ## Unreleased

View File

@ -50,10 +50,10 @@
</div> </div>
<!-- results which **are** attached to an objective --> <!-- 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)"> <div class="item-title" @click="removeGoal(g)">
<span class="removable">{{ g.goal.title.fr }}</span> <span class="removable">{{ g.goal.title.fr }}</span>
</div> </div>
<div> <div>
<add-result :goal="g.goal" destination="goal"></add-result> <add-result :goal="g.goal" destination="goal"></add-result>
</div> </div>
@ -428,11 +428,9 @@ export default {
this.isExpanded = !this.isExpanded; this.isExpanded = !this.isExpanded;
}, },
addGoal(g) { addGoal(g) {
this.$store.commit('addGoal', g); this.$store.commit('addGoal', g);
}, },
removeGoal(g) { removeGoal(g) {
this.$store.commit('removeGoal', g); this.$store.commit('removeGoal', g);
}, },
addEvaluation(e) { addEvaluation(e) {

View File

@ -164,7 +164,14 @@ const store = createStore({
note: '', note: '',
results: [] 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); state.goalsPicked.push(g);
//console.log('goals picked ids', state.goalsPicked.map(g => g.id))
}, },
removeGoal(state, goal) { removeGoal(state, goal) {
state.goalsPicked = state.goalsPicked.filter(g => g.id !== goal.id); state.goalsPicked = state.goalsPicked.filter(g => g.id !== goal.id);