Refactor #5071
parent
c54a34f69d
commit
d5bba26341
|
@ -1,5 +1,5 @@
|
||||||
<template>
|
<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>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
|
@ -20,10 +20,6 @@ export default {
|
||||||
index: {
|
index: {
|
||||||
type: Number,
|
type: Number,
|
||||||
default: null
|
default: null
|
||||||
},
|
|
||||||
unstyled: {
|
|
||||||
type: Boolean,
|
|
||||||
default: undefined
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
|
|
|
@ -8,6 +8,7 @@ export default {
|
||||||
props: {
|
props: {
|
||||||
value: null,
|
value: null,
|
||||||
modelValue: null,
|
modelValue: null,
|
||||||
|
binary: Boolean,
|
||||||
name: {
|
name: {
|
||||||
type: String,
|
type: String,
|
||||||
default: null
|
default: null
|
||||||
|
|
|
@ -105,6 +105,11 @@ export interface RadioButtonProps {
|
||||||
* Name of the input element.
|
* Name of the input element.
|
||||||
*/
|
*/
|
||||||
name?: string | undefined;
|
name?: string | undefined;
|
||||||
|
/**
|
||||||
|
* Allows to select a boolean value.
|
||||||
|
* @default false
|
||||||
|
*/
|
||||||
|
binary?: boolean;
|
||||||
/**
|
/**
|
||||||
* When present, it specifies that the component should be disabled.
|
* When present, it specifies that the component should be disabled.
|
||||||
* @defaultValue false
|
* @defaultValue false
|
||||||
|
|
|
@ -43,7 +43,9 @@ export default {
|
||||||
},
|
},
|
||||||
onChange(event) {
|
onChange(event) {
|
||||||
if (!this.disabled && !this.readonly) {
|
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);
|
this.$emit('change', event);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
@ -56,7 +58,7 @@ export default {
|
||||||
},
|
},
|
||||||
computed: {
|
computed: {
|
||||||
checked() {
|
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