3232 </div >
3333 </template >
3434
35+ <!-- Value-based conditions (linearscale, color) -->
36+ <template v-else-if =" isValueBasedTrigger " >
37+ <div class =" condition-row" >
38+ <template v-if =" triggerType === ' linearscale' " >
39+ <NcSelect
40+ v-model =" conditionType "
41+ :options =" valueConditionTypes "
42+ :placeholder =" t (' forms' , ' Condition type' )"
43+ :ariaLabelCombobox =" t (' forms' , ' Condition type' )"
44+ label="label"
45+ :reduce =" (opt ) => opt .value "
46+ class="condition-type-select" />
47+ <template
48+ v-if ="
49+ conditionType === ' value_equals'
50+ || conditionType === ' value_not_equals'
51+ " >
52+ <NcTextField
53+ v-model .number =" conditionValue "
54+ type="number"
55+ :label =" t (' forms' , ' Value' )"
56+ class="condition-value-input" />
57+ </template >
58+ <template v-else-if =" conditionType === ' value_range' " >
59+ <NcTextField
60+ v-model .number =" conditionMin "
61+ type="number"
62+ :label =" t (' forms' , ' Minimum value' )"
63+ class="condition-range-input" />
64+ <span class =" condition-range-separator" >-</span >
65+ <NcTextField
66+ v-model .number =" conditionMax "
67+ type="number"
68+ :label =" t (' forms' , ' Maximum value' )"
69+ class="condition-range-input" />
70+ </template >
71+ <template v-else-if =" conditionType === ' value_min' " >
72+ <NcTextField
73+ v-model .number =" conditionMin "
74+ type="number"
75+ :label =" t (' forms' , ' Minimum value' )"
76+ class="condition-value-input" />
77+ </template >
78+ <template v-else-if =" conditionType === ' value_max' " >
79+ <NcTextField
80+ v-model .number =" conditionMax "
81+ type="number"
82+ :label =" t (' forms' , ' Maximum value' )"
83+ class="condition-value-input" />
84+ </template >
85+ </template >
86+ <template v-else-if =" triggerType === ' color' " >
87+ <NcColorPicker v-model =" conditionValue " >
88+ <NcButton
89+ :aria-label ="
90+ t (' forms' , ' Select color, current: {color}' , {
91+ color: conditionValue || t (' forms' , ' none' ),
92+ })
93+ " >
94+ <template #icon >
95+ <div
96+ class =" color-preview"
97+ aria-hidden =" true"
98+ :style =" {
99+ backgroundColor: conditionValue || '#000000',
100+ }" />
101+ </template >
102+ {{ conditionValue || t('forms', 'Select color') }}
103+ </NcButton >
104+ </NcColorPicker >
105+ </template >
106+ </div >
107+ </template >
108+
35109 <!-- Date/time-based conditions -->
36110 <template v-else-if =" isDateBasedTrigger " >
37111 <div class =" condition-row" >
66140
67141<script >
68142import moment from ' @nextcloud/moment'
143+ import NcButton from ' @nextcloud/vue/components/NcButton'
69144import NcCheckboxRadioSwitch from ' @nextcloud/vue/components/NcCheckboxRadioSwitch'
145+ import NcColorPicker from ' @nextcloud/vue/components/NcColorPicker'
70146import NcDateTimePicker from ' @nextcloud/vue/components/NcDateTimePicker'
71147import NcSelect from ' @nextcloud/vue/components/NcSelect'
148+ import NcTextField from ' @nextcloud/vue/components/NcTextField'
72149
73150export default {
74151 name: ' BranchConditionEditor' ,
75152
76153 components: {
154+ NcButton,
77155 NcCheckboxRadioSwitch,
156+ NcColorPicker,
78157 NcDateTimePicker,
79158 NcSelect,
159+ NcTextField,
80160 },
81161
82162 props: {
@@ -124,6 +204,13 @@ export default {
124204 return [' multiple_unique' , ' dropdown' ].includes (this .triggerType )
125205 },
126206
207+ /**
208+ * Check if trigger is value-based (linearscale, color)
209+ */
210+ isValueBasedTrigger () {
211+ return [' linearscale' , ' color' ].includes (this .triggerType )
212+ },
213+
127214 /**
128215 * Check if trigger is date-based (date, datetime, time)
129216 */
@@ -174,6 +261,19 @@ export default {
174261 return this .isSingleSelect ? selected[0 ] || null : selected
175262 },
176263
264+ /**
265+ * Value condition type options (for linear scale)
266+ */
267+ valueConditionTypes () {
268+ return [
269+ { value: ' value_equals' , label: t (' forms' , ' Equals' ) },
270+ { value: ' value_not_equals' , label: t (' forms' , ' Not Equals' ) },
271+ { value: ' value_range' , label: t (' forms' , ' In range' ) },
272+ { value: ' value_min' , label: t (' forms' , ' Higher than' ) },
273+ { value: ' value_max' , label: t (' forms' , ' Lower than' ) },
274+ ]
275+ },
276+
177277 /**
178278 * Current condition type from branch
179279 */
@@ -191,10 +291,24 @@ export default {
191291 * Default condition type based on trigger
192292 */
193293 defaultConditionType () {
294+ if (this .triggerType === ' linearscale' ) return ' value_equals'
194295 if (this .isDateBasedTrigger ) return ' date_range'
195296 return null
196297 },
197298
299+ /**
300+ * Current condition value
301+ */
302+ conditionValue: {
303+ get () {
304+ return this .branch .conditions ? .[0 ]? .value || ' '
305+ },
306+
307+ set (value ) {
308+ this .updateCondition ({ value })
309+ },
310+ },
311+
198312 /**
199313 * Storage format of date and time conditions, the same as for answers
200314 */
@@ -363,11 +477,31 @@ export default {
363477 flex- wrap: wrap;
364478}
365479
480+ .condition - type- select {
481+ min- width: 150px ;
482+ }
483+
484+ .condition - value- input {
485+ flex: 1 ;
486+ min- width: 200px ;
487+ }
488+
489+ .condition - range- input {
490+ width: 100px ;
491+ }
492+
366493.condition - range- separator {
367494 color: var (-- color- text- maxcontrast);
368495}
369496
370497.condition - date- input {
371498 flex: 1 ;
372499}
500+
501+ .color - preview {
502+ width: 24px ;
503+ height: 24px ;
504+ border- radius: var (-- border- radius);
505+ border: 1px solid var (-- color- border- dark);
506+ }
373507< / style>
0 commit comments