Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions packages/backend/src/graphql/schema.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -287,6 +287,7 @@ type ActionSubstepArgument {

# Only for multirow
subFields: [ActionSubstepArgument]
maxRows: String

# Only for rich text
customRteMenuOptions: [RteMenuOption]
Expand Down
1 change: 1 addition & 0 deletions packages/frontend/src/components/InputCreator/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -222,6 +222,7 @@ export default function InputCreator(props: InputCreatorProps): JSX.Element {
type={type}
// These are InputCreatorProps which MultiRow will forward.
stepId={stepId}
maxRows={schema.maxRows}
/>
)
}
Expand Down
24 changes: 15 additions & 9 deletions packages/frontend/src/components/MultiRow/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ export type MultiRowProps = {
showDivider?: boolean
addRowButtonText?: string
type?: string
maxRows?: number
} & Omit<InputCreatorProps, 'schema' | 'namePrefix'>

function MultiRow(props: MultiRowProps): JSX.Element {
Expand All @@ -36,6 +37,7 @@ function MultiRow(props: MultiRowProps): JSX.Element {
addRowButtonText,
showDivider,
type,
maxRows,
...forwardedInputCreatorProps
} = props

Expand Down Expand Up @@ -86,6 +88,8 @@ function MultiRow(props: MultiRowProps): JSX.Element {
const rowsToRender =
!rows.length && required ? [{ ...newRowDefaultValue }] : rows
const canRemoveRow = !required || rowsToRender.length > 1
const canAddRow =
maxRows == null || rowsToRender.length < Number(maxRows)

return (
<Flex flexDir="column">
Expand Down Expand Up @@ -171,15 +175,17 @@ function MultiRow(props: MultiRowProps): JSX.Element {
)
})}

<Button
variant="outline"
leftIcon={<BiPlus />}
onClick={handleAddRow}
isDisabled={isEditorReadOnly}
maxW="fit-content"
>
{addRowButtonText ?? 'And'}
</Button>
{canAddRow && (
<Button
variant="outline"
leftIcon={<BiPlus />}
onClick={handleAddRow}
isDisabled={isEditorReadOnly}
maxW="fit-content"
>
{addRowButtonText ?? 'And'}
</Button>
)}
</Flex>
)
}}
Expand Down
1 change: 1 addition & 0 deletions packages/frontend/src/graphql/queries/get-apps.ts
Original file line number Diff line number Diff line change
Expand Up @@ -267,6 +267,7 @@ export const GET_APPS = gql`
}
singleVariableSelection
}
maxRows
}
}
}
Expand Down
2 changes: 2 additions & 0 deletions packages/types/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -450,6 +450,7 @@ export interface IFieldMultiRowMultiCol extends IBaseField {
value?: string
addRowButtonText?: string
subFields: IFieldMultiRowMultiColSubField[]
maxRows?: number
}

export interface IFieldMultiRow extends IBaseField {
Expand All @@ -458,6 +459,7 @@ export interface IFieldMultiRow extends IBaseField {
addRowButtonText?: string

subFields: IField[]
maxRows?: number
}

export type TRteMenuOption =
Expand Down
Loading