mirror of
https://github.com/strapi/strapi.git
synced 2025-09-20 22:10:06 +00:00
feedback fix
This commit is contained in:
parent
ffae9fa5e7
commit
997dbb132e
@ -0,0 +1,20 @@
|
|||||||
|
import React from 'react';
|
||||||
|
import PropTypes from 'prop-types';
|
||||||
|
import CustomRadioGroup from '../CustomRadioGroup';
|
||||||
|
|
||||||
|
const BooleanRadioGroup = ({ onChange, name, ...rest }) => {
|
||||||
|
const handleChange = e => {
|
||||||
|
const checked = e.target.value !== 'false';
|
||||||
|
|
||||||
|
onChange({ target: { name, value: checked, type: 'radio' } });
|
||||||
|
};
|
||||||
|
|
||||||
|
return <CustomRadioGroup {...rest} name={name} onChange={handleChange} />;
|
||||||
|
};
|
||||||
|
|
||||||
|
BooleanRadioGroup.propTypes = {
|
||||||
|
name: PropTypes.string.isRequired,
|
||||||
|
onChange: PropTypes.func.isRequired,
|
||||||
|
};
|
||||||
|
|
||||||
|
export default BooleanRadioGroup;
|
@ -10,23 +10,6 @@ import { Wrapper } from './components';
|
|||||||
const CustomRadioGroup = ({ intlLabel, name, onChange, radios, value }) => {
|
const CustomRadioGroup = ({ intlLabel, name, onChange, radios, value }) => {
|
||||||
const { formatMessage } = useIntl();
|
const { formatMessage } = useIntl();
|
||||||
|
|
||||||
const handleChange = e => {
|
|
||||||
let checked;
|
|
||||||
|
|
||||||
if (
|
|
||||||
name === 'multiple' ||
|
|
||||||
name === 'single' ||
|
|
||||||
name === 'createComponent' ||
|
|
||||||
name === 'repeatable'
|
|
||||||
) {
|
|
||||||
checked = e.target.value !== 'false';
|
|
||||||
} else {
|
|
||||||
checked = e.target.value;
|
|
||||||
}
|
|
||||||
|
|
||||||
onChange({ target: { name, value: checked, type: 'radio' } });
|
|
||||||
};
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Stack size={2}>
|
<Stack size={2}>
|
||||||
<Text textColor="neutral800" htmlFor={name} small bold as="label">
|
<Text textColor="neutral800" htmlFor={name} small bold as="label">
|
||||||
@ -43,7 +26,7 @@ const CustomRadioGroup = ({ intlLabel, name, onChange, radios, value }) => {
|
|||||||
checked={radio.value === value}
|
checked={radio.value === value}
|
||||||
value={radio.value}
|
value={radio.value}
|
||||||
key={radio.value}
|
key={radio.value}
|
||||||
onChange={handleChange}
|
onChange={onChange}
|
||||||
type="radio"
|
type="radio"
|
||||||
/>
|
/>
|
||||||
<Box className="option" padding={4}>
|
<Box className="option" padding={4}>
|
||||||
|
@ -41,7 +41,7 @@ const baseForm = {
|
|||||||
defaultMessage: 'Type',
|
defaultMessage: 'Type',
|
||||||
},
|
},
|
||||||
name: 'repeatable',
|
name: 'repeatable',
|
||||||
type: 'radio-group',
|
type: 'boolean-radio-group',
|
||||||
size: 12,
|
size: 12,
|
||||||
radios: [
|
radios: [
|
||||||
{
|
{
|
||||||
@ -180,7 +180,7 @@ const baseForm = {
|
|||||||
},
|
},
|
||||||
name: 'multiple',
|
name: 'multiple',
|
||||||
size: 12,
|
size: 12,
|
||||||
type: 'radio-group',
|
type: 'boolean-radio-group',
|
||||||
radios: [
|
radios: [
|
||||||
{
|
{
|
||||||
title: {
|
title: {
|
||||||
|
@ -6,7 +6,7 @@ const componentField = {
|
|||||||
defaultMessage: 'Type',
|
defaultMessage: 'Type',
|
||||||
},
|
},
|
||||||
name: 'createComponent',
|
name: 'createComponent',
|
||||||
type: 'radio-group',
|
type: 'boolean-radio-group',
|
||||||
size: 12,
|
size: 12,
|
||||||
radios: [
|
radios: [
|
||||||
{
|
{
|
||||||
|
@ -32,6 +32,7 @@ import DraftAndPublishToggle from '../DraftAndPublishToggle';
|
|||||||
import FormModalHeader from '../FormModalHeader';
|
import FormModalHeader from '../FormModalHeader';
|
||||||
|
|
||||||
import BooleanDefaultValueSelect from '../BooleanDefaultValueSelect';
|
import BooleanDefaultValueSelect from '../BooleanDefaultValueSelect';
|
||||||
|
import BooleanRadioGroup from '../BooleanRadioGroup';
|
||||||
import CheckboxWithNumberField from '../CheckboxWithNumberField';
|
import CheckboxWithNumberField from '../CheckboxWithNumberField';
|
||||||
import CustomRadioGroup from '../CustomRadioGroup';
|
import CustomRadioGroup from '../CustomRadioGroup';
|
||||||
import ContentTypeRadioGroup from '../ContentTypeRadioGroup';
|
import ContentTypeRadioGroup from '../ContentTypeRadioGroup';
|
||||||
@ -864,6 +865,7 @@ const FormModal = () => {
|
|||||||
const genericInputProps = {
|
const genericInputProps = {
|
||||||
customInputs: {
|
customInputs: {
|
||||||
'allowed-types-select': AllowedTypesSelect,
|
'allowed-types-select': AllowedTypesSelect,
|
||||||
|
'boolean-radio-group': BooleanRadioGroup,
|
||||||
'checkbox-with-number-field': CheckboxWithNumberField,
|
'checkbox-with-number-field': CheckboxWithNumberField,
|
||||||
'component-icon-picker': ComponentIconPicker,
|
'component-icon-picker': ComponentIconPicker,
|
||||||
'content-type-radio-group': ContentTypeRadioGroup,
|
'content-type-radio-group': ContentTypeRadioGroup,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user