|
47 | 47 | :model-value="!!extraSettings?.optionsLimitMax" |
48 | 48 | @update:model-value=" |
49 | 49 | (checked) => |
50 | | - onLimitOptionsMax( |
51 | | - checked ? sortedOptions.length || 1 : null, |
52 | | - ) |
| 50 | + onLimitOptionsMax(checked ? choices.length || 1 : null) |
53 | 51 | "> |
54 | 52 | {{ t('forms', 'Require a maximum of options to be checked') }} |
55 | 53 | </NcActionCheckbox> |
|
75 | 73 | {{ errorMessage }} |
76 | 74 | </NcNoteCard> |
77 | 75 | <NcCheckboxRadioSwitch |
78 | | - v-for="answer in sortedOptions" |
| 76 | + v-for="answer in choices" |
79 | 77 | :key="answer.id" |
80 | 78 | :aria-errormessage="hasError ? errorId : undefined" |
81 | 79 | :aria-invalid="hasError ? 'true' : undefined" |
|
118 | 116 | </div> |
119 | 117 | <Draggable |
120 | 118 | v-else |
121 | | - v-model="sortedOptions" |
| 119 | + v-model="choices" |
122 | 120 | class="question__content" |
123 | 121 | animation="200" |
124 | 122 | direction="vertical" |
125 | 123 | handle=".option__drag-handle" |
126 | 124 | invert-swap |
127 | 125 | tag="ul" |
128 | | - @change="saveOptionsOrder" |
| 126 | + @change="saveOptionsOrder('choice')" |
129 | 127 | @start="isDragging = true" |
130 | 128 | @end="isDragging = false"> |
131 | 129 | <TransitionGroup |
|
136 | 134 | "> |
137 | 135 | <!-- Answer text input edit --> |
138 | 136 | <AnswerInput |
139 | | - v-for="(answer, index) in sortedOptions" |
| 137 | + v-for="(answer, index) in choices" |
140 | 138 | :key="answer.local ? 'option-local' : answer.id" |
141 | 139 | ref="input" |
142 | 140 | :answer="answer" |
|
145 | 143 | :is-unique="isUnique" |
146 | 144 | :max-index="options.length - 1" |
147 | 145 | :max-option-length="maxStringLengths.optionText" |
| 146 | + option-type="choice" |
148 | 147 | @create-answer="onCreateAnswer" |
149 | 148 | @update:answer="updateAnswer" |
150 | 149 | @delete="deleteOption" |
151 | 150 | @focus-next="focusNextInput" |
152 | | - @move-up="onOptionMoveUp(index)" |
153 | | - @move-down="onOptionMoveDown(index)" |
154 | | - @tabbed-out="checkValidOption" /> |
| 151 | + @move-up="onOptionMoveUp(index, 'choice')" |
| 152 | + @move-down="onOptionMoveDown(index, 'choice')" |
| 153 | + @tabbed-out="checkValidOption('choice')" /> |
155 | 154 | </TransitionGroup> |
156 | 155 | </Draggable> |
157 | 156 | <li |
@@ -196,7 +195,10 @@ import AnswerInput from './AnswerInput.vue' |
196 | 195 | import Question from './Question.vue' |
197 | 196 | import QuestionMixin from '../../mixins/QuestionMixin.js' |
198 | 197 | import QuestionMultipleMixin from '../../mixins/QuestionMultipleMixin.ts' |
199 | | -import { QUESTION_EXTRASETTINGS_OTHER_PREFIX } from '../../models/Constants.ts' |
| 198 | +import { |
| 199 | + OptionType, |
| 200 | + QUESTION_EXTRASETTINGS_OTHER_PREFIX, |
| 201 | +} from '../../models/Constants.ts' |
200 | 202 |
|
201 | 203 | export default { |
202 | 204 | name: 'QuestionMultiple', |
@@ -288,6 +290,16 @@ export default { |
288 | 290 | v.startsWith(QUESTION_EXTRASETTINGS_OTHER_PREFIX), |
289 | 291 | ) |
290 | 292 | }, |
| 293 | +
|
| 294 | + choices: { |
| 295 | + get() { |
| 296 | + return this.sortOptionsOfType(this.options, OptionType.Choice) |
| 297 | + }, |
| 298 | +
|
| 299 | + set(value) { |
| 300 | + this.updateOptionsOrder(value, OptionType.Choice) |
| 301 | + }, |
| 302 | + }, |
291 | 303 | }, |
292 | 304 |
|
293 | 305 | watch: { |
|
0 commit comments