Skip to content

Commit

Permalink
feat: Add COORS Number to Complaints (#723)
Browse files Browse the repository at this point in the history
Co-authored-by: gregorylavery <[email protected]>
  • Loading branch information
afwilcox and gregorylavery authored Oct 28, 2024
1 parent 5b7147c commit bb20e33
Show file tree
Hide file tree
Showing 20 changed files with 542 additions and 7 deletions.
20 changes: 20 additions & 0 deletions backend/src/middleware/maps/automapper-entity-to-dto-maps.ts
Original file line number Diff line number Diff line change
Expand Up @@ -243,6 +243,10 @@ export const complaintToComplaintDtoMap = (mapper: Mapper) => {
(destination) => destination.webeocId,
mapFrom((source) => source.webeoc_identifier),
),
forMember(
(destination) => destination.referenceNumber,
mapFrom((source) => source.reference_number),
),
forMember(
(destination) => destination.complaintMethodReceivedCode,
mapFrom((source) => {
Expand Down Expand Up @@ -692,6 +696,10 @@ export const applyWildlifeComplaintMap = (mapper: Mapper) => {
(destination) => destination.webeocId,
mapFrom((source) => source.complaint_identifier.webeoc_identifier),
),
forMember(
(destination) => destination.referenceNumber,
mapFrom((source) => source.complaint_identifier.reference_number),
),
forMember(
(destination) => destination.complaintMethodReceivedCode,
mapFrom((source) => {
Expand Down Expand Up @@ -915,6 +923,10 @@ export const applyAllegationComplaintMap = (mapper: Mapper) => {
(destination) => destination.webeocId,
mapFrom((source) => source.complaint_identifier.webeoc_identifier),
),
forMember(
(destination) => destination.referenceNumber,
mapFrom((source) => source.complaint_identifier.reference_number),
),
forMember(
(destination) => destination.complaintMethodReceivedCode,
mapFrom((source) => {
Expand Down Expand Up @@ -1432,6 +1444,10 @@ export const mapWildlifeReport = (mapper: Mapper, tz: string = "America/Vancouve
(destination) => destination.webeocId,
mapFrom((source) => source.complaint_identifier.webeoc_identifier),
),
forMember(
(destination) => destination.referenceNumber,
mapFrom((source) => source.complaint_identifier.reference_number),
),
forMember(
(destination) => destination.complaintMethodReceivedCode,
mapFrom((source) => {
Expand Down Expand Up @@ -1723,6 +1739,10 @@ export const mapAllegationReport = (mapper: Mapper, tz: string = "America/Vancou
(destination) => destination.webeocId,
mapFrom((source) => source.complaint_identifier.webeoc_identifier),
),
forMember(
(destination) => destination.referenceNumber,
mapFrom((source) => source.complaint_identifier.reference_number),
),
forMember(
(destination) => destination.complaintMethodReceivedCode,
mapFrom((source) => {
Expand Down
6 changes: 6 additions & 0 deletions backend/src/middleware/maps/dto-to-table-map.ts
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,12 @@ export const mapComplaintDtoToComplaintTable = (mapper: Mapper) => {
};
}),
),
forMember(
(dest) => dest.reference_number,
mapFrom((src) => {
return src.referenceNumber;
}),
),
forMember(
(dest) => dest.is_privacy_requested,
mapFrom((src) => {
Expand Down
1 change: 1 addition & 0 deletions backend/src/types/models/complaints/complaint.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ export interface ComplaintDto {
};
delegates: Array<DelegateDto>;
webeocId: string;
referenceNumber: string;
complaintMethodReceivedCode: string;
isPrivacyRequested: string;
}
7 changes: 7 additions & 0 deletions backend/src/types/models/complaints/update-complaint.dto.ts
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,13 @@ export class UpdateComplaintDto {
})
webeoc_identifier: string;

@ApiProperty({
example: "54321",
description:
"Allows users to link complaints to files in external systems. Currently labeled in the system as COORS reference number and initially only used for COORS linkages.",
})
reference_number: string;

@ApiProperty({
example: "RAPP",
description: "Method in which the complaint was created",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ export interface ComplaintReportData {
locationDescription: string;
description: string;
webeocId: string;
referenceNumber: string;
complaintMethodReceivedCode: string;

//-- caller information
Expand Down
3 changes: 3 additions & 0 deletions backend/src/v1/complaint/complaint.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -388,6 +388,9 @@ export class ComplaintService {
qb.orWhere("complaint.reported_by_other_text ILIKE :query", {
query: `%${query}%`,
});
qb.orWhere("complaint.reference_number ILIKE :query", {
query: `%${query}%`,
});

qb.orWhere("reported_by.short_description ILIKE :query", {
query: `%${query}%`,
Expand Down
10 changes: 10 additions & 0 deletions backend/src/v1/complaint/entities/complaint.entity.ts
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,14 @@ export class Complaint {
@Column({ length: 20 })
webeoc_identifier: string;

@ApiProperty({
example: "54321",
description:
"Allows users to link complaints to files in external systems. Currently labeled in the system as COORS reference number and initially only used for COORS linkages.",
})
@Column({ length: 20 })
reference_number: string;

@ApiProperty({
example: "43.43,-123.55",
description: "The lat/long point of the complaint",
Expand Down Expand Up @@ -235,6 +243,7 @@ export class Complaint {
cos_geo_org_unit?: CosGeoOrgUnit,
person_complaint_xref?: PersonComplaintXref[],
webeoc_identifier?: string,
reference_number?: string,
comp_mthd_recv_cd_agcy_cd_xref?: CompMthdRecvCdAgcyCdXref,
is_privacy_requested?: string,
) {
Expand Down Expand Up @@ -263,6 +272,7 @@ export class Complaint {
this.cos_geo_org_unit = cos_geo_org_unit;
this.person_complaint_xref = person_complaint_xref;
this.webeoc_identifier = webeoc_identifier;
this.reference_number = reference_number;
this.comp_mthd_recv_cd_agcy_cd_xref = comp_mthd_recv_cd_agcy_cd_xref;
this.is_privacy_requested = is_privacy_requested;
}
Expand Down
Binary file modified backend/templates/complaint/CDOGS-ERS-COMPLAINT-TEMPLATE-v1.docx
Binary file not shown.
Binary file modified backend/templates/complaint/CDOGS-HWCR-COMPLAINT-TEMPLATE-v1.docx
Binary file not shown.
132 changes: 132 additions & 0 deletions frontend/cypress/e2e/external-file-reference.cy.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,132 @@
import COMPLAINT_TYPES from "../../src/app/types/app/complaint-types";

const complaintTypes = [COMPLAINT_TYPES.HWCR, COMPLAINT_TYPES.ERS];

describe("External File Reference", () => {
beforeEach(function () {
cy.viewport("macbook-16");
cy.kcLogout().kcLogin();
});

function enterReferenceNumber(number: string, shouldSave: boolean) {
cy.get("#external-file-reference-number-input").click({ force: true });
cy.get("#external-file-reference-number-input").clear().type(number, { delay: 0 });
if (shouldSave) {
cy.get("#external-file-reference-save-button").click();
}
}

function navigateToComplaint(index: number) {
if (COMPLAINT_TYPES.HWCR.includes(complaintTypes[index])) {
cy.navigateToDetailsScreen(COMPLAINT_TYPES.HWCR, "23-031226", true);
} else {
cy.navigateToDetailsScreen(COMPLAINT_TYPES.ERS, "23-027918", true);
}
}

function deleteReferenceNumber() {
cy.get("#external-file-reference").then(function ($externalref) {
if ($externalref.find("#external-file-reference-delete-button").length) {
cy.get("#external-file-reference-delete-button").click();
cy.get(".modal-footer > .btn-primary").click();
} else {
cy.log("No reference number to delete");
}
});
}

function validateFormIsEmpty() {
cy.get("#external-file-reference-number-input").should("exist");
cy.get("#external-file-reference-number-div").should(($div) => {
expect($div).to.not.contain.text("111111");
expect($div).to.not.contain.text("222222");
expect($div).to.not.contain.text("333333");
});
}

//Core tests - try these on both complaint types

Cypress._.times(complaintTypes.length, (index) => {
it(`Can enter an external reference number: ${complaintTypes[index]}`, () => {
//navigatetoComplaint
navigateToComplaint(index);

//make sure that there isn't an old one there from a failed run
deleteReferenceNumber();

//enter the number
enterReferenceNumber("111111", true);

//validate the number
cy.get("#external-file-reference-number-div").should(($div) => {
expect($div).to.contain.text("111111");
});
});

it(`Can edit an external reference number: ${complaintTypes[index]}`, () => {
//navigatetoComplaint
navigateToComplaint(index);

//press Edit
cy.get("#external-file-reference-edit-button").click();

//enter the number
enterReferenceNumber("222222", true);

//validate the number
cy.get("#external-file-reference-number-div").should(($div) => {
expect($div).to.contain.text("222222");
});
});

it(`Can delete an external reference number: ${complaintTypes[index]}`, () => {
//navigatetoComplaint
navigateToComplaint(index);

//press Delete
deleteReferenceNumber();

//validate the toast
cy.get(".Toastify__toast-body").then(($toast) => {
expect($toast).to.contain.text("Updates have been saved");
});

//validate that the empty input is showing
validateFormIsEmpty();
});
});

//Secondary tests - only need to try these on one complaint type
it("Can cancel pending changes to a reference file number (new)", () => {
//navigatetoComplaint
navigateToComplaint(0);

//attempt to delete if there is old data
deleteReferenceNumber();

//enter the number
enterReferenceNumber("333333", false);

cy.get("#external-file-reference").then(function ($externalref) {
cy.get("#external-file-reference-cancel-button").click();
cy.get(".modal-footer > .btn-primary").click();
});

//validate that the empty input is showing
validateFormIsEmpty();
});

it("Will not accept a reference file number with letters", () => {
//navigatetoComplaint
navigateToComplaint(1);

//make sure that there isn't an old one there from a failed run
deleteReferenceNumber();

//enter the number
enterReferenceNumber("444BADNUMBER44", true);

//validate the error message
cy.hasErrorMessage(["#external-file-reference-number-div"]);
});
});
11 changes: 7 additions & 4 deletions frontend/cypress/support/commands.ts
Original file line number Diff line number Diff line change
Expand Up @@ -131,16 +131,19 @@ Cypress.Commands.add("kcLogout", () => {
});
});

Cypress.Commands.add("hasErrorMessage", (inputs: Array<string>, toastText: string) => {
Cypress.Commands.add("hasErrorMessage", (inputs: Array<string>, toastText?: string) => {
//validate all the inputs
Cypress._.times(inputs.length, (index) => {
cy.get(inputs[index]).find(".error-message").should("exist");
});

//validate the toast
cy.get(".Toastify__toast-body").then(($toast) => {
expect($toast).to.contain.text(toastText);
});
if(toastText)
{
cy.get(".Toastify__toast-body").then(($toast) => {
expect($toast).to.contain.text(toastText);
});
}
});

Cypress.Commands.add("verifyMapMarkerExists", (existIndicator: boolean) => {
Expand Down
2 changes: 1 addition & 1 deletion frontend/cypress/support/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,6 @@ declare namespace Cypress {
validateComplaint(complaintIdentifier: string, species: string): Chainable<void>;
fillInHWCSection(section: HwcSection): Chainable<void>;
validateHWCSection(section: HwcSection): Chainable<void>;
hasErrorMessage(inputs: Array<string>, toastText: string): Chainable<void>;
hasErrorMessage(inputs: Array<string>, toastText?: string): Chainable<void>;
}
}
23 changes: 23 additions & 0 deletions frontend/src/app/common/methods.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@ import { fromImage } from "imtool";
import AttachmentEnum from "../constants/attachment-enum";
import Option from "../types/app/option";
import { GirType } from "../types/app/code-tables/gir-type";
import { WildlifeComplaint as WildlifeComplaintDto } from "../types/app/complaints/wildlife-complaint";
import { AllegationComplaint as AllegationComplaintDto } from "../types/app/complaints/allegation-complaint";
import { GeneralIncidentComplaint as GeneralIncidentComplaintDto } from "../types/app/complaints/general-complaint";

type Coordinate = number[] | string[] | undefined;

Expand Down Expand Up @@ -256,6 +259,26 @@ export const parseCoordinates = (coordinates: Coordinate, coordinateType: Coordi
: coordinates[Coordinates.Longitude];
};

// Helper function for determining what type of complaint your are working with
// so you can pass that type onto the backend for proper processing
export const getComplaintType = (
complaint: WildlifeComplaintDto | AllegationComplaintDto | GeneralIncidentComplaintDto,
): string => {
if ("hwcrId" in complaint) {
return COMPLAINT_TYPES.HWCR;
}

if ("ersId" in complaint) {
return COMPLAINT_TYPES.ERS;
}

if ("girId" in complaint) {
return COMPLAINT_TYPES.GIR;
}

return "Unknown";
};

export const getComplaintTypeFromUrl = (): number => {
let p = new URLPattern({ pathname: "/complaints/:type" });
let r = p.exec(window.location.href);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,7 @@ export const CreateComplaint: FC = () => {
const model: ComplaintDto = {
id: "",
webeocId: "",
referenceNumber: "",
details: "",
name: "",
address: "",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ import { AgencyType } from "../../../../types/app/agency-types";
import { CeebOutcomeReport } from "../outcomes/ceeb/ceeb-outcome-report";
import { FEATURE_TYPES } from "../../../../constants/feature-flag-types";
import { FeatureFlag } from "../../../common/feature-flag";
import { ExternalFileReference } from "../outcomes/external-file-reference";

export type ComplaintParams = {
id: string;
Expand Down Expand Up @@ -1398,11 +1399,25 @@ export const ComplaintDetailsEdit: FC = () => {
)}
</section>

{/* HWCR Outcome Report */}
{readOnly && complaintType === COMPLAINT_TYPES.HWCR && <HWCROutcomeReport />}
{/* HWCR Outcome Report and File Linkage */}
{readOnly && complaintType === COMPLAINT_TYPES.HWCR && (
<>
<HWCROutcomeReport />
<FeatureFlag feature={FEATURE_TYPES.EXTERNAL_FILE_REFERENCE}>
<ExternalFileReference />
</FeatureFlag>
</>
)}

{/* CEEB ERS Outcome Report */}
{readOnly && complaintType === COMPLAINT_TYPES.ERS && agency === AgencyType.CEEB && <CeebOutcomeReport />}

{/* COS ERS File Linkage */}
{readOnly && complaintType === COMPLAINT_TYPES.ERS && (
<FeatureFlag feature={FEATURE_TYPES.EXTERNAL_FILE_REFERENCE}>
<ExternalFileReference />
</FeatureFlag>
)}
</div>
);
};
Loading

0 comments on commit bb20e33

Please sign in to comment.