Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MAT-7790: Function Builder defaults #382

Merged
merged 3 commits into from
Nov 25, 2024
Merged
Show file tree
Hide file tree
Changes from 2 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
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
10 changes: 10 additions & 0 deletions src/validations/FunctionSectionSchemaValidator.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import * as Yup from "yup";

export const FunctionSectionSchemaValidator = Yup.object().shape({
functionName: Yup.string()
.required("Function name is required")
.matches(/^[a-zA-Z0-9]*$/, "No spaces or special characters are allowed"),
adongare marked this conversation as resolved.
Show resolved Hide resolved
comment: Yup.string(),
fluentFunction: Yup.boolean(),
body: Yup.string(),
});
Loading