Skip to content

Commit

Permalink
Multistep multiactions
Browse files Browse the repository at this point in the history
  • Loading branch information
iberdinsky-skilld committed Sep 10, 2024
1 parent 43fc351 commit a0da214
Show file tree
Hide file tree
Showing 22 changed files with 388 additions and 337 deletions.
3 changes: 0 additions & 3 deletions client/.eslintignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,3 @@ node_modules/
**/**/coverage
jest.config.ts
openapi.d.ts

# This is copied file from lib
src/pages/wizard/CustomFieldTemplate.tsx
7 changes: 6 additions & 1 deletion client/openapi.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,12 @@ export interface components {
success: string;
};
WizardFull: components["schemas"]["WizardShort"] & {
steps: components["schemas"]["ActionFull"][];
steps: components["schemas"]["WizardStep"][];
};
WizardStep: {
title?: string;
description?: string;
actions?: components["schemas"]["ActionFull"][];
};
};
responses: {
Expand Down
94 changes: 0 additions & 94 deletions client/src/pages/wizard/CustomFieldTemplate.tsx

This file was deleted.

8 changes: 4 additions & 4 deletions client/src/pages/wizard/FormSteps.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ import Stepper from '@mui/material/Stepper'
import type { FC } from 'react'

interface Step {
id: string
title: string
title?: string
actions?: any
}

interface FormStepsProps {
Expand Down Expand Up @@ -36,8 +36,8 @@ const FormSteps: FC<FormStepsProps> = ({
return (
<div>
<Stepper activeStep={currentStepIndex} orientation="vertical">
{steps.map((step) => (
<Step key={step.id}>
{steps.map((step, idx) => (
<Step key={idx}>
<StepLabel>{step.title}</StepLabel>
</Step>
))}
Expand Down
106 changes: 106 additions & 0 deletions client/src/pages/wizard/ObjectFieldTemplate.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,106 @@
// This is override of
// https://github.com/rjsf-team/react-jsonschema-form/blob/main/packages/mui/src/ObjectFieldTemplate/ObjectFieldTemplate.tsx

import Grid from '@mui/material/Grid';

import {
FormContextType,
ObjectFieldTemplateProps,
RJSFSchema,
StrictRJSFSchema,
canExpand,
descriptionId,
getTemplate,
getUiOptions,
titleId,
} from '@rjsf/utils';

export default function CustomObjectFieldTemplate<
T = any,
S extends StrictRJSFSchema = RJSFSchema,
F extends FormContextType = any
>(props: ObjectFieldTemplateProps<T, S, F>) {
const {
description,
title,
properties,
required,
disabled,
readonly,
uiSchema,
idSchema,
schema,
formData,
onAddClick,
registry,
} = props;
const uiOptions = getUiOptions<T, S, F>(uiSchema);
const TitleFieldTemplate = getTemplate<'TitleFieldTemplate', T, S, F>('TitleFieldTemplate', registry, uiOptions);
const DescriptionFieldTemplate = getTemplate<'DescriptionFieldTemplate', T, S, F>(
'DescriptionFieldTemplate',
registry,
uiOptions
);
// Button templates are not overridden in the uiSchema
const {
ButtonTemplates: { AddButton },
} = registry.templates;




if (uiOptions.CustomObjectTemplate === 'domains') {
// return (<>eee</>)
}

return (
<>
{title && (
<TitleFieldTemplate
id={titleId<T>(idSchema)}
title={title}
required={required}
schema={schema}
uiSchema={uiSchema}
registry={registry}
/>
)}
{description && (
<DescriptionFieldTemplate
id={descriptionId<T>(idSchema)}
description={description}
schema={schema}
uiSchema={uiSchema}
registry={registry}
/>
)}
<Grid container={true} spacing={2} style={{ marginTop: '10px' }}>
{properties.map((element, index) =>
// Remove the <Grid> if the inner element is hidden as the <Grid>
// itself would otherwise still take up space.
element.hidden ? (
element.content
) : (
<Grid item={true} xs={12} key={index} style={{ marginBottom: '10px' }}>
test
{element.content}
</Grid>
)
)}
{canExpand<T, S, F>(schema, uiSchema, formData) && (
<Grid container justifyContent='flex-end'>
<Grid item={true}>
<AddButton
className='object-property-expand'
onClick={onAddClick(schema)}
disabled={disabled || readonly}
uiSchema={uiSchema}
registry={registry}
/>
</Grid>
</Grid>
)}
</Grid>
</>
);
}
Loading

0 comments on commit a0da214

Please sign in to comment.