|
4 | 4 | <li |
5 | 5 | v-for="(option, index) in question.options" |
6 | 6 | v-on:click.prevent="toggleAnswer(option)" |
7 | | - v-bind:class="{'f-selected': option.selected}" |
| 7 | + v-bind:class="{'f-selected': option.selected, 'f-previous': isPreviousOption(option)}" |
8 | 8 | v-bind:key="'m' + index" |
9 | 9 | v-bind:aria-label="getLabel(option.value)" |
10 | 10 | role="option" |
|
14 | 14 | </div> |
15 | 15 | <div v-else-if="isIconScale" class="f-icon-wrap"> |
16 | 16 | <div class="f-icon"> |
17 | | - <svg viewBox="0 0 58 47"><path class="symbolFill" d="M21 27.1L48.05.05l9.9 9.9L21 46.9.05 25.95l9.9-9.9z" fill-rule="nonzero"></path><path class="symbolOutline" d="M21 30.636L9.95 19.586 3.586 25.95 21 43.364 54.414 9.95 48.05 3.586 21 30.636zM48.05.05l9.9 9.9L21 46.9.05 25.95l9.9-9.9L21 27.1 48.05.05z" fill-rule="nonzero"></path></svg> |
| 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"/> |
| 19 | + </svg> |
18 | 20 | </div> |
19 | 21 | <div class="f-key">{{ getToggleKey(option.value) }}</div> |
20 | 22 | </div> |
|
39 | 41 |
|
40 | 42 | data() { |
41 | 43 | return { |
42 | | - isIconScale: false |
| 44 | + isIconScale: false, |
| 45 | + activeIndex: null |
43 | 46 | } |
44 | 47 | }, |
45 | 48 |
|
|
89 | 92 | onKeyListener($event) { |
90 | 93 | if (this.active && $event.key && $event.key.length === 1) { |
91 | 94 | let keyCode = $event.key.toUpperCase().charCodeAt(0) |
92 | | - console.log(keyCode) |
| 95 | + |
93 | 96 | if (keyCode >= 48 && keyCode <= 57) { |
94 | 97 | let index = keyCode - 49 |
95 | 98 |
|
|
108 | 111 | return this.language.ariaMultipleChoice.replace(':letter', this.getToggleKey(index)) |
109 | 112 | }, |
110 | 113 |
|
| 114 | + isPreviousOption(option) { |
| 115 | + return this.getPreviousOptions.includes(option) |
| 116 | + }, |
| 117 | +
|
111 | 118 | getToggleKey(num) { |
112 | 119 | return num |
113 | 120 | }, |
114 | 121 |
|
115 | 122 | toggleAnswer(option) { |
116 | 123 | for (let i = 0; i < this.question.options.length; i++) { |
117 | | - let o = this.question.options[i] |
| 124 | + let o = this.question.options[i] |
118 | 125 |
|
119 | | - if (o.selected) { |
120 | | - this._toggleAnswer(o) |
121 | | - } |
| 126 | + if (o.selected) { |
| 127 | + this._toggleAnswer(o) |
| 128 | + } |
122 | 129 | } |
123 | 130 |
|
124 | 131 | this._toggleAnswer(option) |
|
130 | 137 | option.toggle() |
131 | 138 |
|
132 | 139 | this.dataValue = option.selected ? optionValue : null |
| 140 | + this.activeIndex = this.question.options.indexOf(option) |
133 | 141 | |
134 | 142 | if (this.isValid() && this.question.nextStepOnAnswer && !this.disabled) { |
135 | 143 | this.$emit('next') |
|
154 | 162 | } |
155 | 163 |
|
156 | 164 | return false |
| 165 | + }, |
| 166 | +
|
| 167 | + getPreviousOptions() { |
| 168 | + return this.question.options.filter((o, index) => index < this.activeIndex) |
157 | 169 | } |
158 | 170 | } |
159 | 171 | } |
|
0 commit comments