- {children}
+
+ {displayLabel && (
+
+ )}
+ {help}
+ {children}
-
- {rawErrors && rawErrors.length > 0 ? (
- <>
-
- {errors}
- >
- ) : null}
-
- {help}
+
+ {rawErrors && rawErrors.length > 0 ? (
+ <>
+
+ {errors}
+ >
+ ) : null}
+
- >
+
);
};
diff --git a/app/lib/theme/ReadOnlyFieldTemplate.tsx b/app/lib/theme/ReadOnlyFieldTemplate.tsx
new file mode 100644
index 0000000000..1265faabbc
--- /dev/null
+++ b/app/lib/theme/ReadOnlyFieldTemplate.tsx
@@ -0,0 +1,67 @@
+import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
+import { faExclamationTriangle } from "@fortawesome/free-solid-svg-icons";
+import { FieldTemplateProps } from "@rjsf/core";
+import FieldLabel from "./widgets/FieldLabel";
+
+const FieldTemplate: React.FC
= ({
+ children,
+ errors,
+ rawErrors,
+ label,
+ displayLabel,
+ required,
+ id,
+}) => {
+ return (
+
+
+ {displayLabel && (
+
+ )}
+ {children}
+
+ {rawErrors && rawErrors.length > 0 ? (
+
+
+ {errors}
+
+ ) : null}
+
+
+
+ );
+};
+
+export default FieldTemplate;
diff --git a/app/lib/theme/ReadOnlyTheme.tsx b/app/lib/theme/ReadOnlyTheme.tsx
index a84a1d28e5..dcfcaefd4f 100644
--- a/app/lib/theme/ReadOnlyTheme.tsx
+++ b/app/lib/theme/ReadOnlyTheme.tsx
@@ -1,5 +1,5 @@
import { ThemeProps } from "@rjsf/core";
-import FieldTemplate from "./FieldTemplate";
+import ReadOnlyFieldTemplate from "./ReadOnlyFieldTemplate";
import ReadOnlyObjectFieldTemplate from "./ReadOnlyObjectFieldTemplate";
import { utils } from "@rjsf/core";
import ReadOnlyWidget from "./widgets/ReadOnlyWidget";
@@ -23,7 +23,7 @@ const readOnlyTheme: ThemeProps = {
SelectProjectStatusWidget: ReadOnlyWidget,
},
ObjectFieldTemplate: ReadOnlyObjectFieldTemplate,
- FieldTemplate: FieldTemplate,
+ FieldTemplate: ReadOnlyFieldTemplate,
};
export default readOnlyTheme;
diff --git a/app/lib/theme/utils/getRequiredLabel.ts b/app/lib/theme/utils/getRequiredLabel.ts
deleted file mode 100644
index ae00ef1511..0000000000
--- a/app/lib/theme/utils/getRequiredLabel.ts
+++ /dev/null
@@ -1,4 +0,0 @@
-const getRequiredLabel = (label: string, required: boolean) =>
- label + (required ? "" : " (optional)");
-
-export default getRequiredLabel;
diff --git a/app/lib/theme/widgets/DisplayOnlyWidget.tsx b/app/lib/theme/widgets/DisplayOnlyWidget.tsx
index c44a843c1e..f6a461a64b 100644
--- a/app/lib/theme/widgets/DisplayOnlyWidget.tsx
+++ b/app/lib/theme/widgets/DisplayOnlyWidget.tsx
@@ -1,12 +1,7 @@
import { WidgetProps } from "@rjsf/core";
-const DisplayOnlyWidget: React.FC = ({ options }) => {
- return (
-
- {options.title}
- {options.text}
-
- );
+const DisplayOnlyWidget: React.FC = ({ options, id }) => {
+ return {options.text} ;
};
export default DisplayOnlyWidget;
diff --git a/app/lib/theme/widgets/FieldLabel.tsx b/app/lib/theme/widgets/FieldLabel.tsx
index 6aba3a2608..deeb0c826e 100644
--- a/app/lib/theme/widgets/FieldLabel.tsx
+++ b/app/lib/theme/widgets/FieldLabel.tsx
@@ -1,32 +1,33 @@
-import { UiSchema } from "@rjsf/core";
-import getRequiredLabel from "../utils/getRequiredLabel";
-
interface Props {
label: string;
required: boolean;
htmlFor: string;
- uiSchema?: UiSchema;
+ tagName?: "label" | "dt";
}
const FieldLabel: React.FC = ({
label,
required,
htmlFor,
- uiSchema,
+ tagName = "label",
}) => {
- if (
- uiSchema &&
- uiSchema["ui:options"] &&
- uiSchema["ui:options"].label === false
- ) {
+ if (!label) {
return null;
}
+
+ const displayedLabel = label + (required ? "" : " (optional)") + " ";
+
+ if (tagName === "label")
+ return {displayedLabel} ;
+
return (
<>
- {getRequiredLabel(label, required)}
- {uiSchema && uiSchema["bcgov:help-text"] && (
- {uiSchema["bcgov:help-text"]}
- )}
+ {displayedLabel}
+
>
);
};
diff --git a/app/lib/theme/widgets/MoneyWidget.tsx b/app/lib/theme/widgets/MoneyWidget.tsx
index 4f4463275d..2bb1257492 100644
--- a/app/lib/theme/widgets/MoneyWidget.tsx
+++ b/app/lib/theme/widgets/MoneyWidget.tsx
@@ -1,25 +1,16 @@
import { WidgetProps } from "@rjsf/core";
import NumberFormat from "react-number-format";
-import FieldLabel from "./FieldLabel";
export const MoneyWidget: React.FC = ({
schema,
id,
disabled,
label,
- required,
onChange,
value,
- uiSchema,
}) => {
return (
-
= ({
schema,
id,
disabled,
label,
- required,
onChange,
value,
- uiSchema,
}) => {
return (
<>
-
= ({ id, label, value }) => {
+const ReadOnlyMoneyWidget: React.FC = ({ id, value }) => {
return (
- <>
- {label}
-
- {value ? (
-
- ) : (
- Not added
- )}
-
- >
+
+ {value ? (
+
+ ) : (
+ Not added
+ )}
+
);
};
diff --git a/app/lib/theme/widgets/ReadOnlyWidget.tsx b/app/lib/theme/widgets/ReadOnlyWidget.tsx
index e6ca612363..2698ab4bb3 100644
--- a/app/lib/theme/widgets/ReadOnlyWidget.tsx
+++ b/app/lib/theme/widgets/ReadOnlyWidget.tsx
@@ -1,11 +1,14 @@
import { WidgetProps } from "@rjsf/core";
-const ReadOnlyWidget: React.FC = ({ label, value, options }) => {
+const ReadOnlyWidget: React.FC = ({ value, options }) => {
return (
<>
- {/* Some of the uiSchemas that use this widget have the label text in the label prop; others have it in options.title. Similarly, some uiSchemas have the value in the value prop; others in options.text. */}
- {options.title ?? label}
-
{options.text ?? value ?? Not added }
+
>
);
};
diff --git a/app/lib/theme/widgets/SearchDropdownWidget.tsx b/app/lib/theme/widgets/SearchDropdownWidget.tsx
index 5812bf385b..5b21affa15 100644
--- a/app/lib/theme/widgets/SearchDropdownWidget.tsx
+++ b/app/lib/theme/widgets/SearchDropdownWidget.tsx
@@ -3,20 +3,10 @@ import { WidgetProps } from "@rjsf/core";
import Widgets from "@rjsf/core/dist/cjs/components/widgets";
import TextField from "@mui/material/TextField";
import Autocomplete from "@mui/material/Autocomplete";
-import FieldLabel from "./FieldLabel";
import KeyboardArrowDownIcon from "@mui/icons-material/KeyboardArrowDown";
const SearchDropdownWidget: React.FC = (props) => {
- const {
- id,
- onChange,
- schema,
- placeholder,
- readonly,
- label,
- required,
- uiSchema,
- } = props;
+ const { id, onChange, schema, placeholder, readonly } = props;
const handleChange = (e: React.ChangeEvent<{}>, option: any) => {
onChange(option?.value);
@@ -33,52 +23,44 @@ const SearchDropdownWidget: React.FC = (props) => {
if (readonly) return ;
return (
- <>
-
-
- props.value ? option.value === props.value : true
- }
- getOptionLabel={(option) => (option ? option.title : "")}
- sx={{
- border: "2px solid #606060",
- borderRadius: "0.25em",
- marginTop: "0.2em",
- "&.Mui-focused": {
- outlineStyle: "solid",
- outlineWidth: "4px",
- outlineColor: "#3B99FC",
- outlineOffset: "1px",
- },
- }}
- popupIcon={ }
- renderInput={(params) => {
- return (
-
- );
- }}
- />
- >
+
+ props.value ? option.value === props.value : true
+ }
+ getOptionLabel={(option) => (option ? option.title : "")}
+ sx={{
+ border: "2px solid #606060",
+ borderRadius: "0.25em",
+ marginTop: "0.2em",
+ "&.Mui-focused": {
+ outlineStyle: "solid",
+ outlineWidth: "4px",
+ outlineColor: "#3B99FC",
+ outlineOffset: "1px",
+ },
+ }}
+ popupIcon={ }
+ renderInput={(params) => {
+ return (
+
+ );
+ }}
+ />
);
};
diff --git a/app/lib/theme/widgets/SelectWidget.tsx b/app/lib/theme/widgets/SelectWidget.tsx
index a1f8006585..4d465eadb9 100644
--- a/app/lib/theme/widgets/SelectWidget.tsx
+++ b/app/lib/theme/widgets/SelectWidget.tsx
@@ -1,6 +1,5 @@
import { WidgetProps } from "@rjsf/core";
import Dropdown from "@button-inc/bcgov-theme/Dropdown";
-import FieldLabel from "./FieldLabel";
interface Option {
type: string;
@@ -28,12 +27,6 @@ const SelectWidget: React.FunctionComponent = (props) => {
return (
-
onChange(e.target.value || undefined)}
diff --git a/app/lib/theme/widgets/TextAreaWidget.tsx b/app/lib/theme/widgets/TextAreaWidget.tsx
index 86fd46837b..b6607f4130 100644
--- a/app/lib/theme/widgets/TextAreaWidget.tsx
+++ b/app/lib/theme/widgets/TextAreaWidget.tsx
@@ -1,6 +1,5 @@
import { WidgetProps } from "@rjsf/core";
import Textarea from "@button-inc/bcgov-theme/Textarea";
-import FieldLabel from "./FieldLabel";
const TextAreaWidget: React.FC = ({
id,
@@ -9,16 +8,9 @@ const TextAreaWidget: React.FC = ({
label,
value,
required,
- uiSchema,
}) => {
return (
- <>
-
+
);
};
diff --git a/app/lib/theme/widgets/TextWidget.tsx b/app/lib/theme/widgets/TextWidget.tsx
index 8984cd34f4..2578006b7b 100644
--- a/app/lib/theme/widgets/TextWidget.tsx
+++ b/app/lib/theme/widgets/TextWidget.tsx
@@ -1,8 +1,6 @@
import { WidgetProps } from "@rjsf/core";
import Input from "@button-inc/bcgov-theme/Input";
-import FieldLabel from "./FieldLabel";
-
const TextWidget: React.FC = ({
id,
placeholder,
@@ -10,16 +8,9 @@ const TextWidget: React.FC = ({
label,
value,
required,
- uiSchema,
}) => {
return (
- <>
-
+
onChange(e.target.value || undefined)}
@@ -31,12 +22,12 @@ const TextWidget: React.FC = ({
/>
- >
+
);
};
diff --git a/app/tests/unit/components/Form/ProjectForm.test.tsx b/app/tests/unit/components/Form/ProjectForm.test.tsx
index 126830615f..28961bf210 100644
--- a/app/tests/unit/components/Form/ProjectForm.test.tsx
+++ b/app/tests/unit/components/Form/ProjectForm.test.tsx
@@ -204,6 +204,8 @@ describe("The Project Form", () => {
fundingStreamRfpId: 1,
projectName: "test project name",
totalFundingRequest: 12345,
+ projectStatusId: 1,
+ operatorTradeName: "test trade name",
},
},
};
diff --git a/app/tests/unit/components/Form/__snapshots__/FormBase.test.tsx.snap b/app/tests/unit/components/Form/__snapshots__/FormBase.test.tsx.snap
index 6e33be2e6e..e50c45ce4d 100644
--- a/app/tests/unit/components/Form/__snapshots__/FormBase.test.tsx.snap
+++ b/app/tests/unit/components/Form/__snapshots__/FormBase.test.tsx.snap
@@ -7,7 +7,7 @@ exports[`The FormBase component renders a test schema with the default theme 1`]
novalidate=""
>
@@ -53,7 +57,7 @@ exports[`The FormBase component renders a test schema with the default theme 1`]
@@ -67,26 +71,32 @@ exports[`The FormBase component renders a test schema with the readonly theme 1`
novalidate=""
>
-
-
-
- field
-
-
- test
-
+
+
+ class="jsx-141906859"
+ >
+
+
+ field
+
+
+ test
+
+
+
-
diff --git a/app/tests/unit/lib/theme/widgets/__snapshots__/SearchDropdown.test.tsx.snap b/app/tests/unit/lib/theme/widgets/__snapshots__/SearchDropdown.test.tsx.snap
index 1f0750040b..354cff7fec 100644
--- a/app/tests/unit/lib/theme/widgets/__snapshots__/SearchDropdown.test.tsx.snap
+++ b/app/tests/unit/lib/theme/widgets/__snapshots__/SearchDropdown.test.tsx.snap
@@ -2,11 +2,6 @@
exports[`The SearchDropdown Widget Matches the snapshot with a default value set 1`] = `
-
- Search (optional)
-