Skip to content

Commit

Permalink
Feature 7552 patch (#8574)
Browse files Browse the repository at this point in the history
Related to #7552

<img width="556" alt="Screenshot 2024-11-18 at 17 57 30"
src="https://github.com/user-attachments/assets/e89e575b-9adb-4910-ab0d-b60079727f70">

---------

Co-authored-by: guillim <[email protected]>
  • Loading branch information
guillim and guillim authored Nov 19, 2024
1 parent 9073bdf commit 4a8234d
Show file tree
Hide file tree
Showing 2 changed files with 48 additions and 57 deletions.
Original file line number Diff line number Diff line change
@@ -1,18 +1,10 @@
import { Controller, useFormContext } from 'react-hook-form';

import { FieldMetadataItem } from '@/object-metadata/types/FieldMetadataItem';
import { Select } from '@/ui/input/components/Select';
import styled from '@emotion/styled';
import { CardContent } from 'twenty-ui';
import { SettingsOptionCardContentSelect } from '@/settings/components/SettingsOptions/SettingsOptionCardContentSelect';
import { IconTextWrap } from 'twenty-ui';
import { z } from 'zod';

const StyledFormCardTitle = styled.div`
color: ${({ theme }) => theme.font.color.light};
font-size: ${({ theme }) => theme.font.size.xs};
font-weight: ${({ theme }) => theme.font.weight.semiBold};
margin-bottom: ${({ theme }) => theme.spacing(1)};
`;

type SettingsDataModelFieldTextFormProps = {
disabled?: boolean;
fieldMetadataItem: Pick<
Expand All @@ -39,53 +31,51 @@ export const SettingsDataModelFieldTextForm = ({
}: SettingsDataModelFieldTextFormProps) => {
const { control } = useFormContext<SettingsDataModelFieldTextFormValues>();
return (
<CardContent>
<Controller
name="settings"
defaultValue={{
displayedMaxRows: fieldMetadataItem?.settings?.displayedMaxRows || 0,
}}
control={control}
render={({ field: { onChange, value } }) => {
const displayedMaxRows = value?.displayedMaxRows ?? 0;
<Controller
name="settings"
defaultValue={{
displayedMaxRows: fieldMetadataItem?.settings?.displayedMaxRows || 0,
}}
control={control}
render={({ field: { onChange, value } }) => {
const displayedMaxRows = value?.displayedMaxRows ?? 0;

return (
<>
<StyledFormCardTitle>Wrap on record pages</StyledFormCardTitle>
<Select
disabled={disabled}
dropdownId="selectTextWrap"
options={[
{
label: 'Deactivated',
value: 0,
},
{
label: 'First 2 lines',
value: 2,
},
{
label: 'First 5 lines',
value: 5,
},
{
label: 'First 10 lines',
value: 10,
},
{
label: 'All lines',
value: 99,
},
]}
value={displayedMaxRows}
onChange={(value) => onChange({ displayedMaxRows: value })}
withSearchInput={false}
dropdownWidthAuto={true}
/>
</>
);
}}
/>
</CardContent>
return (
<>
<SettingsOptionCardContentSelect
Icon={IconTextWrap}
dropdownId="text-wrap"
title="Wrap on record pages"
description="Display text on multiple lines"
value={displayedMaxRows}
onChange={(value) => onChange({ displayedMaxRows: value })}
disabled={disabled}
options={[
{
label: 'Deactivated',
value: 0,
},
{
label: 'First 2 lines',
value: 2,
},
{
label: 'First 5 lines',
value: 5,
},
{
label: 'First 10 lines',
value: 10,
},
{
label: 'All lines',
value: 99,
},
]}
/>
</>
);
}}
/>
);
};
Original file line number Diff line number Diff line change
Expand Up @@ -229,6 +229,7 @@ export {
IconTargetArrow,
IconTestPipe,
IconTextSize,
IconTextWrap,
IconTimelineEvent,
IconTool,
IconTrash,
Expand Down

0 comments on commit 4a8234d

Please sign in to comment.