Skip to content

Commit

Permalink
fix(test_heuristic): fixed add description to heuristic question
Browse files Browse the repository at this point in the history
  • Loading branch information
KarinePistili committed Mar 21, 2024
1 parent 150aa9f commit e5e67fb
Show file tree
Hide file tree
Showing 3 changed files with 50 additions and 28 deletions.
28 changes: 17 additions & 11 deletions src/components/atoms/AddDescBtn.vue
Original file line number Diff line number Diff line change
Expand Up @@ -85,9 +85,15 @@ export default {
TextBox,
},
props: {
question: {
type: Object,
questionIndex: {
type: Number,
required: true,
default: 0,
},
heuristicIndex: {
type: Number,
required: true,
default: 0,
},
},
data: () => ({
Expand All @@ -101,6 +107,9 @@ export default {
isMounted: false,
}),
computed: {
question() {
return this.$store.state.Tests.Test.testStructure[this.heuristicIndex].questions[this.questionIndex]
},
testAnswerDocLength() {
if(!this.$store.getters.testAnswerDocument) {
return 0
Expand All @@ -116,17 +125,14 @@ export default {
validate() {
const valid = this.$refs.form.validate()
if (valid && this.desc.text.length > 0) {
if (this.editIndex == null) this.question.descriptions.push(this.desc)
// this.question.descriptions[this.editIndex] = Object.assign({}, this.desc);
else
this.$set(
this.question.descriptions,
this.editIndex,
Object.assign({}, this.desc),
)
this.$store.commit('setupHeuristicQuestionDescription', {
heuristic: this.heuristicIndex,
question: this.questionIndex,
description: this.desc,
editIndex: this.editIndex,
})
this.reset()
this.$emit('change')
} else if (valid && this.desc.text.length == 0) {
Vue.$toast.info(i18n.t('alerts.addDescription'))
}
Expand Down
31 changes: 17 additions & 14 deletions src/components/molecules/HeuristicsTable.vue
Original file line number Diff line number Diff line change
Expand Up @@ -327,9 +327,8 @@
<v-row justify="end" class="ma-0 pa-0">
<AddDescBtn
ref="descBtn"
:question="
heuristics[itemSelect].questions[questionSelect]
"
:question-index="questionSelect"
:heuristic-index="itemSelect"
/>
</v-row>
</v-col>
Expand Down Expand Up @@ -475,7 +474,7 @@
height="350px"
:headers="headers"
:items="
heuristics[itemSelect].questions[questionSelect].questions
heuristics[itemSelect].questions[questionSelect].descriptions
"
:items-per-page="5"
>
Expand All @@ -490,9 +489,8 @@
<v-row justify="end" class="ma-0 pa-0">
<AddDescBtn
ref="descBtn"
:question="
heuristics[itemSelect].questions[questionSelect]
"
:question-index="questionSelect"
:heuristic-index="itemSelect"
/>
</v-row>
</v-col>
Expand All @@ -503,7 +501,8 @@
<template v-slot:item.actions="{ item }">
<!-- table actions -->
<v-row justify="end" class="pr-1">
<v-btn
<!-- TODO: Uncomment and fix reactivity -->
<!-- <v-btn
icon
small
class="mr-2"
Expand All @@ -512,7 +511,7 @@
<v-icon small>
mdi-pencil
</v-icon>
</v-btn>
</v-btn> -->
<v-btn icon small @click="deleteItem(item)">
<v-icon small>
mdi-delete
Expand Down Expand Up @@ -596,8 +595,8 @@ export default {
csvHeuristics() {
return this.$store.state.Tests.Test.testStructure
},
filteredHeuristics(){
if (this.search === '') {
filteredHeuristics() {
if (this.search === '') {
return this.heuristics.filter((item) => {
const searchLower = this.search.toLowerCase()
const idString = item.id.toString()
Expand Down Expand Up @@ -696,7 +695,9 @@ export default {
this.loader = null
} else {
setTimeout(() => (this[l] = false), 3000)
Vue.$toast.warning('No csv file selected. \nPlease select one before procede.')
Vue.$toast.warning(
'No csv file selected. \nPlease select one before procede.',
)
this.loader = null
}
},
Expand Down Expand Up @@ -776,7 +777,7 @@ export default {
)
if (config) {
this.$store.dispatch('removeHeuristic', item)
this.$store.commit('removeHeuristic', item)
this.itemSelect = null
this.questionSelect = null
}
Expand All @@ -800,7 +801,9 @@ export default {
].questions.length
}
} else {
Vue.$toast.warning('Sorry, but you can\'t delete all heuristics questions')
Vue.$toast.warning(
'Sorry, but you can\'t delete all heuristics questions',
)
}
this.menuQuestions = false
Expand Down
19 changes: 16 additions & 3 deletions src/store/modules/Test.js
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,22 @@ export default {
state.participantCamera = ''
state.finalMessage = ''
},
removeHeuristic(state, payload) {
state.Test.testStructure.splice(payload, 1)
},
setupHeuristicQuestionDescription(state, payload) {
// If empty
if (state.Test.testStructure[payload.heuristic].questions[payload.question].descriptions == null) state.Test.testStructure[payload.heuristic].questions[payload.question].descriptions = []

// If is editing
if (payload.editIndex != null) {
state.Test.testStructure[payload.heuristic].questions[payload.question].descriptions[payload.editIndex] = Object.assign({}, payload.description)
}
// New Description
else {
state.Test.testStructure[payload.heuristic].questions[payload.question].descriptions.push(payload.description)
}
},
},
actions: {
/**
Expand Down Expand Up @@ -430,8 +446,5 @@ export default {
managerIDs(state) {
return state.managerIDs
},
removeHeuristic({ state }, payload) {
state.Test.testStructure.splice(payload, 1)
}
},
}

0 comments on commit e5e67fb

Please sign in to comment.