Skip to content

Commit e8033ed

Browse files
authored
Merge pull request #138 from ditdot-dev/feature/no-ok-button
Feature/no ok button
2 parents 7b9f0e8 + a903f54 commit e8033ed

File tree

7 files changed

+32
-3
lines changed

7 files changed

+32
-3
lines changed

examples/questionnaire/Example.vue

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,7 @@
126126
multiple: false,
127127
allowOther: true,
128128
required: true,
129+
nextStepOnAnswer: true,
129130
options: [
130131
new ChoiceOption({
131132
label: 'Answer 1'

examples/quiz/Example.vue

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -145,6 +145,7 @@
145145
type: QuestionType.MultipleChoice,
146146
required: true,
147147
multiple: false,
148+
nextStepOnAnswer: true,
148149
options: [
149150
new ChoiceOption({
150151
label: 'True',
@@ -163,6 +164,7 @@
163164
type: QuestionType.MultipleChoice,
164165
required: true,
165166
multiple: false,
167+
nextStepOnAnswer: true,
166168
options: [
167169
new ChoiceOption({
168170
label: '<form>',
@@ -246,6 +248,7 @@
246248
type: QuestionType.MultipleChoice,
247249
multiple: false,
248250
required: true,
251+
nextStepOnAnswer: true,
249252
options: [
250253
new ChoiceOption({
251254
label: 'True',
@@ -264,6 +267,7 @@
264267
multiple: false,
265268
helpText: 'Select one correct answer.',
266269
required: true,
270+
nextStepOnAnswer: true,
267271
options: [
268272
new ChoiceOption({
269273
label: 'Add progress bar to the form',
@@ -290,6 +294,7 @@
290294
type: QuestionType.MultipleChoice,
291295
multiple: false,
292296
required: true,
297+
nextStepOnAnswer: true,
293298
options: [
294299
new ChoiceOption({
295300
label: 'True',

src/assets/css/common.css

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -584,7 +584,7 @@ header.vff-header svg.f-logo {
584584
}
585585

586586
.vff ul.f-radios li {
587-
padding: .58em .68em;
587+
padding: .6em .68em;
588588
margin: .5em 0 .6em;
589589
font-weight: 300;
590590
line-height: 1.24;

src/components/Question.vue

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -220,6 +220,14 @@
220220
return this.active
221221
}
222222
223+
if (this.question.allowOther && this.question.other) {
224+
return true
225+
}
226+
227+
if (QuestionType.MultipleChoice && !this.question.multiple && this.question.nextStepOnAnswer) {
228+
return false
229+
}
230+
223231
if (!q || !this.dataValue) {
224232
return false
225233
}

src/components/QuestionTypes/BaseType.vue

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131
allowedChars: null,
3232
alwaysAllowedKeys: ['ArrowLeft', 'ArrowRight', 'Delete', 'Backspace'],
3333
focused: false,
34-
canReceiveFocus: false,
34+
canReceiveFocus: false
3535
}
3636
},
3737
mounted() {
@@ -166,6 +166,11 @@
166166
return v.trim().length > 0
167167
}
168168
169+
if (Array.isArray(v)) {
170+
// Don't allow empty arrays
171+
return v.length > 0
172+
}
173+
169174
// All other non-null values are allowed to pass through
170175
return true
171176
}

src/components/QuestionTypes/MultipleChoiceType.vue

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,21 +54,25 @@
5454
export default {
5555
extends: BaseType,
5656
name: QuestionType.MultipleChoice,
57+
5758
data() {
5859
return {
5960
editingOther: false
6061
}
6162
},
63+
6264
mounted() {
6365
if (this.question.multiple) {
6466
this.dataValue = []
6567
}
6668
6769
this.addKeyListener()
6870
},
71+
6972
beforeDestroy() {
7073
this.removeKeyListener()
7174
},
75+
7276
watch: {
7377
active(value) {
7478
if (value) {
@@ -82,6 +86,7 @@
8286
}
8387
}
8488
},
89+
8590
methods: {
8691
addKeyListener() {
8792
this.removeKeyListener()
@@ -162,8 +167,12 @@
162167
} else {
163168
this.dataValue = option.selected ? option.choiceValue() : null
164169
}
165-
170+
166171
this.setAnswer(this.dataValue)
172+
173+
if (this.isValid() && this.question.nextStepOnAnswer && !this.question.multiple) {
174+
setTimeout(() => this.$emit('next'), 350)
175+
}
167176
},
168177
169178
_removeAnswer(value) {

src/models/QuestionModel.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,7 @@ export default class QuestionModel {
9393
this.descriptionLink = []
9494
this.min = null
9595
this.max = null
96+
this.nextStepOnAnswer = false
9697

9798
Object.assign(this, options)
9899

0 commit comments

Comments
 (0)