pull/5098/head
mertsincan 2024-01-14 22:25:39 +00:00
parent c54a34f69d
commit d5bba26341
4 changed files with 11 additions and 7 deletions

View File

@ -1,5 +1,5 @@
<template>
<RadioButton :modelValue="checked" :disabled="$attrs.disabled" :name="name" @change="onChange" :unstyled="unstyled" :pt="getColumnPT('rowRadiobutton')" />
<RadioButton :modelValue="checked" :binary="true" :disabled="$attrs.disabled" :name="name" @change="onChange" :unstyled="unstyled" :pt="getColumnPT('rowRadiobutton')" />
</template>
<script>
@ -20,10 +20,6 @@ export default {
index: {
type: Number,
default: null
},
unstyled: {
type: Boolean,
default: undefined
}
},
methods: {

View File

@ -8,6 +8,7 @@ export default {
props: {
value: null,
modelValue: null,
binary: Boolean,
name: {
type: String,
default: null

View File

@ -105,6 +105,11 @@ export interface RadioButtonProps {
* Name of the input element.
*/
name?: string | undefined;
/**
* Allows to select a boolean value.
* @default false
*/
binary?: boolean;
/**
* When present, it specifies that the component should be disabled.
* @defaultValue false

View File

@ -43,7 +43,9 @@ export default {
},
onChange(event) {
if (!this.disabled && !this.readonly) {
this.$emit('update:modelValue', this.value);
const newModelValue = this.binary ? !this.checked : this.value;
this.$emit('update:modelValue', newModelValue);
this.$emit('change', event);
}
},
@ -56,7 +58,7 @@ export default {
},
computed: {
checked() {
return this.modelValue != null && ObjectUtils.equals(this.modelValue, this.value);
return this.modelValue != null && (this.binary ? !!this.modelValue : ObjectUtils.equals(this.modelValue, this.value));
}
}
};