|
50 | 50 | validationTypeObject, validationTypeName |
51 | 51 | ) in validationTypes" |
52 | 52 | :key="validationTypeName" |
53 | | - :checked="validationType === validationTypeName" |
54 | | - :name="validationTypeName" |
55 | | - @update:checked="onChangeValidationType(validationTypeName)"> |
| 53 | + v-model="validationType" |
| 54 | + :value="validationTypeName" |
| 55 | + :name="`${id}_validationMenu`"> |
56 | 56 | {{ validationTypeObject.label }} |
57 | 57 | </NcActionRadio> |
58 | 58 | <NcActionInput |
@@ -124,8 +124,23 @@ export default { |
124 | 124 | /** |
125 | 125 | * Name of the current validation type, fallsback to 'text' |
126 | 126 | */ |
127 | | - validationType() { |
128 | | - return this.extraSettings?.validationType || 'text' |
| 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 | + }, |
129 | 144 | }, |
130 | 145 | /** |
131 | 146 | * Id of the validation type menu |
@@ -169,28 +184,6 @@ export default { |
169 | 184 | this.$emit('update:values', [value]) |
170 | 185 | }, |
171 | 186 |
|
172 | | - /** |
173 | | - * Change input type |
174 | | - * |
175 | | - * @param {string} validationType new input type |
176 | | - */ |
177 | | - onChangeValidationType(validationType) { |
178 | | - if (validationType === 'regex') { |
179 | | - // Make sure to also submit a regex (even if empty) |
180 | | - this.onExtraSettingsChange({ |
181 | | - validationType, |
182 | | - validationRegex: this.validationRegex, |
183 | | - }) |
184 | | - } else { |
185 | | - // For all other types except regex we close the menu (for regex we keep it open to allow entering a regex) |
186 | | - this.isValidationTypeMenuOpen = false |
187 | | - this.onExtraSettingsChange({ |
188 | | - validationType: |
189 | | - validationType === 'text' ? undefined : validationType, |
190 | | - }) |
191 | | - } |
192 | | - }, |
193 | | -
|
194 | 187 | /** |
195 | 188 | * Validate and save regex if valid |
196 | 189 | * |
|
0 commit comments