Skip to content

Commit

Permalink
Merge pull request #441 from LostSputnik/bugfix/deleting-wrong-option…
Browse files Browse the repository at this point in the history
…-in-heuristic-test

Issue #435: deleting wrong option in heuristic test
  • Loading branch information
jvJUCA authored Apr 17, 2024
2 parents fb1731a + 90cd639 commit 76758e6
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/components/molecules/OptionsTable.vue
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,7 @@ export default {
},
updateOptions() {
if (this.editIndex == -1) {
this.option.timestamp = Date.now() // using the current timestamp as a unique identifier
this.options.push(this.option)
} else {
Object.assign(this.options[this.editIndex], this.option)
Expand All @@ -141,10 +142,13 @@ export default {
this.hasValue = true
},
deleteItem(item) {
this.options.splice(this.options.indexOf(item), 1)
const index = this.options.findIndex((option) => option.timestamp === item.timestamp)
if (index !== -1) {
this.options.splice(index, 1)
}
},
editItem(item) {
this.editIndex = this.options.indexOf(item)
this.editIndex = this.options.findIndex((option) => option.timestamp === item.timestamp)
this.option.text = this.options[this.editIndex].text
this.option.value = this.options[this.editIndex].value
Expand Down

0 comments on commit 76758e6

Please sign in to comment.