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" >
67141<script >
68142import { t } from ' @nextcloud/l10n'
69143import moment from ' @nextcloud/moment'
144+ import NcButton from ' @nextcloud/vue/components/NcButton'
70145import NcCheckboxRadioSwitch from ' @nextcloud/vue/components/NcCheckboxRadioSwitch'
146+ import NcColorPicker from ' @nextcloud/vue/components/NcColorPicker'
71147import NcDateTimePicker from ' @nextcloud/vue/components/NcDateTimePicker'
72148import NcSelect from ' @nextcloud/vue/components/NcSelect'
149+ import NcTextField from ' @nextcloud/vue/components/NcTextField'
73150
74151export default {
75152 name: ' BranchConditionEditor' ,
76153
77154 components: {
155+ NcButton,
78156 NcCheckboxRadioSwitch,
157+ NcColorPicker,
79158 NcDateTimePicker,
80159 NcSelect,
160+ NcTextField,
81161 },
82162
83163 props: {
@@ -125,6 +205,13 @@ export default {
125205 return [' multiple_unique' , ' dropdown' ].includes (this .triggerType )
126206 },
127207
208+ /**
209+ * Check if trigger is value-based (linearscale, color)
210+ */
211+ isValueBasedTrigger () {
212+ return [' linearscale' , ' color' ].includes (this .triggerType )
213+ },
214+
128215 /**
129216 * Check if trigger is date-based (date, datetime, time)
130217 */
@@ -175,6 +262,19 @@ export default {
175262 return this .isSingleSelect ? selected[0 ] || null : selected
176263 },
177264
265+ /**
266+ * Value condition type options (for linear scale)
267+ */
268+ valueConditionTypes () {
269+ return [
270+ { value: ' value_equals' , label: t (' forms' , ' Equals' ) },
271+ { value: ' value_not_equals' , label: t (' forms' , ' Not Equals' ) },
272+ { value: ' value_range' , label: t (' forms' , ' In range' ) },
273+ { value: ' value_min' , label: t (' forms' , ' Higher than' ) },
274+ { value: ' value_max' , label: t (' forms' , ' Lower than' ) },
275+ ]
276+ },
277+
178278 /**
179279 * Current condition type from branch
180280 */
@@ -192,10 +292,24 @@ export default {
192292 * Default condition type based on trigger
193293 */
194294 defaultConditionType () {
295+ if (this .triggerType === ' linearscale' ) return ' value_equals'
195296 if (this .isDateBasedTrigger ) return ' date_range'
196297 return null
197298 },
198299
300+ /**
301+ * Current condition value
302+ */
303+ conditionValue: {
304+ get () {
305+ return this .branch .conditions ? .[0 ]? .value || ' '
306+ },
307+
308+ set (value ) {
309+ this .updateCondition ({ value })
310+ },
311+ },
312+
199313 /**
200314 * Storage format of date and time conditions, the same as for answers
201315 */
@@ -364,11 +478,31 @@ export default {
364478 flex- wrap: wrap;
365479}
366480
481+ .condition - type- select {
482+ min- width: 150px ;
483+ }
484+
485+ .condition - value- input {
486+ flex: 1 ;
487+ min- width: 200px ;
488+ }
489+
490+ .condition - range- input {
491+ width: 100px ;
492+ }
493+
367494.condition - range- separator {
368495 color: var (-- color- text- maxcontrast);
369496}
370497
371498.condition - date- input {
372499 flex: 1 ;
373500}
501+
502+ .color - preview {
503+ width: 24px ;
504+ height: 24px ;
505+ border- radius: var (-- border- radius);
506+ border: 1px solid var (-- color- border- dark);
507+ }
374508< / style>
0 commit comments