Skip to content

Commit

Permalink
Simplify showing the delete button
Browse files Browse the repository at this point in the history
  • Loading branch information
AndrewKostka committed Jan 16, 2024
1 parent 3f24b32 commit 9a7fd67
Showing 1 changed file with 7 additions and 12 deletions.
19 changes: 7 additions & 12 deletions src/components/Pages/ManageWiki/Cards/QuestyCaptcha.vue
Original file line number Diff line number Diff line change
Expand Up @@ -29,14 +29,14 @@
v-model="entry.question"
outlined
hide-details="auto"
:append-outer-icon="showIcon ? 'mdi-delete-outline' : undefined"
:append-outer-icon="showDeleteButton ? 'mdi-delete-outline' : undefined"
:rules="[() => !!entry.question || 'Field cannot be empty. Please provide a question.']"
@click:append-outer="removeQuestion(index)"
dense
></v-text-field>
Answer
<v-combobox
:class="{'answer-box': true, 'answer-input-field': applyStyling}"
:class="{'answer-box': true, 'answer-input-field': showDeleteButton}"
v-model="entry.answers"
:items="entry.answers"
multiple
Expand Down Expand Up @@ -115,11 +115,14 @@ export default {
errorMessage: false,
captchaActivate: false,
questionsFromStore: [],
showIcon: true,
applyStyling: true,
panel: false
}
},
computed: {
showDeleteButton: function () {
return this.questionsFromStore.length > 1
}
},
created () {
this.questionsFromStore = this.$store.state.wikis.currentWikiSettings.captchaQuestions
this.captchaActivate = this.$store.state.wikis.currentWikiSettings.wwUseQuestyCaptcha
Expand All @@ -133,20 +136,12 @@ export default {
},
removeQuestion (index) {
this.questionsFromStore.splice(index, 1)
// hide trash icon when there is just one QA bundle
if (this.questionsFromStore.length === 1) {
this.showIcon = false
this.applyStyling = false
}
},
addQuestion () {
this.questionsFromStore.push({
question: '',
answers: []
})
// show the trash icon again when there are more than one QA bundle
this.showIcon = true
this.applyStyling = true
},
saveForm () {
for (let i = 0; i < this.questionsFromStore.length; i++) {
Expand Down

0 comments on commit 9a7fd67

Please sign in to comment.