Skip to content

Commit 0ffc2ea

Browse files
committed
Scale value constraints
1 parent 7149cdf commit 0ffc2ea

File tree

2 files changed

+14
-16
lines changed

2 files changed

+14
-16
lines changed

examples/questionnaire/Example.vue

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -96,8 +96,7 @@
9696
subtitle: '1 - Awful, 5 - So, so, 10 - Excellent',
9797
type: QuestionType.IconRate,
9898
required: true,
99-
min: 1,
100-
max: 5,
99+
101100
}),
102101
new QuestionModel({
103102
id: 'opinion_scale_num',
@@ -106,8 +105,7 @@
106105
subtitle: '1 - Awful, 5 - So, so, 10 - Excellent',
107106
type: QuestionType.OpinionScale,
108107
required: true,
109-
min: 1,
110-
max: 10,
108+
maxSize: -3
111109
}),
112110
new QuestionModel({
113111
id: 'first_name',

src/components/QuestionTypes/OpinionScaleType.vue

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,12 @@
1313
<span v-if="option.choiceLabel()" class="f-label">{{ option.choiceLabel() }}</span>
1414
</div>
1515
<div v-else-if="isIconScale" class="f-icon-wrap">
16-
<div class="f-icon">
17-
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24">
18-
<path d="M12 .587l3.668 7.568 8.332 1.151-6.064 5.828 1.48 8.279-7.416-3.967-7.417 3.967 1.481-8.279-6.064-5.828 8.332-1.151z" stroke-width=".5"/>
19-
</svg>
20-
</div>
21-
<div class="f-key">{{ getToggleKey(option.value) }}</div>
16+
<div class="f-icon">
17+
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24">
18+
<path d="M12 .587l3.668 7.568 8.332 1.151-6.064 5.828 1.48 8.279-7.416-3.967-7.417 3.967 1.481-8.279-6.064-5.828 8.332-1.151z" stroke-width=".5"/>
19+
</svg>
20+
</div>
21+
<div class="f-key">{{ getToggleKey(option.value) }}</div>
2222
</div>
2323
</li>
2424
</ul>
@@ -47,12 +47,12 @@
4747
},
4848
4949
beforeMount() {
50-
if (this.question.max && !this.question.options.length) {
51-
const
52-
min = this.question.min || 1,
53-
max = this.question.max
54-
55-
for (let i = min; i <= max; i++) {
50+
const
51+
size = this.question.maxSize ?? 5,
52+
numOptions = Math.min(Math.max(size, 1), 10)
53+
54+
if (!this.question.options.length) {
55+
for (let i = 1; i <= numOptions; i++) {
5656
this.question.options.push(new ChoiceOption({value: i.toString()}))
5757
}
5858
}

0 commit comments

Comments
 (0)