Skip to content

Commit 958f337

Browse files
committed
fix: simplify conditional trigger type selection
1 parent 3230a14 commit 958f337

1 file changed

Lines changed: 52 additions & 52 deletions

File tree

‎src/components/Questions/QuestionConditional.vue‎

Lines changed: 52 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -13,37 +13,33 @@
1313
:shiftDragHandle="false"
1414
:isTriggerQuestion="isTriggerQuestion"
1515
v-on="commonListeners">
16-
<template #actions>
17-
<!-- Trigger type selection in menu -->
18-
<NcActionButton
19-
v-for="tt in triggerTypesList"
20-
:key="tt.type"
21-
:closeAfterClick="true"
22-
@click="setTriggerType(tt.type)">
23-
<template #icon>
24-
<NcIconSvgWrapper :svg="tt.icon" />
25-
</template>
26-
{{ tt.label }}
27-
</NcActionButton>
28-
</template>
29-
3016
<div class="question-conditional">
3117
<!-- Trigger Type Selection (Edit Mode) -->
3218
<div v-if="!readOnly && !triggerType" class="trigger-type-selector">
3319
<p class="trigger-type-selector__label">
3420
{{ t('forms', 'Select the trigger question type:') }}
3521
</p>
3622
<div class="trigger-type-selector__options">
37-
<NcButton
38-
v-for="tt in triggerTypesList"
39-
:key="tt.type"
40-
variant="secondary"
41-
@click="setTriggerType(tt.type)">
42-
<template #icon>
43-
<NcIconSvgWrapper :svg="tt.icon" />
44-
</template>
45-
{{ tt.label }}
46-
</NcButton>
23+
<div
24+
v-for="group in triggerTypeGroups"
25+
:key="group.label"
26+
class="trigger-type-selector__group">
27+
<p class="trigger-type-selector__group-label">
28+
{{ group.label }}
29+
</p>
30+
<div class="trigger-type-selector__group-options">
31+
<NcButton
32+
v-for="tt in group.types"
33+
:key="tt.type"
34+
variant="secondary"
35+
@click="setTriggerType(tt.type)">
36+
<template #icon>
37+
<NcIconSvgWrapper :svg="tt.icon" />
38+
</template>
39+
{{ tt.label }}
40+
</NcButton>
41+
</div>
42+
</div>
4743
</div>
4844
</div>
4945

@@ -386,42 +382,32 @@ export default defineComponent({
386382
},
387383
388384
computed: {
389-
/**
390-
* Trigger types available for conditional questions
391-
*/
392-
triggerTypesList() {
393-
return [
394-
{
395-
type: 'multiple_unique',
396-
label: t('forms', 'Radio buttons'),
397-
icon: IconRadioboxMarked,
398-
},
385+
triggerTypeGroups() {
386+
const groups = [
399387
{
400-
type: 'dropdown',
401-
label: t('forms', 'Dropdown'),
402-
icon: IconArrowDownDropCircleOutline,
388+
label: t('forms', 'Choice'),
389+
types: ['multiple_unique', 'multiple', 'dropdown'],
403390
},
404391
{
405-
type: 'multiple',
406-
label: t('forms', 'Checkboxes'),
407-
icon: IconCheckboxOutline,
392+
label: t('forms', 'Text'),
393+
types: ['short', 'long'],
408394
},
409395
{
410-
type: 'short',
411-
label: t('forms', 'Short answer'),
412-
icon: IconTextShort,
396+
label: t('forms', 'Date and time'),
397+
types: ['date', 'time'],
413398
},
414-
{ type: 'long', label: t('forms', 'Long text'), icon: IconTextLong },
415399
{
416-
type: 'linearscale',
417-
label: t('forms', 'Linear scale'),
418-
icon: IconLinearScale,
400+
label: t('forms', 'Other'),
401+
types: ['linearscale', 'color', 'file'],
419402
},
420-
{ type: 'date', label: t('forms', 'Date'), icon: IconCalendar },
421-
{ type: 'time', label: t('forms', 'Time'), icon: IconClockOutline },
422-
{ type: 'color', label: t('forms', 'Color'), icon: IconPalette },
423-
{ type: 'file', label: t('forms', 'File'), icon: IconFile },
424403
]
404+
405+
return groups.map((group) => ({
406+
...group,
407+
types: group.types.map((type) =>
408+
this.subQuestionTypesList.find((item) => item.type === type),
409+
),
410+
}))
425411
},
426412
427413
/**
@@ -472,7 +458,9 @@ export default defineComponent({
472458
},
473459
474460
currentTriggerConfig() {
475-
return this.triggerTypesList.find((t) => t.type === this.triggerType)
461+
return this.triggerTypeGroups
462+
.flatMap((group) => group.types)
463+
.find((type) => type.type === this.triggerType)
476464
},
477465
478466
currentTriggerIcon() {
@@ -1179,6 +1167,18 @@ export default defineComponent({
11791167
}
11801168
11811169
&__options {
1170+
display: flex;
1171+
flex-direction: column;
1172+
gap: 12px;
1173+
}
1174+
1175+
&__group-label {
1176+
margin-bottom: 4px;
1177+
color: var(--color-text-maxcontrast);
1178+
font-size: 0.9em;
1179+
}
1180+
1181+
&__group-options {
11821182
display: flex;
11831183
flex-wrap: wrap;
11841184
gap: 8px;

0 commit comments

Comments
 (0)