1111 v-on =" commonListeners" >
1212 <template #actions >
1313 <NcActionInput
14+ v-model =" lowestOption"
1415 type =" multiselect"
16+ :clearable =" false"
17+ :label =" t('forms', 'Lowest value')"
18+ label-outside
1519 :options =" [0, 1]"
16- :v-model =" lowestOption" >
17- {{ t('forms', 'Lowest value') }}
20+ required >
21+ <template #icon >
22+ <IconPencil :size =" 20" />
23+ </template >
1824 </NcActionInput >
1925 <NcActionInput
26+ v-model =" highestOption"
2027 type =" multiselect"
28+ :clearable =" false"
29+ :label =" t('forms', 'Highest value')"
30+ label-outside
2131 :options =" [2, 3, 4, 5, 6, 7, 8, 9, 10]"
22- :v-model =" highestOption" >
23- {{ t('forms', 'Highest value') }}
32+ required >
33+ <template #icon >
34+ <IconPencil :size =" 20" />
35+ </template >
2436 </NcActionInput >
2537 <NcActionInput >
38+ <template #icon >
39+ <IconPencil :size =" 20" />
40+ </template >
2641 {{ t('forms', 'Label for lowest value') }}
2742 </NcActionInput >
2843 <NcActionInput >
44+ <template #icon >
45+ <IconPencil :size =" 20" />
46+ </template >
2947 {{ t('forms', 'Label for highest value') }}
3048 </NcActionInput >
3149 </template >
3250
33- <fieldset :name =" name || undefined" :aria-labelledby =" titleId" >
34- <NcNoteCard v-if =" hasError" :id =" errorId" type =" error" >
35- {{ errorMessage }}
36- </NcNoteCard >
51+ <div class =" question__content" >
3752 <NcCheckboxRadioSwitch
3853 v-for =" option in scaleOptions"
3954 :key =" option"
55+ class =" question__content"
4056 :disabled =" !readOnly"
41- :aria-errormessage =" hasError ? errorId : undefined"
42- :aria-invalid =" hasError ? 'true' : undefined"
4357 :checked =" questionValues"
4458 :value =" option.toString()"
4559 :name =" `${id}-answer`"
5165 @keydown.enter.exact.prevent =" onKeydownEnter" >
5266 {{ option }}
5367 </NcCheckboxRadioSwitch >
54- </fieldset >
68+ </div >
5569 </Question >
5670</template >
5771
5872<script >
5973import { translate as t , translatePlural as n } from ' @nextcloud/l10n'
6074import NcActionInput from ' @nextcloud/vue/components/NcActionInput'
6175import NcCheckboxRadioSwitch from ' @nextcloud/vue/components/NcCheckboxRadioSwitch'
62- import NcNoteCard from ' @nextcloud/vue/components/NcNoteCard'
6376
6477import QuestionMixin from ' ../../mixins/QuestionMixin.js'
6578
79+ import IconPencil from ' vue-material-design-icons/Pencil.vue'
80+
6681export default {
6782 name: ' QuestionLinearScale' ,
6883
6984 components: {
85+ IconPencil,
7086 NcActionInput,
7187 NcCheckboxRadioSwitch,
72- NcNoteCard,
7388 },
7489
7590 mixins: [QuestionMixin],
7691
7792 data () {
7893 return {
79- /**
80- * The shown error message
81- */
82- errorMessage: null ,
83-
8494 isLoading: false ,
8595
8696 lowestOption: 1 ,
@@ -100,53 +110,12 @@ export default {
100110 return this .answerType .unique === true
101111 },
102112
103- hasError () {
104- return !! this .errorMessage
105- },
106-
107113 questionValues () {
108114 return this .isUnique ? this .values ? .[0 ] : this .values
109115 },
110-
111- titleId () {
112- return ` q${ this .index } _title`
113- },
114-
115- errorId () {
116- return ` q${ this .index } _error`
117- },
118116 },
119117
120118 methods: {
121- async validate () {
122- if (! this .isUnique ) {
123- // Validate limits
124- const max = this .extraSettings .optionsLimitMax ?? 0
125- const min = this .extraSettings .optionsLimitMin ?? 0
126- if (max && this .values .length > max) {
127- this .errorMessage = n (
128- ' forms' ,
129- ' You must choose at most one option' ,
130- ' You must choose a maximum of %n options' ,
131- max,
132- )
133- return false
134- }
135- if (min && this .values .length < min) {
136- this .errorMessage = n (
137- ' forms' ,
138- ' You must choose at least one option' ,
139- ' You must choose at least %n options' ,
140- min,
141- )
142- return false
143- }
144- }
145-
146- this .errorMessage = null
147- return true
148- },
149-
150119 onChange (value ) {
151120 this .$emit (' update:values' , this .isUnique ? [value].flat () : value)
152121 },
@@ -172,11 +141,10 @@ export default {
172141 }
173142
174143 // For checkboxes, only required if no other is checked
175- return this . areNoneChecked
144+ return false
176145 },
177146 },
178147}
179148< / script>
180149
181- < style lang= " scss" scoped>
182- < / style>
150+ < style lang= " scss" scoped>< / style>
0 commit comments