Skip to content

Commit d573515

Browse files
committed
use model-value instead of v-model
Signed-off-by: GitHub <noreply@github.com> Signed-off-by: Christian Hartmann <chris-hartmann@gmx.de>
1 parent f6cc5c8 commit d573515

1 file changed

Lines changed: 27 additions & 19 deletions

File tree

src/components/Questions/QuestionShort.vue

Lines changed: 27 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -50,9 +50,10 @@
5050
validationTypeObject, validationTypeName
5151
) in validationTypes"
5252
:key="validationTypeName"
53-
v-model="validationType"
53+
:model-value="validationType"
5454
:name="`${id}_validationMenu`"
55-
:value="validationTypeName">
55+
:value="validationTypeName"
56+
@update:model-value="onChangeValidationType(validationTypeName)">
5657
{{ validationTypeObject.label }}
5758
</NcActionRadio>
5859
<NcActionInput
@@ -124,23 +125,8 @@ export default {
124125
/**
125126
* Name of the current validation type, fallsback to 'text'
126127
*/
127-
validationType: {
128-
get() {
129-
return this.extraSettings?.validationType || 'text'
130-
},
131-
set(value) {
132-
if (value === 'regex') {
133-
this.onExtraSettingsChange({
134-
validationType: value,
135-
validationRegex: this.validationRegex,
136-
})
137-
} else {
138-
this.isValidationTypeMenuOpen = false
139-
this.onExtraSettingsChange({
140-
validationType: value === 'text' ? undefined : value,
141-
})
142-
}
143-
},
128+
validationType() {
129+
return this.extraSettings?.validationType || 'text'
144130
},
145131
/**
146132
* Id of the validation type menu
@@ -184,6 +170,28 @@ export default {
184170
this.$emit('update:values', [value])
185171
},
186172
173+
/**
174+
* Change input type
175+
*
176+
* @param {string} validationType new input type
177+
*/
178+
onChangeValidationType(validationType) {
179+
if (validationType === 'regex') {
180+
// Make sure to also submit a regex (even if empty)
181+
this.onExtraSettingsChange({
182+
validationType,
183+
validationRegex: this.validationRegex,
184+
})
185+
} else {
186+
// For all other types except regex we close the menu (for regex we keep it open to allow entering a regex)
187+
this.isValidationTypeMenuOpen = false
188+
this.onExtraSettingsChange({
189+
validationType:
190+
validationType === 'text' ? undefined : validationType,
191+
})
192+
}
193+
},
194+
187195
/**
188196
* Validate and save regex if valid
189197
*

0 commit comments

Comments
 (0)