Refactor #5071
parent
c54a34f69d
commit
d5bba26341
|
@ -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: {
|
||||
|
|
|
@ -8,6 +8,7 @@ export default {
|
|||
props: {
|
||||
value: null,
|
||||
modelValue: null,
|
||||
binary: Boolean,
|
||||
name: {
|
||||
type: String,
|
||||
default: null
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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));
|
||||
}
|
||||
}
|
||||
};
|
||||
|
|
Loading…
Reference in New Issue