Skip to content

Commit

Permalink
Merge pull request #1719 from bcgov/1702-fix-default-commit-handler-i…
Browse files Browse the repository at this point in the history
…ssue

Fix: add null and undefined values to optional fields in json schemas
  • Loading branch information
Sepehr-Sobhani authored Jul 21, 2023
2 parents 921267c + 4ba0cae commit e410b49
Show file tree
Hide file tree
Showing 33 changed files with 358 additions and 384 deletions.
2 changes: 1 addition & 1 deletion app/components/Contact/ContactForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ const ContactForm: React.FC<Props> = (props) => {
id: formChange.id,
formDataRecordId: formChange.formDataRecordId,
newFormData: formData,
isUniqueValue: true,
isUniqueValue: isUniqueValue,
changeStatus: "pending",
},
},
Expand Down
21 changes: 14 additions & 7 deletions app/components/Form/ProjectForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -314,20 +314,27 @@ const ProjectForm: React.FC<Props> = (props) => {
},
projectType: {
...projectSchema.properties.projectType,
anyOf: query.allProjectTypes.edges
.map(({ node }) => {
anyOf: [
...query.allProjectTypes.edges.map(({ node }) => {
return {
type: "string",
title: node.name,
enum: [node.name],
value: node.name,
};
})
.sort((a, b) => {
if (b.value === "Other") {
return -1;
} else return 0;
}),
// Add null as an option
{
type: "null",
value: null,
enum: [null],
title: "N/A",
},
].sort((a, b) => {
if (b.value === "Other") {
return -1;
} else return 0;
}),
},
projectStatusId: {
...projectSchema.properties.projectStatusId,
Expand Down
4 changes: 2 additions & 2 deletions app/components/Form/ProjectMilestoneReportForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,7 @@ const ProjectMilestoneReportForm: React.FC<Props> = (props) => {
formChangePatch: {
newFormData: {
...formData,
hasExpenses: reportTypeRecord.node.hasExpenses,
hasExpenses: reportTypeRecord?.node.hasExpenses,
},
},
},
Expand All @@ -233,7 +233,7 @@ const ProjectMilestoneReportForm: React.FC<Props> = (props) => {
id: milestoneNode.id,
newFormData: {
...milestoneChangeData,
hasExpenses: reportTypeRecord.node.hasExpenses,
hasExpenses: reportTypeRecord?.node.hasExpenses,
},
changeStatus: "pending",
},
Expand Down
72 changes: 0 additions & 72 deletions app/components/Form/SelectProjectTypeWidget.tsx

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -485,6 +485,7 @@ describe("when creating a project, the project page", () => {
cy.findByText(/TEIMP End Date/i)
.next()
.contains(/Jan(\.)? 1, 2022/);
cy.contains("Changes saved").should("be.visible"); // a check to make sure happo is taking the right screenshot
cy.happoAndAxe("Auto-generate quarterly reports", "generated", "main");

//generate annual reports
Expand All @@ -509,6 +510,7 @@ describe("when creating a project, the project page", () => {
.next()
.contains(/Feb(\.)? 2, 2024/);
cy.findAllByText(/^on track$/i).should("have.length", 5);
cy.contains("Changes saved").should("be.visible"); // a check to make sure happo is taking the right screenshot
cy.happoAndAxe("Auto-generate annual reports", "generated", "main");
});

Expand Down
15 changes: 10 additions & 5 deletions app/data/jsonSchemaForm/contactSchema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,26 +17,31 @@ const contactSchema = {
pattern: "^[\\.\\w-]+@([\\w-]+\\.)+[\\w-]{2,4}$",
},
phone: {
type: "string",
type: ["null", "string"],
title: "Phone",
pattern:
"^(\\+?\\d{1,2}[\\s,-]?)?\\(?\\d{3}\\)?[\\s.-]?\\d{3}[\\s.-]?\\d{4}$",
default: null,
},
phoneExt: {
type: "string",
type: ["null", "string"],
title: "Phone Extension",
default: null,
},
companyName: {
type: "string",
type: ["null", "string"],
title: "Company Name",
default: null,
},
contactPosition: {
type: "string",
type: ["null", "string"],
title: "Position",
default: null,
},
comments: {
type: "string",
type: ["null", "string"],
title: "Comments",
default: null,
},
},
};
Expand Down
207 changes: 0 additions & 207 deletions app/data/jsonSchemaForm/projectEmissionIntensitySchema.ts

This file was deleted.

Loading

0 comments on commit e410b49

Please sign in to comment.