Skip to content

Commit c7ff7a9

Browse files
committed
Try to fix failing tests
Signed-off-by: Micke Nordin <kano@sunet.se>
1 parent 1886b63 commit c7ff7a9

6 files changed

Lines changed: 295 additions & 92 deletions

File tree

openapi.json

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1621,6 +1621,19 @@
16211621
"nullable": true,
16221622
"default": null,
16231623
"description": "(optional) id of the question that should be cloned"
1624+
},
1625+
"parentQuestionId": {
1626+
"type": "integer",
1627+
"format": "int64",
1628+
"nullable": true,
1629+
"default": null,
1630+
"description": "(optional) id of the parent conditional question (for subquestions)"
1631+
},
1632+
"branchId": {
1633+
"type": "string",
1634+
"nullable": true,
1635+
"default": null,
1636+
"description": "(optional) branch id within the parent conditional question"
16241637
}
16251638
}
16261639
}

src/components/Questions/BranchConditionEditor.vue

Lines changed: 32 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@
4141
:options="textConditionTypes"
4242
:placeholder="t('forms', 'Condition type')"
4343
label="label"
44-
:reduce="opt => opt.value"
44+
:reduce="(opt) => opt.value"
4545
class="condition-type-select" />
4646
<NcTextField
4747
v-model="conditionValue"
@@ -59,7 +59,7 @@
5959
:options="valueConditionTypes"
6060
:placeholder="t('forms', 'Condition type')"
6161
label="label"
62-
:reduce="opt => opt.value"
62+
:reduce="(opt) => opt.value"
6363
class="condition-type-select" />
6464
<template v-if="conditionType === 'value_equals'">
6565
<NcTextField
@@ -88,7 +88,9 @@
8888
<template #icon>
8989
<div
9090
class="color-preview"
91-
:style="{ backgroundColor: conditionValue || '#000000' }" />
91+
:style="{
92+
backgroundColor: conditionValue || '#000000',
93+
}" />
9294
</template>
9395
{{ t('forms', 'Select color') }}
9496
</NcButton>
@@ -118,7 +120,7 @@
118120
<template v-else-if="triggerType === 'file'">
119121
<div class="condition-row">
120122
<NcCheckboxRadioSwitch
121-
:checked="fileUploadedCondition"
123+
:model-value="fileUploadedCondition"
122124
@update:checked="onFileConditionChange">
123125
{{ t('forms', 'File is uploaded') }}
124126
</NcCheckboxRadioSwitch>
@@ -155,13 +157,15 @@ export default {
155157
type: Object,
156158
required: true,
157159
},
160+
158161
/**
159162
* The trigger question type
160163
*/
161164
triggerType: {
162165
type: String,
163166
required: true,
164167
},
168+
165169
/**
166170
* Options for option-based triggers (radio, dropdown, checkbox)
167171
*/
@@ -178,7 +182,9 @@ export default {
178182
* Check if trigger is option-based (radio, dropdown, checkbox)
179183
*/
180184
isOptionBasedTrigger() {
181-
return ['multiple_unique', 'dropdown', 'multiple'].includes(this.triggerType)
185+
return ['multiple_unique', 'dropdown', 'multiple'].includes(
186+
this.triggerType,
187+
)
182188
},
183189
184190
/**
@@ -223,7 +229,7 @@ export default {
223229
* Options list for NcSelect
224230
*/
225231
optionsList() {
226-
return this.options.map(opt => ({
232+
return this.options.map((opt) => ({
227233
id: opt.id,
228234
text: opt.text || t('forms', 'Option {id}', { id: opt.id }),
229235
}))
@@ -240,12 +246,14 @@ export default {
240246
let selectedIds
241247
if (this.isSingleSelect) {
242248
// Single select uses optionId in each condition
243-
selectedIds = this.branch.conditions.map(c => c.optionId)
249+
selectedIds = this.branch.conditions.map((c) => c.optionId)
244250
} else {
245251
// Multi select uses optionIds array in first condition
246252
selectedIds = this.branch.conditions[0]?.optionIds || []
247253
}
248-
const selected = this.optionsList.filter(opt => selectedIds.includes(opt.id))
254+
const selected = this.optionsList.filter((opt) =>
255+
selectedIds.includes(opt.id),
256+
)
249257
250258
return this.isSingleSelect ? selected[0] || null : selected
251259
},
@@ -261,7 +269,7 @@ export default {
261269
]
262270
// Long text doesn't support string_equals
263271
if (this.triggerType === 'long') {
264-
return types.filter(t => t.value !== 'string_equals')
272+
return types.filter((t) => t.value !== 'string_equals')
265273
}
266274
return types
267275
},
@@ -283,6 +291,7 @@ export default {
283291
get() {
284292
return this.branch.conditions?.[0]?.type || this.defaultConditionType
285293
},
294+
286295
set(value) {
287296
this.updateCondition({ type: value })
288297
},
@@ -305,6 +314,7 @@ export default {
305314
get() {
306315
return this.branch.conditions?.[0]?.value || ''
307316
},
317+
308318
set(value) {
309319
this.updateCondition({ value })
310320
},
@@ -317,6 +327,7 @@ export default {
317327
get() {
318328
return this.branch.conditions?.[0]?.min || null
319329
},
330+
320331
set(value) {
321332
this.updateCondition({ min: value })
322333
},
@@ -329,6 +340,7 @@ export default {
329340
get() {
330341
return this.branch.conditions?.[0]?.max || null
331342
},
343+
332344
set(value) {
333345
this.updateCondition({ max: value })
334346
},
@@ -367,6 +379,8 @@ export default {
367379
methods: {
368380
/**
369381
* Handle single option selection (radio/dropdown)
382+
*
383+
* @param {object|null} option The selected option or null
370384
*/
371385
onSingleOptionSelect(option) {
372386
const conditions = option ? [{ optionId: option.id }] : []
@@ -375,15 +389,19 @@ export default {
375389
376390
/**
377391
* Handle multiple option selection (checkbox)
392+
*
393+
* @param {Array} options The selected options array
378394
*/
379395
onMultipleOptionsSelect(options) {
380-
const optionIds = options.map(opt => opt.id)
396+
const optionIds = options.map((opt) => opt.id)
381397
const conditions = optionIds.length > 0 ? [{ optionIds }] : []
382398
this.emitUpdate({ conditions })
383399
},
384400
385401
/**
386402
* Handle file condition change
403+
*
404+
* @param {boolean} checked Whether file is uploaded condition is checked
387405
*/
388406
onFileConditionChange(checked) {
389407
const conditions = [{ fileUploaded: checked }]
@@ -392,6 +410,8 @@ export default {
392410
393411
/**
394412
* Update a condition property
413+
*
414+
* @param {object} updates The condition properties to update
395415
*/
396416
updateCondition(updates) {
397417
const currentCondition = this.branch.conditions?.[0] || {}
@@ -405,6 +425,8 @@ export default {
405425
406426
/**
407427
* Emit branch update
428+
*
429+
* @param {object} updates The branch properties to update
408430
*/
409431
emitUpdate(updates) {
410432
this.$emit('update:branch', {

0 commit comments

Comments
 (0)