diff options
Diffstat (limited to 'plugins/CorePluginsAdmin/vue/src')
3 files changed, 24 insertions, 4 deletions
diff --git a/plugins/CorePluginsAdmin/vue/src/FormField/FieldCheckbox.vue b/plugins/CorePluginsAdmin/vue/src/FormField/FieldCheckbox.vue index b07115f983..3c242e2627 100644 --- a/plugins/CorePluginsAdmin/vue/src/FormField/FieldCheckbox.vue +++ b/plugins/CorePluginsAdmin/vue/src/FormField/FieldCheckbox.vue @@ -36,8 +36,13 @@ export default defineComponent({ emits: ['update:modelValue'], methods: { onChange(event: Event) { - if (this.modelValue !== (event.target as HTMLInputElement).checked) { - this.$emit('update:modelValue', (event.target as HTMLInputElement).checked); + const newValue = (event.target as HTMLInputElement).checked; + if (this.modelValue !== newValue) { + // undo checked change since we want the parent component to decide if it should go + // through + (event.target as HTMLInputElement).checked = !newValue; + + this.$emit('update:modelValue', newValue); } }, }, diff --git a/plugins/CorePluginsAdmin/vue/src/FormField/FieldCheckboxArray.vue b/plugins/CorePluginsAdmin/vue/src/FormField/FieldCheckboxArray.vue index f6ba555691..b9e5c7036e 100644 --- a/plugins/CorePluginsAdmin/vue/src/FormField/FieldCheckboxArray.vue +++ b/plugins/CorePluginsAdmin/vue/src/FormField/FieldCheckboxArray.vue @@ -5,7 +5,7 @@ --> <template> - <div> + <div ref="root"> <label class="fieldRadioTitle" v-show="title">{{ title }}</label> <p v-for="(checkboxModel, $index) in availableOptions" @@ -76,6 +76,12 @@ export default defineComponent({ } }); + // undo checked changes since we want the parent component to decide if it should go + // through + (this.$refs.root as HTMLElement).querySelectorAll('input').forEach((inp: HTMLInputElement) => { + inp.checked = !inp.checked; + }); + this.$emit('update:modelValue', newValue); }, }, diff --git a/plugins/CorePluginsAdmin/vue/src/FormField/FieldRadio.vue b/plugins/CorePluginsAdmin/vue/src/FormField/FieldRadio.vue index d48b62a283..9231ca3e80 100644 --- a/plugins/CorePluginsAdmin/vue/src/FormField/FieldRadio.vue +++ b/plugins/CorePluginsAdmin/vue/src/FormField/FieldRadio.vue @@ -5,7 +5,7 @@ --> <template> - <div> + <div ref="root"> <label class="fieldRadioTitle" v-show="title">{{ title }}</label> <p @@ -53,6 +53,15 @@ export default defineComponent({ emits: ['update:modelValue'], methods: { onChange(event: Event) { + (this.$refs.root as HTMLElement).querySelectorAll('input').forEach((inp, i) => { + if (!this.availableOptions?.[i]) { + return; + } + + const { key } = (this.availableOptions as { key: string }[])[i]; + (inp as HTMLInputElement).checked = this.modelValue === key || `${this.modelValue}` === key; + }); + this.$emit('update:modelValue', (event.target as HTMLInputElement).value); }, }, |