|
50 | 50 | validationTypeObject, validationTypeName |
51 | 51 | ) in validationTypes" |
52 | 52 | :key="validationTypeName" |
53 | | - v-model="validationType" |
| 53 | + :model-value="validationType" |
54 | 54 | :name="`${id}_validationMenu`" |
55 | | - :value="validationTypeName"> |
| 55 | + :value="validationTypeName" |
| 56 | + @update:model-value="onChangeValidationType(validationTypeName)"> |
56 | 57 | {{ validationTypeObject.label }} |
57 | 58 | </NcActionRadio> |
58 | 59 | <NcActionInput |
@@ -124,23 +125,8 @@ export default { |
124 | 125 | /** |
125 | 126 | * Name of the current validation type, fallsback to 'text' |
126 | 127 | */ |
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' |
144 | 130 | }, |
145 | 131 | /** |
146 | 132 | * Id of the validation type menu |
@@ -184,6 +170,28 @@ export default { |
184 | 170 | this.$emit('update:values', [value]) |
185 | 171 | }, |
186 | 172 |
|
| 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 | +
|
187 | 195 | /** |
188 | 196 | * Validate and save regex if valid |
189 | 197 | * |
|
0 commit comments