Skip to content

Commit

Permalink
feat: calculated milestone values diffing
Browse files Browse the repository at this point in the history
  • Loading branch information
gurjmatharu authored and Sepehr-Sobhani committed Jun 29, 2023
1 parent b6c2c3e commit 6f03130
Showing 1 changed file with 57 additions and 4 deletions.
61 changes: 57 additions & 4 deletions app/components/Form/ProjectMilestoneReportFormSummary.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,9 @@ const ProjectMilestoneReportFormSummary: React.FC<Props> = ({
formDataRecordId
isPristine
newFormData
calculatedHoldbackAmountThisMilestone
calculatedGrossAmountThisMilestone
calculatedNetAmountThisMilestone
operation
formChangeByPreviousFormChangeId {
newFormData
Expand Down Expand Up @@ -105,9 +108,40 @@ const ProjectMilestoneReportFormSummary: React.FC<Props> = ({
// Set the formSchema and formData based on showing the diff or not
const milestoneFormDiffObject = renderDiff
? getMilestoneFilteredSchema(
milestoneReport.formByJsonSchemaName.jsonSchema
.schema as JSONSchema7,
milestoneReport
{
...(milestoneReport.formByJsonSchemaName.jsonSchema
.schema as JSONSchema7),
properties: {
...(
milestoneReport.formByJsonSchemaName.jsonSchema
.schema as JSONSchema7
).properties,
calculatedHoldbackAmount: {
title: "Calculated Holdback Amount",
type: "number",
},
calculatedGrossAmount: {
title: "Calculated Gross Amount",
type: "number",
},
calculatedNetAmount: {
title: "Calculated Net Amount",
type: "number",
},
},
},
{
...milestoneReport,
newFormData: {
...milestoneReport.newFormData,
calculatedHoldbackAmount:
milestoneReport.calculatedHoldbackAmountThisMilestone,
calculatedGrossAmount:
milestoneReport.calculatedGrossAmountThisMilestone,
calculatedNetAmount:
milestoneReport.calculatedNetAmountThisMilestone,
},
}
)
: {
formSchema: milestoneReport.formByJsonSchemaName.jsonSchema.schema,
Expand All @@ -131,6 +165,24 @@ const ProjectMilestoneReportFormSummary: React.FC<Props> = ({
}
)?.node?.newFormData;

const updatedUiSchema = {
...projectMilestoneUiSchema,
calculatedHoldbackAmount: {
"ui:widget": "NumberWidget",
hideOptional: true,
isMoney: true,
},
calculatedGrossAmount: {
"ui:widget": "NumberWidget",
hideOptional: true,
isMoney: true,
},
calculatedNetAmount: {
"ui:widget": "NumberWidget",
hideOptional: true,
isMoney: true,
},
};
return (
<div key={index} className="reportContainer">
<header>
Expand Down Expand Up @@ -161,7 +213,7 @@ const ProjectMilestoneReportFormSummary: React.FC<Props> = ({
theme={readOnlyTheme}
fields={renderDiff ? customFields : fields}
schema={milestoneFormDiffObject.formSchema as JSONSchema7}
uiSchema={projectMilestoneUiSchema}
uiSchema={updatedUiSchema}
formData={milestoneFormDiffObject.formData}
formContext={{
operation: milestoneReport.operation,
Expand All @@ -184,6 +236,7 @@ const ProjectMilestoneReportFormSummary: React.FC<Props> = ({
}, [
isFirstRevision,
isOnAmendmentsAndOtherRevisionsPage,
latestCommittedMilestoneFormChanges?.edges,
renderDiff,
sortedMilestoneReports,
]);
Expand Down

0 comments on commit 6f03130

Please sign in to comment.