Skip to content

Commit

Permalink
Compenf 456-457-458 (#128)
Browse files Browse the repository at this point in the history
  • Loading branch information
cnesmithsalus authored Sep 18, 2023
1 parent 12d759a commit 99571ef
Show file tree
Hide file tree
Showing 14 changed files with 467 additions and 122 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -114,14 +114,8 @@ export class AllegationComplaintController {

@Patch(":id")
@Roles(Role.COS_OFFICER)
update(
@Param("id") id: UUID,
@Body() updateAllegationComplaintDto: UpdateAllegationComplaintDto
) {
return this.allegationComplaintService.update(
id,
updateAllegationComplaintDto
);
update(@Param('id') id: UUID, @Body('allegationComplaint') updateAllegationComplaintDto: string) {
return this.allegationComplaintService.update(id, updateAllegationComplaintDto);
}

@Delete(":id")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,12 @@ import { Office } from '../office/entities/office.entity';
import { Officer } from '../officer/entities/officer.entity';
import { PersonService } from '../person/person.service';
import { Person } from '../person/entities/person.entity';
import { PersonComplaintXrefService } from '../person_complaint_xref/person_complaint_xref.service';
import { PersonComplaintXref } from '../person_complaint_xref/entities/person_complaint_xref.entity';

@Module({
imports: [TypeOrmModule.forFeature([AllegationComplaint]), TypeOrmModule.forFeature([Complaint]), TypeOrmModule.forFeature([ViolationCode]), TypeOrmModule.forFeature([AgencyCode]), TypeOrmModule.forFeature([ComplaintStatusCode]), TypeOrmModule.forFeature([GeoOrganizationUnitCode]), TypeOrmModule.forFeature([CosGeoOrgUnit]) , TypeOrmModule.forFeature([Office]),TypeOrmModule.forFeature([Officer]), TypeOrmModule.forFeature([Person])],
imports: [TypeOrmModule.forFeature([AllegationComplaint]), TypeOrmModule.forFeature([Complaint]), TypeOrmModule.forFeature([ViolationCode]), TypeOrmModule.forFeature([AgencyCode]), TypeOrmModule.forFeature([ComplaintStatusCode]), TypeOrmModule.forFeature([GeoOrganizationUnitCode]), TypeOrmModule.forFeature([CosGeoOrgUnit]) , TypeOrmModule.forFeature([Office]),TypeOrmModule.forFeature([Officer]), TypeOrmModule.forFeature([Person]), TypeOrmModule.forFeature([PersonComplaintXref])],
controllers: [AllegationComplaintController],
providers: [AllegationComplaintService, ComplaintService, ViolationCodeService, AgencyCodeService, ComplaintStatusCodeService, GeoOrganizationUnitCodeService, CosGeoOrgUnitService, OfficeService, OfficerService, PersonService]
providers: [AllegationComplaintService, ComplaintService, ViolationCodeService, AgencyCodeService, ComplaintStatusCodeService, GeoOrganizationUnitCodeService, CosGeoOrgUnitService, OfficeService, OfficerService, PersonService, PersonComplaintXrefService]
})
export class AllegationComplaintModule {}
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,9 @@ import {
ZoneAtAGlanceStats,
} from "src/types/zone_at_a_glance/zone_at_a_glance_stats";
import { CosGeoOrgUnit } from "../cos_geo_org_unit/entities/cos_geo_org_unit.entity";
import { Officer } from "../officer/entities/officer.entity";
import { Office } from "../office/entities/office.entity";
import { Officer } from '../officer/entities/officer.entity';
import { Office } from '../office/entities/office.entity';
import { PersonComplaintXrefService } from "../person_complaint_xref/person_complaint_xref.service";

@Injectable()
export class AllegationComplaintService {
Expand All @@ -36,6 +37,8 @@ export class AllegationComplaintService {
private cosGeoOrgUnitRepository: Repository<CosGeoOrgUnit>;
@Inject(ComplaintService)
protected readonly complaintService: ComplaintService;
@Inject(PersonComplaintXrefService)
protected readonly personComplaintXrefService: PersonComplaintXrefService;

async create(allegationComplaint: any): Promise<AllegationComplaint> {
const queryRunner = this.dataSource.createQueryRunner();
Expand Down Expand Up @@ -443,14 +446,48 @@ export class AllegationComplaintService {

async update(
allegation_complaint_guid: UUID,
updateAllegationComplaint: UpdateAllegationComplaintDto
updateAllegationComplaint: string
): Promise<AllegationComplaint> {
await this.allegationComplaintsRepository.update(
{ allegation_complaint_guid },
updateAllegationComplaint
);
return this.findOne(allegation_complaint_guid);
}
//const queryRunner = this.dataSource.createQueryRunner();

//await queryRunner.connect();
//await queryRunner.startTransaction();
try
{
const updateAllegationComplaintDto: UpdateAllegationComplaintDto = JSON.parse(updateAllegationComplaint);

const updateData =
{
allegation_complaint_guid: updateAllegationComplaintDto.allegation_complaint_guid,
in_progress_ind: updateAllegationComplaintDto.in_progress_ind,
observed_ind: updateAllegationComplaintDto.observed_ind,
violation_code: updateAllegationComplaintDto.violation_code,
};
const updatedValue = await this.allegationComplaintsRepository.update(
{ allegation_complaint_guid },
updateData
);
//queryRunner.manager.save(updatedValue);
//await this.complaintService.updateComplex(queryRunner, updateHwcrComplaintDto.complaint_identifier.complaint_identifier, JSON.stringify(updateHwcrComplaintDto.complaint_identifier));
await this.complaintService.updateComplex(updateAllegationComplaintDto.complaint_identifier.complaint_identifier, JSON.stringify(updateAllegationComplaintDto.complaint_identifier));
//Note: this needs a refactor for when we have more types of persons being loaded in
//await this.personComplaintXrefService.update(queryRunner, updateHwcrComplaintDto.complaint_identifier.person_complaint_xref[0].personComplaintXrefGuid, updateHwcrComplaintDto.complaint_identifier.person_complaint_xref[0]);
if(updateAllegationComplaintDto.complaint_identifier.person_complaint_xref[0] !== undefined)
{
await this.personComplaintXrefService.assignOfficer(updateAllegationComplaintDto.complaint_identifier.complaint_identifier, updateAllegationComplaintDto.complaint_identifier.person_complaint_xref[0]);
}
}
catch (err) {
this.logger.error(err);
//await queryRunner.rollbackTransaction();
throw new BadRequestException(err);
}
finally
{
//await queryRunner.release();
}
return this.findOne(allegation_complaint_guid);
}

async remove(id: UUID): Promise<{ deleted: boolean; message?: string }> {
try {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { AllegationComplaintDto } from "./allegation_complaint.dto";

export class CreateAllegationComplaintDto extends PickType(AllegationComplaintDto, [
"complaint_identifier",
"allegation_complaint_guid",
"violation_code",
"in_progress_ind",
"observed_ind",
Expand Down
7 changes: 7 additions & 0 deletions backend/src/v1/complaint/dto/complaint.dto.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { ComplaintStatusCode } from '../../complaint_status_code/entities/compla
import { GeoOrganizationUnitCode } from '../../geo_organization_unit_code/entities/geo_organization_unit_code.entity';
import { Geometry, Point } from 'geojson';
import { CosGeoOrgUnit } from '../../cos_geo_org_unit/entities/cos_geo_org_unit.entity';
import { PersonComplaintXref } from '../../person_complaint_xref/entities/person_complaint_xref.entity';

export class ComplaintDto {
@ApiProperty({
Expand Down Expand Up @@ -44,6 +45,12 @@ export class ComplaintDto {
})
cos_geo_org_unit: CosGeoOrgUnit;

@ApiProperty({
example: "DCC",
description: "The geographical organization code of the organization that currently owns the complaint",
})
person_complaint_xref: PersonComplaintXref[];

@ApiProperty({
example: "Bear overturning garbage bins",
description: "Description of the complaint",
Expand Down
2 changes: 1 addition & 1 deletion backend/src/v1/hwcr_complaint/hwcr_complaint.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -328,7 +328,7 @@ export class HwcrComplaintService {
//await this.personComplaintXrefService.update(queryRunner, updateHwcrComplaintDto.complaint_identifier.person_complaint_xref[0].personComplaintXrefGuid, updateHwcrComplaintDto.complaint_identifier.person_complaint_xref[0]);
if(updateHwcrComplaintDto.complaint_identifier.person_complaint_xref[0] !== undefined)
{
await this.personComplaintXrefService.assignOfficer(updateHwcrComplaintDto.complaint_identifier.person_complaint_xref[0].personComplaintXrefGuid, updateHwcrComplaintDto.complaint_identifier.person_complaint_xref[0]);
await this.personComplaintXrefService.assignOfficer(updateHwcrComplaintDto.complaint_identifier.complaint_identifier, updateHwcrComplaintDto.complaint_identifier.person_complaint_xref[0]);
}
//await this.attractantHwcrXrefService.updateComplaintAttractants(queryRunner, updateHwcrComplaintDto.hwcr_complaint_guid, updateHwcrComplaintDto.attractant_hwcr_xref);
await this.attractantHwcrXrefService.updateComplaintAttractants(updateHwcrComplaintDto as HwcrComplaint, updateHwcrComplaintDto.attractant_hwcr_xref);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,6 @@ export class PersonComplaintXrefService {
unassignedPersonComplaintXref.active_ind = false;
await queryRunner.manager.save(unassignedPersonComplaintXref);
}
console.log(JSON.stringify(createPersonComplaintXrefDto));
// create a new complaint assignment record
newPersonComplaintXref = await this.create(createPersonComplaintXrefDto);
this.logger.debug(
Expand Down
4 changes: 2 additions & 2 deletions backend/src/v1/violation_code/violation_code.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ export class ViolationCodeService {
return this.violationCodeRepository.find();
}

async findOne(id: any): Promise<ViolationCode> {
return this.violationCodeRepository.findOneOrFail(id);
async findOne(id: string): Promise<ViolationCode> {
return this.violationCodeRepository.findOneByOrFail({violation_code: id});
}

async update(violation_code: string, updateViolationCodeDto: UpdateViolationCodeDto): Promise<ViolationCode> {
Expand Down
11 changes: 11 additions & 0 deletions frontend/src/app/common/validation-phone-input.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,17 @@ interface ValidationPhoneInputProps {
className={calulatedClass}
value={defaultValue}
onChange={e => onChange(e)}
onKeyUp={(e: any) => {
var index = (e.target.value.length - 1);
var key = e.code;

if (index === 0 && (key === 'Numpad0' || key === 'Digit0' || key === "Numpad1" || key === "Digit1")) {
e.preventDefault();
} else {
return true;
}
return false;
}}
maxLength={14} //phone input counts () - space, so this is actually a 10 character number
international={false}
initialValueFormat="national"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,6 @@ export const BCGeocoderAutocomplete: FC<Props> = ({
setAddressOptions(options);*/
setInputValue(inputValue);
parentOnChange(inputValue);
console.log("inputValue: " + JSON.stringify(inputValue));
//console.log("inputChange: " + JSON.stringify(options));
};

const dispatch = useAppDispatch();
Expand Down
Loading

0 comments on commit 99571ef

Please sign in to comment.