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

feat: gis assessment history display #3284

Merged
Show file tree
Hide file tree
Changes from all 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
47 changes: 42 additions & 5 deletions app/components/Analyst/History/HistoryContent.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ import projectInformationSchema from 'formSchema/uiSchema/history/projectInforma
import { diff } from 'json-diff';
import conditionalApprovalSchema from 'formSchema/uiSchema/history/conditionalApproval';
import screeningSchema from 'formSchema/uiSchema/history/screening';
import gis from 'formSchema/uiSchema/history/gis';
import gisAssessmentHhSchema from 'formSchema/uiSchema/history/gisAssessmentHh';
import StatusPill from '../../StatusPill';
import HistoryDetails from './HistoryDetails';
import HistoryAttachment from './HistoryAttachment';
Expand Down Expand Up @@ -386,6 +388,7 @@ const HistoryContent = ({ historyItem, prevHistoryItem }) => {

const assessmentSchema = (assessmentName) => {
if (assessmentName === 'screening') return screeningSchema;
if (assessmentName === 'gis') return gis;
return {};
};

Expand All @@ -395,7 +398,8 @@ const HistoryContent = ({ historyItem, prevHistoryItem }) => {
prevAssessmentFilesArray
);

const isScreeningAssessment = assessmentType === 'screening';
const isDetailedAssessment =
assessmentType === 'gis' || assessmentType === 'screening';

return (
<div>
Expand All @@ -404,7 +408,7 @@ const HistoryContent = ({ historyItem, prevHistoryItem }) => {
<b>{formatAssessment(assessmentType)} Assessment</b>
<span> on {createdAtFormatted}</span>
</StyledContent>
{showHistoryDetails && isScreeningAssessment && (
{showHistoryDetails && isDetailedAssessment && (
<HistoryDetails
json={record.json_data}
prevJson={prevHistoryItem?.record?.json_data || {}}
Expand All @@ -419,10 +423,10 @@ const HistoryContent = ({ historyItem, prevHistoryItem }) => {
'otherFiles',
'assessmentTemplate',
]}
overrideParent="screening"
overrideParent={assessmentType}
/>
)}
{showOtherFilesDiff && isScreeningAssessment && (
{showOtherFilesDiff && isDetailedAssessment && (
<HistoryFile
filesArray={record.json_data?.otherFiles || []}
previousFileArray={
Expand All @@ -431,7 +435,7 @@ const HistoryContent = ({ historyItem, prevHistoryItem }) => {
title={`${formatAssessment(assessmentType)} Other Files`}
/>
)}
{showAssessmentFilesDiff && isScreeningAssessment && (
{showAssessmentFilesDiff && isDetailedAssessment && (
<HistoryFile
filesArray={assessmentFilesArray}
previousFileArray={prevAssessmentFilesArray}
Expand Down Expand Up @@ -505,6 +509,39 @@ const HistoryContent = ({ historyItem, prevHistoryItem }) => {
);
}

if (tableName === 'application_gis_assessment_hh') {
return (
<div>
<StyledContent data-testid="history-content-gis-assessment-hh">
<span>
{displayName}
{' updated the '}
<b>GIS Assessment Household Count </b>
</span>
on {createdAtFormatted}
</StyledContent>
{showHistoryDetails && (
<HistoryDetails
json={record}
prevJson={prevHistoryItem?.record || {}}
excludedKeys={[
'id',
'updated_at',
'created_at',
'created_by',
'updated_by',
'archived_at',
'archived_by',
]}
diffSchema={gisAssessmentHhSchema}
overrideParent="gis"
/>
)}
{reasonForChange && <ChangeReason reason={reasonForChange} />}
</div>
);
}

if (tableName === 'project_information_data') {
// Generate a diff for all the file arrays
// will return undefined if no changes
Expand Down
23 changes: 23 additions & 0 deletions app/formSchema/uiSchema/history/gis.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import commonAssessment from './commonAssessment';

const gis = {
gis: {
properties: {
...commonAssessment,
commentsOnCoverageData: {
title: 'Comments on coverage data',
},
commentsOnHouseholdCounts: {
title: 'Comments on household counts',
},
commentsOnOverbuild: {
title: 'Comments on overbuild',
},
commentsOnOverlap: {
title: 'Comments on overlap',
},
},
},
};

export default gis;
14 changes: 14 additions & 0 deletions app/formSchema/uiSchema/history/gisAssessmentHh.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
const gisAssessmentHh = {
gis: {
properties: {
eligible: {
title: 'Eligible',
},
eligible_indigenous: {
title: 'Eligible Indigenous',
},
},
},
};

export default gisAssessmentHh;
Loading
Loading