Skip to content

Commit

Permalink
MAT-7790: Function Builder defaults (#382)
Browse files Browse the repository at this point in the history
* MAT-7790: update defaults and fix button movement

* MAT-7790: fix styles

* MAT-7790: remove function name validation
  • Loading branch information
chubert-sb authored Nov 25, 2024
1 parent 5ac33f6 commit fb951f0
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 1 deletion.
3 changes: 3 additions & 0 deletions src/CqlBuilderPanel/definitionsSection/Definitions.scss
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,9 @@
margin-top: 1rem;
margin-right: 32px;
}
> #clear-definition-btn:focus {
margin-right: 16px;
}
> button[type="submit"] {
margin-top: 0;
}
Expand Down
3 changes: 3 additions & 0 deletions src/CqlBuilderPanel/functionsSection/Functions.scss
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,9 @@
margin-top: 1rem;
margin-right: 32px;
}
> #clear-function-btn:focus {
margin-right: 16px;
}
> button[type="submit"] {
margin-top: 0;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import {
TextField,
} from "@madie/madie-design-system/dist/react";
import "../Functions.scss";
import { FunctionSectionSchemaValidator } from "../../../validations/FunctionSectionSchemaValidator";
import ExpandingSection from "../../../common/ExpandingSection";
import { Checkbox, FormControlLabel } from "@mui/material";
import { Box } from "@mui/system";
Expand Down Expand Up @@ -45,8 +46,9 @@ export default function FunctionBuilder({
initialValues: {
functionName: funct?.functionName || "",
comment: funct?.comment || "",
fluentFunction: funct?.fluentFunction || false,
fluentFunction: funct?.fluentFunction || true,
},
validationSchema: FunctionSectionSchemaValidator,
enableReinitialize: true,
onSubmit: (values) => {},
});
Expand All @@ -69,6 +71,8 @@ export default function FunctionBuilder({
inputProps={{
"data-testid": "function-name-text-input",
}}
error={Boolean(formik.errors.functionName)}
helperText={formik.errors.functionName}
{...formik.getFieldProps("functionName")}
/>
</div>
Expand Down Expand Up @@ -120,6 +124,7 @@ export default function FunctionBuilder({
/>
<div className="form-actions">
<Button
id="clear-function-btn"
variant="outline"
data-testid="clear-function-btn"
disabled={!formik.dirty || !canEdit}
Expand All @@ -133,6 +138,7 @@ export default function FunctionBuilder({
<Button
data-testid={`function-apply-btn`}
disabled={!formik.values.functionName || !canEdit || !formik.dirty}
// tw="ml-4"
onClick={() => {}}
>
Apply
Expand Down
8 changes: 8 additions & 0 deletions src/validations/FunctionSectionSchemaValidator.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import * as Yup from "yup";

export const FunctionSectionSchemaValidator = Yup.object().shape({
functionName: Yup.string().required("Function name is required"),
comment: Yup.string(),
fluentFunction: Yup.boolean(),
body: Yup.string(),
});

0 comments on commit fb951f0

Please sign in to comment.