diff --git a/src/components/atoms/AddDescBtn.vue b/src/components/atoms/AddDescBtn.vue index 75e4b70bb..68d632295 100644 --- a/src/components/atoms/AddDescBtn.vue +++ b/src/components/atoms/AddDescBtn.vue @@ -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: () => ({ @@ -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 @@ -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')) } diff --git a/src/components/molecules/HeuristicsTable.vue b/src/components/molecules/HeuristicsTable.vue index 82e45f8f1..cf9d7edc5 100644 --- a/src/components/molecules/HeuristicsTable.vue +++ b/src/components/molecules/HeuristicsTable.vue @@ -151,13 +151,13 @@ @click="dialogHeuris = true" > - + mdi-plus {{ @@ -327,10 +327,8 @@ @@ -476,7 +474,7 @@ height="350px" :headers="headers" :items=" - heuristics[itemSelect].questions[questionSelect].questions + heuristics[itemSelect].questions[questionSelect].descriptions " :items-per-page="5" > @@ -491,9 +489,8 @@ @@ -504,7 +501,8 @@ @@ -47,10 +47,11 @@ export default { type: Object, default: () => { }, }, + index: { + type: Number, + default: 0, + }, }, - data: () => ({ - index: 0, - }), computed: { currentTest() { return this.$store.state.Tests.Test.testStructure @@ -58,12 +59,8 @@ export default { }, methods: { tabClicked(index) { - this.index = index - }, - emitChange() { - this.$emit('change') + this.$emit('tabClicked', index) }, - }, } diff --git a/src/store/modules/Test.js b/src/store/modules/Test.js index ca1a3bb63..9e234fb76 100644 --- a/src/store/modules/Test.js +++ b/src/store/modules/Test.js @@ -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: { /** diff --git a/src/views/admin/EditTestView.vue b/src/views/admin/EditTestView.vue index f266562f0..10a4cc83c 100644 --- a/src/views/admin/EditTestView.vue +++ b/src/views/admin/EditTestView.vue @@ -93,7 +93,7 @@ type="content" :object="object" :index="index" - @change="change = true" + @tabClicked="setIndex" /> @@ -102,7 +102,6 @@ slot="top" type="tabs" @tabClicked="setIndex" - @change="change = true" />