feat: add active/disabled fields table to New Field - Step 1 page (#2069)
Closes #1785
This commit is contained in:
@ -1,7 +1,8 @@
|
|||||||
import { useTheme } from '@emotion/react';
|
import { useTheme } from '@emotion/react';
|
||||||
import styled from '@emotion/styled';
|
import styled from '@emotion/styled';
|
||||||
|
|
||||||
import { IconDotsVertical } from '@/ui/display/icon';
|
import { IconComponent } from '@/ui/display/icon/types/IconComponent';
|
||||||
|
import { LightIconButton } from '@/ui/input/button/components/LightIconButton';
|
||||||
import { TableCell } from '@/ui/layout/table/components/TableCell';
|
import { TableCell } from '@/ui/layout/table/components/TableCell';
|
||||||
import { TableRow } from '@/ui/layout/table/components/TableRow';
|
import { TableRow } from '@/ui/layout/table/components/TableRow';
|
||||||
|
|
||||||
@ -9,6 +10,11 @@ import { ObjectFieldItem } from '../../types/ObjectFieldItem';
|
|||||||
|
|
||||||
import { SettingsObjectFieldDataType } from './SettingsObjectFieldDataType';
|
import { SettingsObjectFieldDataType } from './SettingsObjectFieldDataType';
|
||||||
|
|
||||||
|
type SettingsObjectFieldItemTableRowProps = {
|
||||||
|
ActionIcon: IconComponent;
|
||||||
|
fieldItem: ObjectFieldItem;
|
||||||
|
};
|
||||||
|
|
||||||
export const StyledObjectFieldTableRow = styled(TableRow)`
|
export const StyledObjectFieldTableRow = styled(TableRow)`
|
||||||
grid-template-columns: 180px 148px 148px 36px;
|
grid-template-columns: 180px 148px 148px 36px;
|
||||||
`;
|
`;
|
||||||
@ -23,15 +29,10 @@ const StyledIconTableCell = styled(TableCell)`
|
|||||||
padding-right: ${({ theme }) => theme.spacing(1)};
|
padding-right: ${({ theme }) => theme.spacing(1)};
|
||||||
`;
|
`;
|
||||||
|
|
||||||
const StyledIconDotsVertical = styled(IconDotsVertical)`
|
|
||||||
color: ${({ theme }) => theme.font.color.tertiary};
|
|
||||||
`;
|
|
||||||
|
|
||||||
export const SettingsObjectFieldItemTableRow = ({
|
export const SettingsObjectFieldItemTableRow = ({
|
||||||
|
ActionIcon,
|
||||||
fieldItem,
|
fieldItem,
|
||||||
}: {
|
}: SettingsObjectFieldItemTableRowProps) => {
|
||||||
fieldItem: ObjectFieldItem;
|
|
||||||
}) => {
|
|
||||||
const theme = useTheme();
|
const theme = useTheme();
|
||||||
|
|
||||||
return (
|
return (
|
||||||
@ -47,10 +48,7 @@ export const SettingsObjectFieldItemTableRow = ({
|
|||||||
<SettingsObjectFieldDataType value={fieldItem.dataType} />
|
<SettingsObjectFieldDataType value={fieldItem.dataType} />
|
||||||
</TableCell>
|
</TableCell>
|
||||||
<StyledIconTableCell>
|
<StyledIconTableCell>
|
||||||
<StyledIconDotsVertical
|
<LightIconButton Icon={ActionIcon} accent="tertiary" />
|
||||||
size={theme.icon.size.md}
|
|
||||||
stroke={theme.icon.stroke.sm}
|
|
||||||
/>
|
|
||||||
</StyledIconTableCell>
|
</StyledIconTableCell>
|
||||||
</StyledObjectFieldTableRow>
|
</StyledObjectFieldTableRow>
|
||||||
);
|
);
|
||||||
|
|||||||
@ -104,7 +104,7 @@ export const LightIconButton = ({
|
|||||||
size={size}
|
size={size}
|
||||||
active={active}
|
active={active}
|
||||||
>
|
>
|
||||||
{Icon && <Icon size={theme.icon.size.md} />}
|
{Icon && <Icon size={theme.icon.size.md} stroke={theme.icon.stroke.sm} />}
|
||||||
</StyledButton>
|
</StyledButton>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|||||||
@ -3,6 +3,7 @@ import styled from '@emotion/styled';
|
|||||||
|
|
||||||
type SectionProps = {
|
type SectionProps = {
|
||||||
children: ReactNode;
|
children: ReactNode;
|
||||||
|
className?: string;
|
||||||
alignment?: SectionAlignment;
|
alignment?: SectionAlignment;
|
||||||
fullWidth?: boolean;
|
fullWidth?: boolean;
|
||||||
fontColor?: SectionFontColor;
|
fontColor?: SectionFontColor;
|
||||||
@ -31,11 +32,13 @@ const StyledSection = styled.div<{
|
|||||||
|
|
||||||
export const Section = ({
|
export const Section = ({
|
||||||
children,
|
children,
|
||||||
|
className,
|
||||||
alignment = SectionAlignment.Left,
|
alignment = SectionAlignment.Left,
|
||||||
fullWidth = true,
|
fullWidth = true,
|
||||||
fontColor = SectionFontColor.Primary,
|
fontColor = SectionFontColor.Primary,
|
||||||
}: SectionProps) => (
|
}: SectionProps) => (
|
||||||
<StyledSection
|
<StyledSection
|
||||||
|
className={className}
|
||||||
alignment={alignment}
|
alignment={alignment}
|
||||||
fullWidth={fullWidth}
|
fullWidth={fullWidth}
|
||||||
fontColor={fontColor}
|
fontColor={fontColor}
|
||||||
|
|||||||
@ -14,7 +14,7 @@ import {
|
|||||||
StyledObjectFieldTableRow,
|
StyledObjectFieldTableRow,
|
||||||
} from '@/settings/data-model/object-details/components/SettingsObjectFieldItemTableRow';
|
} from '@/settings/data-model/object-details/components/SettingsObjectFieldItemTableRow';
|
||||||
import { AppPath } from '@/types/AppPath';
|
import { AppPath } from '@/types/AppPath';
|
||||||
import { IconPlus, IconSettings } from '@/ui/display/icon';
|
import { IconDotsVertical, IconPlus, IconSettings } from '@/ui/display/icon';
|
||||||
import { H2Title } from '@/ui/display/typography/components/H2Title';
|
import { H2Title } from '@/ui/display/typography/components/H2Title';
|
||||||
import { Button } from '@/ui/input/button/components/Button';
|
import { Button } from '@/ui/input/button/components/Button';
|
||||||
import { SubMenuTopBarContainer } from '@/ui/layout/page/SubMenuTopBarContainer';
|
import { SubMenuTopBarContainer } from '@/ui/layout/page/SubMenuTopBarContainer';
|
||||||
@ -74,6 +74,7 @@ export const SettingsObjectDetail = () => {
|
|||||||
{activeFieldItems.map((fieldItem) => (
|
{activeFieldItems.map((fieldItem) => (
|
||||||
<SettingsObjectFieldItemTableRow
|
<SettingsObjectFieldItemTableRow
|
||||||
key={fieldItem.name}
|
key={fieldItem.name}
|
||||||
|
ActionIcon={IconDotsVertical}
|
||||||
fieldItem={fieldItem}
|
fieldItem={fieldItem}
|
||||||
/>
|
/>
|
||||||
))}
|
))}
|
||||||
@ -83,6 +84,7 @@ export const SettingsObjectDetail = () => {
|
|||||||
{disabledFieldItems.map((fieldItem) => (
|
{disabledFieldItems.map((fieldItem) => (
|
||||||
<SettingsObjectFieldItemTableRow
|
<SettingsObjectFieldItemTableRow
|
||||||
key={fieldItem.name}
|
key={fieldItem.name}
|
||||||
|
ActionIcon={IconDotsVertical}
|
||||||
fieldItem={fieldItem}
|
fieldItem={fieldItem}
|
||||||
/>
|
/>
|
||||||
))}
|
))}
|
||||||
|
|||||||
@ -1,13 +1,38 @@
|
|||||||
import { useEffect } from 'react';
|
import { useEffect } from 'react';
|
||||||
import { useNavigate, useParams } from 'react-router-dom';
|
import { useNavigate, useParams } from 'react-router-dom';
|
||||||
|
import styled from '@emotion/styled';
|
||||||
|
|
||||||
import { SettingsPageContainer } from '@/settings/components/SettingsPageContainer';
|
import { SettingsPageContainer } from '@/settings/components/SettingsPageContainer';
|
||||||
import { activeObjectItems } from '@/settings/data-model/constants/mockObjects';
|
import {
|
||||||
|
activeFieldItems,
|
||||||
|
activeObjectItems,
|
||||||
|
disabledFieldItems,
|
||||||
|
} from '@/settings/data-model/constants/mockObjects';
|
||||||
|
import {
|
||||||
|
SettingsObjectFieldItemTableRow,
|
||||||
|
StyledObjectFieldTableRow,
|
||||||
|
} from '@/settings/data-model/object-details/components/SettingsObjectFieldItemTableRow';
|
||||||
import { AppPath } from '@/types/AppPath';
|
import { AppPath } from '@/types/AppPath';
|
||||||
import { IconSettings } from '@/ui/display/icon';
|
import { IconMinus, IconPlus, IconSettings } from '@/ui/display/icon';
|
||||||
|
import { H2Title } from '@/ui/display/typography/components/H2Title';
|
||||||
|
import { Button } from '@/ui/input/button/components/Button';
|
||||||
import { SubMenuTopBarContainer } from '@/ui/layout/page/SubMenuTopBarContainer';
|
import { SubMenuTopBarContainer } from '@/ui/layout/page/SubMenuTopBarContainer';
|
||||||
|
import { Section } from '@/ui/layout/section/components/Section';
|
||||||
|
import { Table } from '@/ui/layout/table/components/Table';
|
||||||
|
import { TableHeader } from '@/ui/layout/table/components/TableHeader';
|
||||||
|
import { TableSection } from '@/ui/layout/table/components/TableSection';
|
||||||
import { Breadcrumb } from '@/ui/navigation/bread-crumb/components/Breadcrumb';
|
import { Breadcrumb } from '@/ui/navigation/bread-crumb/components/Breadcrumb';
|
||||||
|
|
||||||
|
const StyledSection = styled(Section)`
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
`;
|
||||||
|
|
||||||
|
const StyledAddCustomFieldButton = styled(Button)`
|
||||||
|
align-self: flex-end;
|
||||||
|
margin-top: ${({ theme }) => theme.spacing(2)};
|
||||||
|
`;
|
||||||
|
|
||||||
export const SettingsObjectNewFieldStep1 = () => {
|
export const SettingsObjectNewFieldStep1 = () => {
|
||||||
const navigate = useNavigate();
|
const navigate = useNavigate();
|
||||||
const { pluralObjectName = '' } = useParams();
|
const { pluralObjectName = '' } = useParams();
|
||||||
@ -32,6 +57,49 @@ export const SettingsObjectNewFieldStep1 = () => {
|
|||||||
{ children: 'New Field' },
|
{ children: 'New Field' },
|
||||||
]}
|
]}
|
||||||
/>
|
/>
|
||||||
|
<StyledSection>
|
||||||
|
<H2Title
|
||||||
|
title="Check disabled fields"
|
||||||
|
description="Before creating a custom field, check if it already exists in the disabled section."
|
||||||
|
/>
|
||||||
|
<Table>
|
||||||
|
<StyledObjectFieldTableRow>
|
||||||
|
<TableHeader>Name</TableHeader>
|
||||||
|
<TableHeader>Field type</TableHeader>
|
||||||
|
<TableHeader>Data type</TableHeader>
|
||||||
|
<TableHeader></TableHeader>
|
||||||
|
</StyledObjectFieldTableRow>
|
||||||
|
<TableSection isInitiallyExpanded={false} title="Active">
|
||||||
|
{activeFieldItems.map((fieldItem) => (
|
||||||
|
<SettingsObjectFieldItemTableRow
|
||||||
|
key={fieldItem.name}
|
||||||
|
ActionIcon={IconMinus}
|
||||||
|
fieldItem={fieldItem}
|
||||||
|
/>
|
||||||
|
))}
|
||||||
|
</TableSection>
|
||||||
|
{!!disabledFieldItems.length && (
|
||||||
|
<TableSection title="Disabled">
|
||||||
|
{disabledFieldItems.map((fieldItem) => (
|
||||||
|
<SettingsObjectFieldItemTableRow
|
||||||
|
key={fieldItem.name}
|
||||||
|
ActionIcon={IconPlus}
|
||||||
|
fieldItem={fieldItem}
|
||||||
|
/>
|
||||||
|
))}
|
||||||
|
</TableSection>
|
||||||
|
)}
|
||||||
|
</Table>
|
||||||
|
<StyledAddCustomFieldButton
|
||||||
|
Icon={IconPlus}
|
||||||
|
title="Add Custom Field"
|
||||||
|
size="small"
|
||||||
|
variant="secondary"
|
||||||
|
onClick={() =>
|
||||||
|
navigate(`/settings/objects/${pluralObjectName}/new-field/step-2`)
|
||||||
|
}
|
||||||
|
/>
|
||||||
|
</StyledSection>
|
||||||
</SettingsPageContainer>
|
</SettingsPageContainer>
|
||||||
</SubMenuTopBarContainer>
|
</SubMenuTopBarContainer>
|
||||||
);
|
);
|
||||||
|
|||||||
Reference in New Issue
Block a user