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 @@
-
+
mdi-delete
@@ -572,7 +570,6 @@ export default {
heuristicForm: null,
search: '',
searchBar: false,
- filteredHeuristics: [],
headers: [
{
text: 'Title',
@@ -598,6 +595,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 +652,6 @@ export default {
},
},
watch: {
- search() {
- this.updateFilteredHeuristics()
- },
dialogHeuris() {
if (!this.dialogHeuris && this.heuristics.length > 0 && !this.itemEdit) {
this.heuristicForm = {
@@ -657,7 +676,7 @@ export default {
this.$refs.formHeuris.reset()
}
}
- this.updateFilteredHeuristics()
+ // this.updateFilteredHeuristics()
},
itemSelect() {
if (this.itemSelect !== null) this.questionSelect = null
@@ -676,16 +695,14 @@ 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
}
},
},
- 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 +735,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 +771,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.commit('removeHeuristic', item)
this.itemSelect = null
this.questionSelect = null
}
@@ -815,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
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..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"
/>