From 150aa9f674d91b011604065cd9f1a1c149f883f6 Mon Sep 17 00:00:00 2001 From: karine Date: Thu, 21 Mar 2024 17:14:20 -0300 Subject: [PATCH 1/2] fix(heuristic_test): fixed behaviour of state changes on heuristic tabs --- src/components/molecules/HeuristicsTable.vue | 73 ++++++++----------- .../organisms/EditHeuristicsTest.vue | 21 +++--- src/store/modules/Test.js | 3 + src/views/admin/EditTestView.vue | 4 +- 4 files changed, 42 insertions(+), 59 deletions(-) diff --git a/src/components/molecules/HeuristicsTable.vue b/src/components/molecules/HeuristicsTable.vue index 82e45f8f1..a57ef78de 100644 --- a/src/components/molecules/HeuristicsTable.vue +++ b/src/components/molecules/HeuristicsTable.vue @@ -151,13 +151,13 @@ @click="dialogHeuris = true" > - + mdi-plus {{ @@ -330,7 +330,6 @@ :question=" heuristics[itemSelect].questions[questionSelect] " - @change="emitChange" /> @@ -572,7 +571,6 @@ export default { heuristicForm: null, search: '', searchBar: false, - filteredHeuristics: [], headers: [ { text: 'Title', @@ -598,6 +596,31 @@ export default { csvHeuristics() { return this.$store.state.Tests.Test.testStructure }, + filteredHeuristics(){ + if (this.search === '') { + return this.heuristics.filter((item) => { + const searchLower = this.search.toLowerCase() + const idString = item.id.toString() + + return ( + item.title.toLowerCase().includes(searchLower) || + idString.includes(searchLower) || + idString === searchLower + ) + }) + } else { + return this.heuristics.filter((item) => { + const searchLower = this.search.toLowerCase() + const idString = item.id.toString() + + return ( + item.title.toLowerCase().includes(searchLower) || + idString.includes(searchLower) || + idString === searchLower + ) + }) + } + }, heuristics() { return this.$store.state.Tests.Test.testStructure ? this.$store.state.Tests.Test.testStructure @@ -630,9 +653,6 @@ export default { }, }, watch: { - search() { - this.updateFilteredHeuristics() - }, dialogHeuris() { if (!this.dialogHeuris && this.heuristics.length > 0 && !this.itemEdit) { this.heuristicForm = { @@ -657,7 +677,7 @@ export default { this.$refs.formHeuris.reset() } } - this.updateFilteredHeuristics() + // this.updateFilteredHeuristics() }, itemSelect() { if (this.itemSelect !== null) this.questionSelect = null @@ -681,11 +701,7 @@ export default { } }, }, - mounted() { - this.updateFilteredHeuristics() - }, async created() { - await this.$store.dispatch('getTest', { id: this.$route.params.id }) if (this.heuristics.length) { this.heuristicForm = { id: this.heuristics[this.heuristics.length - 1].id + 1, @@ -718,10 +734,6 @@ export default { this.heuristicForm.total = this.heuristicForm.questions.length }, methods: { - emitChange() { - this.$emit('change') - this.$forceUpdate() - }, moveItemUp(index) { if (index > 0) { const itemToMove = this.filteredHeuristics[index] @@ -758,40 +770,13 @@ export default { itemBelow.id = index } }, - updateFilteredHeuristics() { - if (this.search === '') { - this.searchBar = false - this.filteredHeuristics = this.heuristics.filter((item) => { - const searchLower = this.search.toLowerCase() - const idString = item.id.toString() - - return ( - item.title.toLowerCase().includes(searchLower) || - idString.includes(searchLower) || - idString === searchLower - ) - }) - } else { - this.searchBar = true - this.filteredHeuristics = this.heuristics.filter((item) => { - const searchLower = this.search.toLowerCase() - const idString = item.id.toString() - - return ( - item.title.toLowerCase().includes(searchLower) || - idString.includes(searchLower) || - idString === searchLower - ) - }) - } - }, deleteHeuristic(item) { const config = confirm( `${i18n.t('alerts.deleteHeuristic')} ${this.heuristics[item].title}?`, ) if (config) { - this.heuristics.splice(item, 1) + this.$store.dispatch('removeHeuristic', item) this.itemSelect = null this.questionSelect = null } diff --git a/src/components/organisms/EditHeuristicsTest.vue b/src/components/organisms/EditHeuristicsTest.vue index aace8de51..7ee123211 100644 --- a/src/components/organisms/EditHeuristicsTest.vue +++ b/src/components/organisms/EditHeuristicsTest.vue @@ -16,10 +16,10 @@
- - - - + + + +
@@ -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..b40180f7c 100644 --- a/src/store/modules/Test.js +++ b/src/store/modules/Test.js @@ -430,5 +430,8 @@ export default { managerIDs(state) { return state.managerIDs }, + removeHeuristic({ state }, payload) { + state.Test.testStructure.splice(payload, 1) + } }, } 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" /> From e5e67fb2d6403b4a00bf01b0f1ba233748d3136d Mon Sep 17 00:00:00 2001 From: karine Date: Thu, 21 Mar 2024 17:41:30 -0300 Subject: [PATCH 2/2] fix(test_heuristic): fixed add description to heuristic question --- src/components/atoms/AddDescBtn.vue | 28 +++++++++++------- src/components/molecules/HeuristicsTable.vue | 31 +++++++++++--------- src/store/modules/Test.js | 19 ++++++++++-- 3 files changed, 50 insertions(+), 28 deletions(-) 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 a57ef78de..cf9d7edc5 100644 --- a/src/components/molecules/HeuristicsTable.vue +++ b/src/components/molecules/HeuristicsTable.vue @@ -327,9 +327,8 @@ @@ -475,7 +474,7 @@ height="350px" :headers="headers" :items=" - heuristics[itemSelect].questions[questionSelect].questions + heuristics[itemSelect].questions[questionSelect].descriptions " :items-per-page="5" > @@ -490,9 +489,8 @@ @@ -503,7 +501,8 @@