Skip to content

Commit

Permalink
✨ feat(form-select): use character length to trigger select button
Browse files Browse the repository at this point in the history
  • Loading branch information
thrownullexception committed Dec 28, 2023
1 parent b310667 commit ddd6425
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 13 deletions.
6 changes: 5 additions & 1 deletion src/frontend/components/SchemaForm/_RenderFormInput.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,11 @@ export function RenderFormInput(props: IRenderFormInputProps) {
};

if (entityFieldSelections.length > 0) {
if (entityFieldSelections.length > 1 && entityFieldSelections.length <= 4) {
if (
entityFieldSelections.reduce((acc, selection) => {
return acc + selection.label.length;
}, 0) < 15
) {
return (
<FormSelectButton {...formProps} selectData={entityFieldSelections} />
);
Expand Down
6 changes: 3 additions & 3 deletions src/frontend/design-system/components/Table/Stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { action } from "@storybook/addon-actions";
import { IPaginatedDataState } from "shared/types/data";
import { ApplicationRoot } from "frontend/components/ApplicationRoot";
import { Table, DEFAULT_TABLE_STATE } from ".";
import { IProps } from "./types";
import { ITableProps } from "./types";
import { TABLE_COLUMNS, TABLE_DATA } from "./data";

export default {
Expand All @@ -29,10 +29,10 @@ export default {
syncPaginatedDataStateOut: action("setPaginatedDataState"),
columns: TABLE_COLUMNS,
tableData: TABLE_DATA,
} as IProps<unknown>,
} as ITableProps<unknown>,
};

const Template: Story<IProps<unknown>> = (args) => {
const Template: Story<ITableProps<unknown>> = (args) => {
const [paginatedDataState, setPaginatedDataState] = useState<
IPaginatedDataState<any>
>({ ...DEFAULT_TABLE_STATE });
Expand Down
6 changes: 1 addition & 5 deletions src/frontend/views/data/Details/RelationsDetails.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -92,11 +92,7 @@ export function EntityRelationDetails() {
});

return (
<DetailsLayout
entity={parentEntity}
menuKey={childEntity}
childEntity={childEntity}
>
<DetailsLayout entity={parentEntity} menuKey={childEntity}>
{dataDetails.error ? (
<SectionBox
title={title}
Expand Down
1 change: 0 additions & 1 deletion src/frontend/views/data/Details/RelationsTable.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,6 @@ export function EntityRelationTable() {
return (
<DetailsLayout
entity={parentEntity}
childEntity={childEntity}
menuKey={childEntity}
menuItems={menuItems}
>
Expand Down
4 changes: 1 addition & 3 deletions src/frontend/views/data/Details/_Layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -30,13 +30,11 @@ interface IProps {
entity: string;
menuItems?: IDropDownMenuItem[];
menuKey: string;
childEntity?: string;
}

export function DetailsLayout({
children,
entity,
childEntity,
menuKey,
menuItems = [],
}: IProps) {
Expand All @@ -46,7 +44,7 @@ export function DetailsLayout({
EntityActionTypes.Form,
EntityActionTypes.Labels,
],
childEntity
entity
);
const entityId = useEntityId();

Expand Down

0 comments on commit ddd6425

Please sign in to comment.