Fix display empty value if boolean instead of false on show page (#4468)
* default value boolean fixed * fixed creation, fixed updating a value to false * fixed default value for default value if boolean * fixed tests --------- Co-authored-by: Félix Malfait <felix.malfait@gmail.com>
This commit is contained in:
@ -0,0 +1,60 @@
|
||||
import styled from '@emotion/styled';
|
||||
|
||||
import { IconCheck, IconX } from '@/ui/display/icon';
|
||||
import { Select } from '@/ui/input/components/Select';
|
||||
import { CardContent } from '@/ui/layout/card/components/CardContent';
|
||||
|
||||
type SettingsDataModelDefaultValueFormProps = {
|
||||
className?: string;
|
||||
disabled?: boolean;
|
||||
onChange?: (defaultValue: SettingsDataModelDefaultValue) => void;
|
||||
value?: SettingsDataModelDefaultValue;
|
||||
};
|
||||
|
||||
export type SettingsDataModelDefaultValue = any;
|
||||
|
||||
const StyledContainer = styled(CardContent)`
|
||||
padding-bottom: ${({ theme }) => theme.spacing(3.5)};
|
||||
`;
|
||||
|
||||
const StyledLabel = styled.span`
|
||||
color: ${({ theme }) => theme.font.color.light};
|
||||
display: block;
|
||||
font-size: ${({ theme }) => theme.font.size.xs};
|
||||
font-weight: ${({ theme }) => theme.font.weight.semiBold};
|
||||
margin-bottom: 6px;
|
||||
margin-top: ${({ theme }) => theme.spacing(1)};
|
||||
`;
|
||||
|
||||
export const SettingsDataModelDefaultValueForm = ({
|
||||
className,
|
||||
disabled,
|
||||
onChange,
|
||||
value,
|
||||
}: SettingsDataModelDefaultValueFormProps) => {
|
||||
return (
|
||||
<StyledContainer>
|
||||
<StyledLabel>Default Value</StyledLabel>
|
||||
<Select
|
||||
className={className}
|
||||
fullWidth
|
||||
disabled={disabled}
|
||||
dropdownId="object-field-default-value-select"
|
||||
value={value}
|
||||
onChange={(value) => onChange?.(value)}
|
||||
options={[
|
||||
{
|
||||
value: true,
|
||||
label: 'True',
|
||||
Icon: IconCheck,
|
||||
},
|
||||
{
|
||||
value: false,
|
||||
label: 'False',
|
||||
Icon: IconX,
|
||||
},
|
||||
]}
|
||||
/>
|
||||
</StyledContainer>
|
||||
);
|
||||
};
|
||||
Reference in New Issue
Block a user